CommerceBees_CustomerGroupRestriction_v1 - Version 1.0.0

Version Notes

First version of Customer group restriction module is released

Download this release

Release Info

Developer Commerce Bees
Extension CommerceBees_CustomerGroupRestriction_v1
Version 1.0.0
Comparing to
See all releases


Version 1.0.0

CommerceBees_CustomerGroupRestriction_Extension_Guide_V1.0.pdf ADDED
Binary file
app/code/local/Ameex/CustomerGroupRestriction/Model/Backend/Group.php ADDED
@@ -0,0 +1,36 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ class Ameex_CustomerGroupRestriction_Model_Backend_Group extends Mage_Eav_Model_Entity_Attribute_Backend_Abstract
4
+ {
5
+ const ATTRIBUTE_CODE = 'restrict_groups';
6
+
7
+ public function beforeSave($object)
8
+ {
9
+ $attributeCode = $this->getAttribute()->getName();
10
+ if ($attributeCode == self::ATTRIBUTE_CODE) {
11
+ $data = $object->getData($attributeCode);
12
+ $postData = Mage::app()->getRequest()->getPost('product');
13
+ if (!empty($postData) && empty($postData[$attributeCode])) {
14
+ $data = array();
15
+ }
16
+ if (is_array($data)) {
17
+ $object->setData($attributeCode, implode(',', $data));
18
+ }
19
+ }
20
+
21
+ parent::beforeSave($object);
22
+ }
23
+
24
+ public function afterLoad($object)
25
+ {
26
+ $attributeCode = $this->getAttribute()->getName();
27
+ if ($attributeCode == self::ATTRIBUTE_CODE) {
28
+ $data = $object->getData($attributeCode);
29
+ if (!is_array($data)) {
30
+ $object->setData($attributeCode, explode(',', $data));
31
+ }
32
+ }
33
+
34
+ parent::afterLoad($object);
35
+ }
36
+ }
app/code/local/Ameex/CustomerGroupRestriction/Model/Observer.php ADDED
@@ -0,0 +1,42 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ class Ameex_CustomerGroupRestriction_Model_Observer
3
+ {
4
+ public function checkoutCustomerRestriction(Varien_Event_Observer $observer) {
5
+ $quote = Mage::getSingleton('checkout/session')->getQuote();
6
+ $_items = $quote->getAllItems();
7
+ $noOfRestrictedProductsInCart = 0;
8
+ $restrictedProductsName = array();
9
+ foreach ($_items as $_item) {
10
+ $groupId = Mage::getSingleton('customer/session')->getCustomerGroupId();
11
+ $_product = Mage::getModel('catalog/product')->loadByAttribute('sku',$_item->getSku());
12
+ $restrictedCustomerGroups = explode(',',$_product->getRestrictGroups());
13
+ if(empty($restrictedCustomerGroups) || ((count($restrictedCustomerGroups) == 1) && ($restrictedCustomerGroups[0] == '0'))) {
14
+ $allowAddToCart = true;
15
+ }
16
+ else if(in_array($groupId,$restrictedCustomerGroups)) {
17
+ $allowAddToCart = false;
18
+ }
19
+ else {
20
+ $allowAddToCart = true;
21
+ }
22
+ if(!$allowAddToCart) {
23
+ $restrictedProductsName[++$noOfRestrictedProductsInCart] = $_product->getName();
24
+ }
25
+ }
26
+ if($noOfRestrictedProductsInCart > 0) {
27
+ $message = "Please remove the following restricted items from your cart:";
28
+ foreach($restrictedProductsName as $key=>$value) {
29
+ $message .= "\n".$key.". ".$value;
30
+ }
31
+ $this->_throwError($observer,$message);
32
+ }
33
+ }
34
+
35
+ private function _throwError($observer,$message) {
36
+ $controller = $observer->getControllerAction();
37
+ $controller->setFlag('', Mage_Core_Controller_Varien_Action::FLAG_NO_DISPATCH, true);
38
+ $response = array('error' => -1, 'message' => $message);
39
+ return $controller->getResponse()->setBody(Mage::helper('core')->jsonEncode($response));
40
+ }
41
+ }
42
+ ?>
app/code/local/Ameex/CustomerGroupRestriction/Model/Product.php ADDED
@@ -0,0 +1,42 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ class Ameex_CustomerGroupRestriction_Model_Product extends Mage_Catalog_Model_Product
4
+ {
5
+ public function isSalable()
6
+ {
7
+ Mage::dispatchEvent('catalog_product_is_salable_before', array(
8
+ 'product' => $this
9
+ ));
10
+
11
+ $salable = $this->isAvailable();
12
+
13
+ $object = new Varien_Object(array(
14
+ 'product' => $this,
15
+ 'is_salable' => $salable
16
+ ));
17
+ Mage::dispatchEvent('catalog_product_is_salable_after', array(
18
+ 'product' => $this,
19
+ 'salable' => $object
20
+ ));
21
+
22
+ $_product = Mage::getModel('catalog/product')->load($this->getId());
23
+ $groupId = Mage::getSingleton('customer/session')->getCustomerGroupId();
24
+ $restrictedCustomerGroups = $_product->getRestrictGroups();
25
+ if(empty($restrictedCustomerGroups) || ((count($restrictedCustomerGroups) == 1) && (($restrictedCustomerGroups[0] == '0') || ($restrictedCustomerGroups[0] == '')))) {
26
+ $allowAddToCart = true;
27
+ }
28
+ else if(in_array($groupId,$restrictedCustomerGroups)) {
29
+ $allowAddToCart = false;
30
+ }
31
+ else {
32
+ $allowAddToCart = true;
33
+ }
34
+ if(!$allowAddToCart) {
35
+ $object->setIsSalable($allowAddToCart);
36
+ }
37
+
38
+ return $object->getIsSalable();
39
+ }
40
+ }
41
+
42
+ ?>
app/code/local/Ameex/CustomerGroupRestriction/Model/Source/Group.php ADDED
@@ -0,0 +1,20 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ class Ameex_CustomerGroupRestriction_Model_Source_Group extends Mage_Eav_Model_Entity_Attribute_Source_Abstract
4
+ {
5
+
6
+ public function getAllOptions()
7
+ {
8
+ $groups = Mage::getResourceModel('customer/group_collection')
9
+ ->addFieldToFilter('customer_group_id', array('gt'=> 0))
10
+ ->load()
11
+ ->toOptionArray();
12
+
13
+ array_unshift($groups, array(
14
+ 'value' => 0,
15
+ 'label' => Mage::helper('core')->__('None')
16
+ ));
17
+
18
+ return $groups;
19
+ }
20
+ }
app/code/local/Ameex/CustomerGroupRestriction/etc/config.xml ADDED
@@ -0,0 +1,47 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?xml version="1.0"?>
2
+ <config>
3
+ <modules>
4
+ <Ameex_CustomerGroupRestriction>
5
+ <version>1.0</version>
6
+ </Ameex_CustomerGroupRestriction>
7
+ </modules>
8
+ <frontend>
9
+ <layout>
10
+ <updates>
11
+ <customergrouprestriction>
12
+ <file>customergrouprestriction.xml</file>
13
+ </customergrouprestriction>
14
+ </updates>
15
+ </layout>
16
+ </frontend>
17
+ <global>
18
+ <events>
19
+ <controller_action_predispatch_checkout_onepage_saveBilling>
20
+ <observers>
21
+ <checkout_customer_restriction>
22
+ <class>Ameex_CustomerGroupRestriction_Model_Observer</class>
23
+ <method>checkoutCustomerRestriction</method>
24
+ </checkout_customer_restriction>
25
+ </observers>
26
+ </controller_action_predispatch_checkout_onepage_saveBilling>
27
+ </events>
28
+ <resources>
29
+ <customergrouprestriction_setup>
30
+ <setup>
31
+ <module>Ameex_CustomerGroupRestriction</module>
32
+ <class>Mage_Catalog_Model_Resource_Setup</class>
33
+ </setup>
34
+ </customergrouprestriction_setup>
35
+ </resources>
36
+ <models>
37
+ <ameex_customergrouprestriction>
38
+ <class>Ameex_CustomerGroupRestriction_Model</class>
39
+ </ameex_customergrouprestriction>
40
+ <catalog>
41
+ <rewrite>
42
+ <product>Ameex_CustomerGroupRestriction_Model_Product</product>
43
+ </rewrite>
44
+ </catalog>
45
+ </models>
46
+ </global>
47
+ </config>
app/code/local/Ameex/CustomerGroupRestriction/sql/customergrouprestriction_setup/mysql4-install-0.0.1.php ADDED
@@ -0,0 +1,18 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ /* @var $installer Mage_Catalog_Model_Resource_Setup */
4
+ $installer = $this;
5
+
6
+ $installer->startSetup();
7
+ $installer->addAttribute('catalog_product', 'restrict_groups', array(
8
+ 'label' => 'Hide from customer groups',
9
+ 'group' => 'General',
10
+ 'input' => 'multiselect',
11
+ 'required' => false,
12
+ 'source' => 'ameex_customergrouprestriction/source_group',
13
+ 'backend' => 'ameex_customergrouprestriction/backend_group',
14
+ 'global' => Mage_Catalog_Model_Resource_Eav_Attribute::SCOPE_GLOBAL,
15
+ 'used_in_product_listing' => true,
16
+ ));
17
+
18
+ $installer->endSetup();
app/design/frontend/base/default/layout/customergrouprestriction.xml ADDED
@@ -0,0 +1,38 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?xml version="1.0" encoding="UTF-8"?>
2
+ <layout version="0.1.0">
3
+ <catalog_category_default>
4
+ <reference name="product_list">
5
+ <action method="setTemplate"><template>customergrouprestriction/catalog/product/list.phtml</template></action>
6
+ </reference>
7
+ </catalog_category_default>
8
+ <catalog_category_layered>
9
+ <reference name="product_list">
10
+ <action method="setTemplate"><template>customergrouprestriction/catalog/product/list.phtml</template></action>
11
+ </reference>
12
+ </catalog_category_layered>
13
+ <catalogsearch_result_index>
14
+ <reference name="search_result_list">
15
+ <action method="setTemplate"><template>customergrouprestriction/catalog/product/list.phtml</template></action>
16
+ </reference>
17
+ </catalogsearch_result_index>
18
+ <catalogsearch_advanced_result>
19
+ <reference name="search_result_list">
20
+ <action method="setTemplate"><template>customergrouprestriction/catalog/product/list.phtml</template></action>
21
+ </reference>
22
+ </catalogsearch_advanced_result>
23
+ <tag_product_list>
24
+ <reference name="search_result_list">
25
+ <action method="setTemplate"><template>customergrouprestriction/catalog/product/list.phtml</template></action>
26
+ </reference>
27
+ </tag_product_list>
28
+ <catalog_product_compare_index translate="label">
29
+ <reference name="catalog.compare.list">
30
+ <action method="setTemplate"><template>customergrouprestriction/catalog/product/compare/list.phtml</template></action>
31
+ </reference>
32
+ </catalog_product_compare_index>
33
+ <checkout_cart_index>
34
+ <reference name="checkout.cart.crosssell">
35
+ <action method="setTemplate"><template>customergrouprestriction/checkout/cart/crosssell.phtml</template></action>
36
+ </reference>
37
+ </checkout_cart_index>
38
+ </layout>
app/design/frontend/base/default/template/customergrouprestriction/catalog/product/compare/list.phtml ADDED
@@ -0,0 +1,166 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * Magento
4
+ *
5
+ * NOTICE OF LICENSE
6
+ *
7
+ * This source file is subject to the Academic Free License (AFL 3.0)
8
+ * that is bundled with this package in the file LICENSE_AFL.txt.
9
+ * It is also available through the world-wide-web at this URL:
10
+ * http://opensource.org/licenses/afl-3.0.php
11
+ * If you did not receive a copy of the license and are unable to
12
+ * obtain it through the world-wide-web, please send an email
13
+ * to license@magentocommerce.com so we can send you a copy immediately.
14
+ *
15
+ * DISCLAIMER
16
+ *
17
+ * Do not edit or add to this file if you wish to upgrade Magento to newer
18
+ * versions in the future. If you wish to customize Magento for your
19
+ * needs please refer to http://www.magentocommerce.com for more information.
20
+ *
21
+ * @category design
22
+ * @package base_default
23
+ * @copyright Copyright (c) 2013 Magento Inc. (http://www.magentocommerce.com)
24
+ * @license http://opensource.org/licenses/afl-3.0.php Academic Free License (AFL 3.0)
25
+ */
26
+ /* @var $this Mage_Catalog_Block_Product_Compare_List */
27
+ ?>
28
+ <div class="page-title title-buttons">
29
+ <h1><?php echo $this->__('Compare Products') ?></h1>
30
+ <a href="#" onclick="window.print(); return false;" class="link-print"><?php echo $this->__('Print This Page') ?></a>
31
+ </div>
32
+ <?php $_total=$this->getItems()->getSize() ?>
33
+ <?php if($_total): ?>
34
+ <table class="data-table compare-table" id="product_comparison">
35
+ <?php $_i=0 ?>
36
+ <?php foreach($this->getItems() as $_item): ?>
37
+ <?php if($_i++%10==0): ?>
38
+ <col width="1" />
39
+ <?php endif; ?>
40
+ <col width="<?php echo floor(100/$_total); ?>%" />
41
+ <?php endforeach; ?>
42
+ <?php if ($_total>2): ?>
43
+ <thead>
44
+ <tr>
45
+ <?php $_i=0 ?>
46
+ <?php foreach($this->getItems() as $_item): ?>
47
+ <?php if($_i++%10==0): ?>
48
+ <th>&nbsp;</th>
49
+ <?php endif; ?>
50
+ <td class="a-right"><a href="#" class="btn-remove" onclick="removeItem('<?php echo $this->helper('catalog/product_compare')->getRemoveUrl($_item) ?>');" title="<?php echo $this->__('Remove This Item') ?>"><?php echo $this->__('Remove This Item') ?></a></td>
51
+ <?php endforeach; ?>
52
+ </tr>
53
+ </thead>
54
+ <?php endif ?>
55
+ <tbody>
56
+ <tr class="product-shop-row">
57
+ <?php $_i=0 ?>
58
+ <?php foreach($this->getItems() as $_item): ?>
59
+ <?php if($_i++%10==0): ?>
60
+ <th>&nbsp;</th>
61
+ <?php endif; ?>
62
+ <td>
63
+ <a class="product-image" href="#" onclick="setPLocation('<?php echo $this->getProductUrl($_item) ?>', true)" title="<?php echo $this->stripTags($_item->getName(), null, true) ?>"><img src="<?php echo $this->helper('catalog/image')->init($_item, 'small_image')->resize(125, 125); ?>" width="125" height="125" alt="<?php echo $this->stripTags($_item->getName(), null, true) ?>" /></a>
64
+ <h2 class="product-name"><a href="#" onclick="setPLocation('<?php echo $this->getProductUrl($_item) ?>', true)" title="<?php echo $this->stripTags($_item->getName(), null, true) ?>"><?php echo $this->helper('catalog/output')->productAttribute($_item, $_item->getName(), 'name') ?></a></h2>
65
+ <?php echo $this->getReviewsSummaryHtml($_item, 'short') ?>
66
+ <?php echo $this->getPriceHtml($_item, true, '-compare-list-top') ?>
67
+ <?php if($_item->isSaleable()): ?>
68
+ <p><button type="button" title="<?php echo $this->__('Add to Cart') ?>" class="button btn-cart" onclick="setPLocation('<?php echo $this->helper('catalog/product_compare')->getAddToCartUrl($_item) ?>', true)"><span><span><?php echo $this->__('Add to Cart') ?></span></span></button></p>
69
+ <?php elseif ($_item->isAvailable()): ?>
70
+ <p class="availability in-stock"><span><?php echo $this->__('In stock') ?></span></p>
71
+ <?php else: ?>
72
+ <p class="availability out-of-stock"><span><?php echo $this->__('Out of stock') ?></span></p>
73
+ <?php endif; ?>
74
+ <?php if ($this->helper('wishlist')->isAllow()) : ?>
75
+ <ul class="add-to-links">
76
+ <li><a href="<?php echo $this->getAddToWishlistUrl($_item) ?>" class="link-wishlist"><?php echo $this->__('Add to Wishlist') ?></a></li>
77
+ </ul>
78
+ <?php endif; ?>
79
+ </td>
80
+ <?php endforeach; ?>
81
+ </tr>
82
+ </tbody>
83
+ <tbody>
84
+ <?php foreach ($this->getAttributes() as $_attribute): ?>
85
+ <tr>
86
+ <?php $_i=0 ?>
87
+ <?php foreach($this->getItems() as $_item): ?>
88
+ <?php if($_i++%10==0): ?>
89
+ <th><span class="nobr"><?php echo $_attribute->getStoreLabel() ?></span></th>
90
+ <?php endif; ?>
91
+ <td>
92
+ <?php switch ($_attribute->getAttributeCode()) {
93
+ case "price": ?>
94
+ <?php echo $this->getPriceHtml($_item, true, '-compare-list-' . $_attribute->getCode()) ?>
95
+ <?php break;
96
+ case "small_image": ?>
97
+ <img src="<?php echo $this->helper('catalog/image')->init($_item, 'small_image')->resize(125, 125); ?>" width="125" height="125" alt="<?php echo $this->escapeHtml($_item->getName()) ?>" title="<?php echo $this->escapeHtml($_item->getName()) ?>" />
98
+ <?php break;
99
+ case "date":
100
+ echo substr($this->getProductAttributeValue($_item, $_attribute),0,10);
101
+ break;
102
+ default: ?>
103
+ <div class="std">
104
+ <?php echo $this->helper('catalog/output')->productAttribute($_item, $this->getProductAttributeValue($_item, $_attribute), $_attribute->getAttributeCode()) ?>
105
+ </div>
106
+ <?php break;
107
+ } ?>
108
+ </td>
109
+ <?php endforeach; ?>
110
+ </tr>
111
+ <?php endforeach; ?>
112
+ </tbody>
113
+ <tbody>
114
+ <tr class="add-to-row">
115
+ <?php $_i=0 ?>
116
+ <?php foreach($this->getItems() as $_item): ?>
117
+ <?php if($_i++%10==0): ?>
118
+ <th>&nbsp;</th>
119
+ <?php endif; ?>
120
+ <td>
121
+ <?php echo $this->getPriceHtml($_item, true, '-compare-list-bottom') ?>
122
+ <?php if($_item->isSaleable()): ?>
123
+ <p><button type="button" title="<?php echo $this->__('Add to Cart') ?>" class="button btn-cart" onclick="setPLocation('<?php echo $this->helper('catalog/product_compare')->getAddToCartUrl($_item) ?>', true)"><span><span><?php echo $this->__('Add to Cart') ?></span></span></button></p>
124
+ <?php elseif ($_item->isAvailable()): ?>
125
+ <p class="availability in-stock"><span><?php echo $this->__('In stock') ?></span></p>
126
+ <?php else: ?>
127
+ <p class="availability out-of-stock"><span><?php echo $this->__('Out of stock') ?></span></p>
128
+ <?php endif; ?>
129
+ <?php if ($this->helper('wishlist')->isAllow()) : ?>
130
+ <ul class="add-to-links">
131
+ <li><a href="<?php echo $this->getAddToWishlistUrl($_item);?>" class="link-wishlist"><?php echo $this->__('Add to Wishlist') ?></a></li>
132
+ </ul>
133
+ <?php endif; ?>
134
+ </td>
135
+ <?php endforeach; ?>
136
+ </tr>
137
+ </tbody>
138
+ </table>
139
+ <div class="buttons-set">
140
+ <button type="button" title="<?php echo $this->__('Close Window') ?>" class="button" onclick="window.close();"><span><span><?php echo $this->__('Close Window') ?></span></span></button>
141
+ <span class="please-wait" id="compare-list-please-wait" style="display:none;">
142
+ <img src="<?php echo $this->getSkinUrl('images/opc-ajax-loader.gif') ?>" alt="<?php echo $this->__('Please wait...') ?>" title="<?php echo $this->__('Please wait...') ?>" class="v-middle" /> <?php echo $this->__('Please wait...') ?>
143
+ </span>
144
+ </div>
145
+ <script type="text/javascript">
146
+ decorateTable('product_comparison');
147
+
148
+ /**
149
+ * Send remove item request, after that reload windows
150
+ */
151
+ function removeItem(url)
152
+ {
153
+ new Ajax.Request(url, {
154
+ parameters: {isAjax: 1, method: 'POST'},
155
+ onLoading: function(){$('compare-list-please-wait').show();},
156
+ onSuccess: function(transport) {
157
+ $('compare-list-please-wait').hide();
158
+ window.location.reload();
159
+ window.opener.location.reload();
160
+ }
161
+ });
162
+ }
163
+ </script>
164
+ <?php else: ?>
165
+ <script type="text/javascript">window.close();</script>
166
+ <?php endif; ?>
app/design/frontend/base/default/template/customergrouprestriction/catalog/product/list.phtml ADDED
@@ -0,0 +1,132 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * Magento
4
+ *
5
+ * NOTICE OF LICENSE
6
+ *
7
+ * This source file is subject to the Academic Free License (AFL 3.0)
8
+ * that is bundled with this package in the file LICENSE_AFL.txt.
9
+ * It is also available through the world-wide-web at this URL:
10
+ * http://opensource.org/licenses/afl-3.0.php
11
+ * If you did not receive a copy of the license and are unable to
12
+ * obtain it through the world-wide-web, please send an email
13
+ * to license@magentocommerce.com so we can send you a copy immediately.
14
+ *
15
+ * DISCLAIMER
16
+ *
17
+ * Do not edit or add to this file if you wish to upgrade Magento to newer
18
+ * versions in the future. If you wish to customize Magento for your
19
+ * needs please refer to http://www.magentocommerce.com for more information.
20
+ *
21
+ * @category design
22
+ * @package base_default
23
+ * @copyright Copyright (c) 2013 Magento Inc. (http://www.magentocommerce.com)
24
+ * @license http://opensource.org/licenses/afl-3.0.php Academic Free License (AFL 3.0)
25
+ */
26
+ ?>
27
+ <?php
28
+ /**
29
+ * Product list template
30
+ *
31
+ * @see Mage_Catalog_Block_Product_List
32
+ */
33
+ ?>
34
+ <?php
35
+ $_productCollection=$this->getLoadedProductCollection();
36
+ $_helper = $this->helper('catalog/output');
37
+ ?>
38
+ <?php if(!$_productCollection->count()): ?>
39
+ <p class="note-msg"><?php echo $this->__('There are no products matching the selection.') ?></p>
40
+ <?php else: ?>
41
+ <div class="category-products">
42
+ <?php echo $this->getToolbarHtml() ?>
43
+ <?php // List mode ?>
44
+ <?php if($this->getMode()!='grid'): ?>
45
+ <?php $_iterator = 0; ?>
46
+ <ol class="products-list" id="products-list">
47
+ <?php foreach ($_productCollection as $_product): ?>
48
+ <li class="item<?php if( ++$_iterator == sizeof($_productCollection) ): ?> last<?php endif; ?>">
49
+ <?php // Product Image ?>
50
+ <a href="<?php echo $_product->getProductUrl() ?>" title="<?php echo $this->stripTags($this->getImageLabel($_product, 'small_image'), null, true) ?>" class="product-image"><img src="<?php echo $this->helper('catalog/image')->init($_product, 'small_image')->resize(135); ?>" width="135" height="135" alt="<?php echo $this->stripTags($this->getImageLabel($_product, 'small_image'), null, true) ?>" /></a>
51
+ <?php // Product description ?>
52
+ <div class="product-shop">
53
+ <div class="f-fix">
54
+ <?php $_productNameStripped = $this->stripTags($_product->getName(), null, true); ?>
55
+ <h2 class="product-name"><a href="<?php echo $_product->getProductUrl() ?>" title="<?php echo $_productNameStripped; ?>"><?php echo $_helper->productAttribute($_product, $_product->getName() , 'name'); ?></a></h2>
56
+ <?php if($_product->getRatingSummary()): ?>
57
+ <?php echo $this->getReviewsSummaryHtml($_product) ?>
58
+ <?php endif; ?>
59
+ <?php echo $this->getPriceHtml($_product, true) ?>
60
+ <?php if($_product->isSaleable()): ?>
61
+ <p><button type="button" title="<?php echo $this->__('Add to Cart') ?>" class="button btn-cart" onclick="setLocation('<?php echo $this->getAddToCartUrl($_product) ?>')"><span><span><?php echo $this->__('Add to Cart') ?></span></span></button></p>
62
+ <?php elseif ($_product->isAvailable()): ?>
63
+ <p class="availability in-stock"><span><?php echo $this->__('In stock') ?></span></p>
64
+ <?php else: ?>
65
+ <p class="availability out-of-stock"><span><?php echo $this->__('Out of stock') ?></span></p>
66
+ <?php endif; ?>
67
+ <div class="desc std">
68
+ <?php echo $_helper->productAttribute($_product, $_product->getShortDescription(), 'short_description') ?>
69
+ <a href="<?php echo $_product->getProductUrl() ?>" title="<?php echo $_productNameStripped ?>" class="link-learn"><?php echo $this->__('Learn More') ?></a>
70
+ </div>
71
+ <ul class="add-to-links">
72
+ <?php if ($this->helper('wishlist')->isAllow()) : ?>
73
+ <li><a href="<?php echo $this->helper('wishlist')->getAddUrl($_product) ?>" class="link-wishlist"><?php echo $this->__('Add to Wishlist') ?></a></li>
74
+ <?php endif; ?>
75
+ <?php if($_compareUrl=$this->getAddToCompareUrl($_product)): ?>
76
+ <li><span class="separator">|</span> <a href="<?php echo $_compareUrl ?>" class="link-compare"><?php echo $this->__('Add to Compare') ?></a></li>
77
+ <?php endif; ?>
78
+ </ul>
79
+ </div>
80
+ </div>
81
+ </li>
82
+ <?php endforeach; ?>
83
+ </ol>
84
+ <script type="text/javascript">decorateList('products-list', 'none-recursive')</script>
85
+
86
+ <?php else: ?>
87
+
88
+ <?php // Grid Mode ?>
89
+
90
+ <?php $_collectionSize = $_productCollection->count() ?>
91
+ <?php $_columnCount = $this->getColumnCount(); ?>
92
+ <?php $i=0; foreach ($_productCollection as $_product): ?>
93
+ <?php if ($i++%$_columnCount==0): ?>
94
+ <ul class="products-grid">
95
+ <?php endif ?>
96
+ <li class="item<?php if(($i-1)%$_columnCount==0): ?> first<?php elseif($i%$_columnCount==0): ?> last<?php endif; ?>">
97
+ <a href="<?php echo $_product->getProductUrl() ?>" title="<?php echo $this->stripTags($this->getImageLabel($_product, 'small_image'), null, true) ?>" class="product-image"><img src="<?php echo $this->helper('catalog/image')->init($_product, 'small_image')->resize(135); ?>" width="135" height="135" alt="<?php echo $this->stripTags($this->getImageLabel($_product, 'small_image'), null, true) ?>" /></a>
98
+ <h2 class="product-name"><a href="<?php echo $_product->getProductUrl() ?>" title="<?php echo $this->stripTags($_product->getName(), null, true) ?>"><?php echo $_helper->productAttribute($_product, $_product->getName(), 'name') ?></a></h2>
99
+ <?php if($_product->getRatingSummary()): ?>
100
+ <?php echo $this->getReviewsSummaryHtml($_product, 'short') ?>
101
+ <?php endif; ?>
102
+ <?php echo $this->getPriceHtml($_product, true) ?>
103
+ <div class="actions">
104
+ <?php if($_product->isSaleable()): ?>
105
+ <button type="button" title="<?php echo $this->__('Add to Cart') ?>" class="button btn-cart" onclick="setLocation('<?php echo $this->getAddToCartUrl($_product) ?>')"><span><span><?php echo $this->__('Add to Cart') ?></span></span></button>
106
+ <?php elseif ($_product->isAvailable()): ?>
107
+ <p class="availability in-stock"><span><?php echo $this->__('In stock') ?></span></p>
108
+ <?php else: ?>
109
+ <p class="availability out-of-stock"><span><?php echo $this->__('Out of stock') ?></span></p>
110
+ <?php endif; ?>
111
+ <ul class="add-to-links">
112
+ <?php if ($this->helper('wishlist')->isAllow()) : ?>
113
+ <li><a href="<?php echo $this->helper('wishlist')->getAddUrl($_product) ?>" class="link-wishlist"><?php echo $this->__('Add to Wishlist') ?></a></li>
114
+ <?php endif; ?>
115
+ <?php if($_compareUrl=$this->getAddToCompareUrl($_product)): ?>
116
+ <li><span class="separator">|</span> <a href="<?php echo $_compareUrl ?>" class="link-compare"><?php echo $this->__('Add to Compare') ?></a></li>
117
+ <?php endif; ?>
118
+ </ul>
119
+ </div>
120
+ </li>
121
+ <?php if ($i%$_columnCount==0 || $i==$_collectionSize): ?>
122
+ </ul>
123
+ <?php endif ?>
124
+ <?php endforeach ?>
125
+ <script type="text/javascript">decorateGeneric($$('ul.products-grid'), ['odd','even','first','last'])</script>
126
+ <?php endif; ?>
127
+
128
+ <div class="toolbar-bottom">
129
+ <?php echo $this->getToolbarHtml() ?>
130
+ </div>
131
+ </div>
132
+ <?php endif; ?>
app/design/frontend/base/default/template/customergrouprestriction/checkout/cart/crosssell.phtml ADDED
@@ -0,0 +1,61 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * Magento
4
+ *
5
+ * NOTICE OF LICENSE
6
+ *
7
+ * This source file is subject to the Academic Free License (AFL 3.0)
8
+ * that is bundled with this package in the file LICENSE_AFL.txt.
9
+ * It is also available through the world-wide-web at this URL:
10
+ * http://opensource.org/licenses/afl-3.0.php
11
+ * If you did not receive a copy of the license and are unable to
12
+ * obtain it through the world-wide-web, please send an email
13
+ * to license@magentocommerce.com so we can send you a copy immediately.
14
+ *
15
+ * DISCLAIMER
16
+ *
17
+ * Do not edit or add to this file if you wish to upgrade Magento to newer
18
+ * versions in the future. If you wish to customize Magento for your
19
+ * needs please refer to http://www.magentocommerce.com for more information.
20
+ *
21
+ * @category design
22
+ * @package base_default
23
+ * @copyright Copyright (c) 2013 Magento Inc. (http://www.magentocommerce.com)
24
+ * @license http://opensource.org/licenses/afl-3.0.php Academic Free License (AFL 3.0)
25
+ */
26
+ ?>
27
+ <?php
28
+ /**
29
+ * Cart cross sell items template
30
+ *
31
+ * @see Mage_Checkout_Block_Cart_Crosssell
32
+ */
33
+ ?>
34
+ <?php if($this->getItemCount()): ?>
35
+ <div class="crosssell">
36
+ <h2><?php echo $this->__('Based on your selection, you may be interested in the following items:') ?></h2>
37
+ <ul id="crosssell-products-list">
38
+ <?php foreach ($this->getItems() as $_item): ?>
39
+ <li class="item">
40
+ <a class="product-image" href="<?php echo $_item->getProductUrl() ?>" title="<?php echo $this->escapeHtml($_item->getName()) ?>"><img src="<?php echo $this->helper('catalog/image')->init($_item, 'thumbnail')->resize(75); ?>" width="75" height="75" alt="<?php echo $this->escapeHtml($_item->getName()) ?>" /></a>
41
+ <div class="product-details">
42
+ <h3 class="product-name"><a href="<?php echo $_item->getProductUrl() ?>"><?php echo $this->escapeHtml($_item->getName()) ?></a></h3>
43
+ <?php echo $this->getPriceHtml($_item, true) ?>
44
+ <?php if($_item->isSaleable()): ?>
45
+ <button type="button" title="<?php echo $this->__('Add to Cart') ?>" class="button btn-cart" onclick="setLocation('<?php echo $this->getAddToCartUrl($_item) ?>')"><span><span><?php echo $this->__('Add to Cart') ?></span></span></button>
46
+ <?php endif;?>
47
+ <ul class="add-to-links">
48
+ <?php if ($this->helper('wishlist')->isAllow()) : ?>
49
+ <li><a href="<?php echo $this->getAddToWishlistUrl($_item) ?>" class="link-wishlist"><?php echo $this->__('Add to Wishlist') ?></a></li>
50
+ <?php endif; ?>
51
+ <?php if($_compareUrl=$this->getAddToCompareUrl($_item)): ?>
52
+ <li><span class="separator">|</span> <a href="<?php echo $_compareUrl ?>" class="link-compare"><?php echo $this->__('Add to Compare') ?></a></li>
53
+ <?php endif; ?>
54
+ </ul>
55
+ </div>
56
+ </li>
57
+ <?php endforeach; ?>
58
+ </ul>
59
+ <script type="text/javascript">decorateList('crosssell-products-list', 'none-recursive')</script>
60
+ </div>
61
+ <?php endif; ?>
app/etc/modules/Ameex_CustomerGroupRestriction.xml ADDED
@@ -0,0 +1,9 @@
 
 
 
 
 
 
 
 
 
1
+ <?xml version="1.0"?>
2
+ <config>
3
+ <modules>
4
+ <Ameex_CustomerGroupRestriction>
5
+ <codePool>local</codePool>
6
+ <active>true</active>
7
+ </Ameex_CustomerGroupRestriction>
8
+ </modules>
9
+ </config>
package.xml ADDED
@@ -0,0 +1,18 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?xml version="1.0"?>
2
+ <package>
3
+ <name>CommerceBees_CustomerGroupRestriction_v1</name>
4
+ <version>1.0.0</version>
5
+ <stability>stable</stability>
6
+ <license uri="https://www.gnu.org/copyleft/gpl.html">GPL v3</license>
7
+ <channel>community</channel>
8
+ <extends/>
9
+ <summary>Customer group restriction is a free Magento module to restrict some customer groups from buying certain products</summary>
10
+ <description>Customer group restriction is a free Magento module to restrict some customer groups from buying certain products</description>
11
+ <notes>First version of Customer group restriction module is released</notes>
12
+ <authors><author><name>Commerce Bees</name><user>CommerceBees</user><email>support@commercebees.com</email></author></authors>
13
+ <date>2014-02-27</date>
14
+ <time>14:42:32</time>
15
+ <contents><target name="magelocal"><dir name="Ameex"><dir name="CustomerGroupRestriction"><dir name="Model"><dir name="Backend"><file name="Group.php" hash="f24eadc38e45c75905f7a88f19120cec"/></dir><file name="Observer.php" hash="e863e07690a9676983fb61d4bf1a951c"/><file name="Product.php" hash="0f16637b3e0af4a8f0f1689ab594f1ec"/><dir name="Source"><file name="Group.php" hash="fc9e7b288a6a57a28650a8049d32e956"/></dir></dir><dir name="etc"><file name="config.xml" hash="082dcdf853dabf6f844c5fef4ba7b7d6"/></dir><dir name="sql"><dir name="customergrouprestriction_setup"><file name="mysql4-install-0.0.1.php" hash="d2d158f8ee2cdc05efe2fbb1bf9a66d2"/></dir></dir></dir></dir></target><target name="magedesign"><dir name="frontend"><dir name="base"><dir name="default"><dir name="layout"><file name="customergrouprestriction.xml" hash="71ea236a632778c9a5243a0ed977388c"/></dir><dir name="template"><dir name="customergrouprestriction"><dir name="catalog"><dir name="product"><dir name="compare"><file name="list.phtml" hash="04ce582f321a2de12d2b2e6cb3faa6ae"/></dir><file name="list.phtml" hash="f15543d86e9c41920e11fc337025ea9c"/></dir></dir><dir name="checkout"><dir name="cart"><file name="crosssell.phtml" hash="edd009e4203bd3f9901163937bb1c8d1"/></dir></dir></dir></dir></dir></dir></dir></target><target name="mageetc"><dir name="modules"><file name="Ameex_CustomerGroupRestriction.xml" hash="f9634c4f37189d58f6b12e467d7222ec"/></dir></target><target name="mage"><dir name="."><file name="CommerceBees_CustomerGroupRestriction_Extension_Guide_V1.0.pdf" hash="586466d775c18d4d074647639bbad5fe"/></dir></target></contents>
16
+ <compatible/>
17
+ <dependencies><required><php><min>5.2.0</min><max>7.0.0</max></php></required></dependencies>
18
+ </package>