auguriaproductmatrix - Version 0.0.1

Version Notes

Compatibility with magento 1.9

Download this release

Release Info

Developer Auguria
Extension auguriaproductmatrix
Version 0.0.1
Comparing to
See all releases


Version 0.0.1

Files changed (35) hide show
  1. app/code/community/Auguria/Core/Helper/Data.php +9 -0
  2. app/code/community/Auguria/Core/Model/Attribute/Backend/Image/Abstract.php +59 -0
  3. app/code/community/Auguria/Core/Model/Customer/Attribute/Source/Group.php +22 -0
  4. app/code/community/Auguria/Core/Model/System/Config/Source/Config.php +35 -0
  5. app/code/community/Auguria/Core/Model/System/Config/Source/Customer/Group/Multiselect.php +34 -0
  6. app/code/community/Auguria/Core/etc/config.xml +50 -0
  7. app/code/community/Auguria/Core/etc/system.xml +17 -0
  8. app/code/community/Auguria/ProductMatrix/Block/Adminhtml/Catalog/Product/Helper/Form/Config.php +21 -0
  9. app/code/community/Auguria/ProductMatrix/Block/Adminhtml/Catalog/Product/Helper/Form/Config/Customer/Group.php +46 -0
  10. app/code/community/Auguria/ProductMatrix/Block/Catalog/Product/Matrix.php +141 -0
  11. app/code/community/Auguria/ProductMatrix/Helper/Config.php +49 -0
  12. app/code/community/Auguria/ProductMatrix/Helper/Data.php +9 -0
  13. app/code/community/Auguria/ProductMatrix/Model/Entity/Attribute/Backend/Customer/Group.php +31 -0
  14. app/code/community/Auguria/ProductMatrix/Model/System/Config/Source/Matrix/Template.php +12 -0
  15. app/code/community/Auguria/ProductMatrix/controllers/Checkout/CartController.php +167 -0
  16. app/code/community/Auguria/ProductMatrix/etc/adminhtml.xml +30 -0
  17. app/code/community/Auguria/ProductMatrix/etc/config.xml +138 -0
  18. app/code/community/Auguria/ProductMatrix/etc/system.xml +61 -0
  19. app/code/community/Auguria/ProductMatrix/sql/auguria_productmatrix_setup/install-0.0.1.php +64 -0
  20. app/design/adminhtml/default/default/layout/auguria/core.xml +19 -0
  21. app/design/adminhtml/default/default/layout/auguria/product_matrix.xml +20 -0
  22. app/design/frontend/base/default/layout/auguria/product_matrix.xml +24 -0
  23. app/design/frontend/base/default/template/auguria/productmatrix/catalog/product/matrix/condensed.phtml +310 -0
  24. app/design/frontend/base/default/template/auguria/productmatrix/catalog/product/matrix/inline.phtml +145 -0
  25. app/etc/modules/Auguria_Core.xml +17 -0
  26. app/etc/modules/Auguria_ProductMatrix.xml +20 -0
  27. app/locale/en_US/Auguria_Core.csv +0 -0
  28. app/locale/en_US/Auguria_ProductMatrix.csv +17 -0
  29. app/locale/fr_FR/Auguria_Core.csv +0 -0
  30. app/locale/fr_FR/Auguria_ProductMatrix.csv +20 -0
  31. js/auguria/productmatrix/matrix.js +143 -0
  32. package.xml +32 -0
  33. skin/adminhtml/default/default/auguria/core.css +17 -0
  34. skin/adminhtml/default/default/auguria/images/section-header.png +0 -0
  35. skin/adminhtml/default/default/auguria/images/tab-header.png +0 -0
app/code/community/Auguria/Core/Helper/Data.php ADDED
@@ -0,0 +1,9 @@
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * @category Auguria
4
+ * @package Auguria_Core
5
+ * @author Auguria
6
+ * @license http://opensource.org/licenses/gpl-3.0.html GNU General Public License version 3 (GPLv3)
7
+ */
8
+
9
+ class Auguria_Core_Helper_Data extends Mage_Core_Helper_Abstract {}
app/code/community/Auguria/Core/Model/Attribute/Backend/Image/Abstract.php ADDED
@@ -0,0 +1,59 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * @category Auguria
4
+ * @package Auguria_Core
5
+ * @author Auguria
6
+ * @license http://opensource.org/licenses/gpl-3.0.html GNU General Public License version 3 (GPLv3)
7
+ */
8
+
9
+ abstract class Auguria_Core_Model_Attribute_Backend_Image_Abstract extends Mage_Eav_Model_Entity_Attribute_Backend_Abstract
10
+ {
11
+ /**
12
+ * Save uploaded file
13
+ *
14
+ * @param Varien_Object $object
15
+ */
16
+ public function afterSave($object)
17
+ {
18
+ $value = $object->getData($this->getAttribute()->getName());
19
+
20
+ if (is_array($value) && !empty($value['delete'])) {
21
+ $object->setData($this->getAttribute()->getName(), '');
22
+ $this->getAttribute()->getEntity()
23
+ ->saveAttribute($object, $this->getAttribute()->getName());
24
+ return;
25
+ }
26
+
27
+ try {
28
+ $uploader = new Mage_Core_Model_File_Uploader($this->getAttribute()->getName());
29
+ $uploader->setAllowedExtensions(array('jpg','jpeg','gif','png'));
30
+ $uploader->setAllowRenameFiles(true);
31
+ $result = $uploader->save($this->_getPath());
32
+
33
+ $object->setData($this->getAttribute()->getName(), $this->_getPrefix() . $result['file']);
34
+ $this->getAttribute()->getEntity()->saveAttribute($object, $this->getAttribute()->getName());
35
+ } catch (Exception $e) {
36
+ if ($e->getCode() != Mage_Core_Model_File_Uploader::TMP_NAME_EMPTY) {
37
+ Mage::logException($e);
38
+ }
39
+ return;
40
+ }
41
+ }
42
+
43
+ /**
44
+ * Get path to save file
45
+ *
46
+ * @return string
47
+ */
48
+ abstract protected function _getPath();
49
+
50
+ /**
51
+ * Get prefix when save path file in attribute value
52
+ *
53
+ * @return string
54
+ */
55
+ protected function _getPrefix()
56
+ {
57
+ return;
58
+ }
59
+ }
app/code/community/Auguria/Core/Model/Customer/Attribute/Source/Group.php ADDED
@@ -0,0 +1,22 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * @category Auguria
4
+ * @package Auguria_Core
5
+ * @author Auguria
6
+ * @license http://opensource.org/licenses/gpl-3.0.html GNU General Public License version 3 (GPLv3)
7
+ */
8
+
9
+ class Auguria_Core_Model_Customer_Attribute_Source_Group extends Mage_Eav_Model_Entity_Attribute_Source_Table
10
+ {
11
+ public function getAllOptions()
12
+ {
13
+ if (!$this->_options) {
14
+ $this->_options = Mage::getResourceModel('customer/group_collection')
15
+ //->setRealGroupsFilter() GET NOT LOGGED IN GROUP
16
+ ->load()
17
+ ->toOptionArray()
18
+ ;
19
+ }
20
+ return $this->_options;
21
+ }
22
+ }
app/code/community/Auguria/Core/Model/System/Config/Source/Config.php ADDED
@@ -0,0 +1,35 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * @category Auguria
4
+ * @package Auguria_Core
5
+ * @author Auguria
6
+ * @license http://opensource.org/licenses/gpl-3.0.html GNU General Public License version 3 (GPLv3)
7
+ */
8
+
9
+ abstract class Auguria_Core_Model_System_Config_Source_Config
10
+ {
11
+
12
+ const CONFIG_OPTIONS_PATH = '';
13
+
14
+ /**
15
+ * Options getter
16
+ *
17
+ * @return array
18
+ */
19
+ public function toOptionArray()
20
+ {
21
+ $nodes = Mage::getConfig()->getNode(static::CONFIG_OPTIONS_PATH);
22
+ $translator = (string)$nodes->getAttribute('translator'); // used to translate label
23
+
24
+ $options = array();
25
+
26
+ foreach($nodes as $_node){
27
+ foreach ($_node as $_option){
28
+ $options[] = array('value' => (string)$_option->value, 'label' => Mage::helper($translator)->__((string)$_option->label));
29
+ }
30
+ }
31
+
32
+ return $options;
33
+ }
34
+
35
+ }
app/code/community/Auguria/Core/Model/System/Config/Source/Customer/Group/Multiselect.php ADDED
@@ -0,0 +1,34 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * @category Auguria
4
+ * @package Auguria_Core
5
+ * @author Auguria
6
+ * @license http://opensource.org/licenses/gpl-3.0.html GNU General Public License version 3 (GPLv3)
7
+ */
8
+
9
+ class Auguria_Core_Model_System_Config_Source_Customer_Group_Multiselect
10
+ {
11
+
12
+ /**
13
+ * Customer groups options array
14
+ *
15
+ * @var null|array
16
+ */
17
+ protected $_options;
18
+
19
+ /**
20
+ * Retrieve customer groups as array
21
+ *
22
+ * @return array
23
+ */
24
+ public function toOptionArray()
25
+ {
26
+ if (!$this->_options) {
27
+ $this->_options = Mage::getResourceModel('customer/group_collection')
28
+ //->setRealGroupsFilter() Get the NOT LOGGED IN GROUP TOO
29
+ ->loadData()->toOptionArray();
30
+ }
31
+ return $this->_options;
32
+ }
33
+
34
+ }
app/code/community/Auguria/Core/etc/config.xml ADDED
@@ -0,0 +1,50 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?xml version="1.0" encoding="UTF-8"?>
2
+ <!--
3
+ /**
4
+ * @category Auguria
5
+ * @package Auguria_Core
6
+ * @author Auguria
7
+ * @license http://opensource.org/licenses/gpl-3.0.html GNU General Public License version 3 (GPLv3)
8
+ */
9
+ -->
10
+ <config>
11
+
12
+ <modules>
13
+ <Auguria_Core>
14
+ <version/>
15
+ </Auguria_Core>
16
+ </modules>
17
+
18
+ <global>
19
+ <helpers>
20
+ <auguria_core>
21
+ <class>Auguria_Core_Helper</class>
22
+ </auguria_core>
23
+ </helpers>
24
+ <models>
25
+ <auguria_core>
26
+ <class>Auguria_Core_Model</class>
27
+ </auguria_core>
28
+ </models>
29
+ </global>
30
+
31
+ <adminhtml>
32
+ <layout>
33
+ <updates>
34
+ <auguria_core>
35
+ <file>auguria/core.xml</file>
36
+ </auguria_core>
37
+ </updates>
38
+ </layout>
39
+ <translate>
40
+ <modules>
41
+ <Auguria_Core>
42
+ <files>
43
+ <default>Auguria_Core.csv</default>
44
+ </files>
45
+ </Auguria_Core>
46
+ </modules>
47
+ </translate>
48
+ </adminhtml>
49
+
50
+ </config>
app/code/community/Auguria/Core/etc/system.xml ADDED
@@ -0,0 +1,17 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <!--
2
+ /**
3
+ * @category Auguria
4
+ * @package Auguria_Core
5
+ * @author Auguria
6
+ * @license http://opensource.org/licenses/gpl-3.0.html GNU General Public License version 3 (GPLv3)
7
+ */
8
+ -->
9
+ <config>
10
+ <tabs>
11
+ <auguria>
12
+ <label></label>
13
+ <sort_order>150</sort_order>
14
+ <class>auguria-tab</class>
15
+ </auguria>
16
+ </tabs>
17
+ </config>
app/code/community/Auguria/ProductMatrix/Block/Adminhtml/Catalog/Product/Helper/Form/Config.php ADDED
@@ -0,0 +1,21 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * @category Auguria
4
+ * @package Auguria_ProductMatrix
5
+ * @author Auguria
6
+ * @license http://opensource.org/licenses/gpl-3.0.html GNU General Public License version 3 (GPLv3)
7
+ */
8
+
9
+ class Auguria_ProductMatrix_Block_Adminhtml_Catalog_Product_Helper_Form_Config
10
+ extends Mage_Adminhtml_Block_Catalog_Product_Helper_Form_Config
11
+ {
12
+ /**
13
+ * Get config value data
14
+ *
15
+ * @return mixed
16
+ */
17
+ protected function _getValueFromConfig()
18
+ {
19
+ return Mage::helper('auguria_productmatrix/config')->isProductMatrixActive();
20
+ }
21
+ }
app/code/community/Auguria/ProductMatrix/Block/Adminhtml/Catalog/Product/Helper/Form/Config/Customer/Group.php ADDED
@@ -0,0 +1,46 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * @category Auguria
4
+ * @package Auguria_ProductMatrix
5
+ * @author Auguria
6
+ * @license http://opensource.org/licenses/gpl-3.0.html GNU General Public License version 3 (GPLv3)
7
+ */
8
+
9
+ class Auguria_ProductMatrix_Block_Adminhtml_Catalog_Product_Helper_Form_Config_Customer_Group
10
+ extends Varien_Data_Form_Element_Multiselect
11
+ {
12
+ /**
13
+ * Get config value data
14
+ *
15
+ * @return mixed
16
+ */
17
+ protected function _getValueFromConfig()
18
+ {
19
+ return Mage::helper('auguria_productmatrix/config')->getCustomerGroups();
20
+ }
21
+
22
+ /**
23
+ * Retrieve element html
24
+ *
25
+ * @return string
26
+ */
27
+ public function getElementHtml()
28
+ {
29
+ $values = $this->getValues();
30
+ if ($values == '') {
31
+ $this->setValues($this->_getValueFromConfig());
32
+ }
33
+ $html = parent::getElementHtml();
34
+
35
+ $htmlId = 'use_config_' . $this->getHtmlId();
36
+ $checked = ($values == '') ? ' checked="checked"' : '';
37
+ $disabled = ($this->getReadonly()) ? ' disabled="disabled"' : '';
38
+
39
+ $html .= '<input id="'.$htmlId.'" name="product['.$htmlId.']" '.$disabled.' value="1" ' . $checked;
40
+ $html .= ' onclick="toggleValueElements(this, this.parentNode);" class="checkbox" type="checkbox" />';
41
+ $html .= ' <label for="'.$htmlId.'">' . Mage::helper('adminhtml')->__('Use Config Settings').'</label>';
42
+ $html .= '<script type="text/javascript">toggleValueElements($(\''.$htmlId.'\'), $(\''.$htmlId.'\').parentNode);</script>';
43
+
44
+ return $html;
45
+ }
46
+ }
app/code/community/Auguria/ProductMatrix/Block/Catalog/Product/Matrix.php ADDED
@@ -0,0 +1,141 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * @category Auguria
4
+ * @package Auguria_ProductMatrix
5
+ * @author Auguria
6
+ * @license http://opensource.org/licenses/gpl-3.0.html GNU General Public License version 3 (GPLv3)
7
+ */
8
+
9
+ class Auguria_ProductMatrix_Block_Catalog_Product_Matrix extends Mage_Core_Block_Template {
10
+
11
+ protected $_childrenProducts;
12
+ protected $_matrixInformations;
13
+ protected $_productsByOption = array();
14
+
15
+ /**
16
+ * Render block HTML
17
+ *
18
+ * @return string
19
+ */
20
+ protected function _toHtml()
21
+ {
22
+ // check configuration and product custom options
23
+ if (!$this->getTemplate() || !$this->canDisplayMatrix()) {
24
+ return '';
25
+ }
26
+ $html = $this->renderView();
27
+ return $html;
28
+ }
29
+
30
+ /**
31
+ * Retrieve current product model
32
+ *
33
+ * @return Mage_Catalog_Model_Product
34
+ */
35
+ public function getProduct()
36
+ {
37
+ return Mage::registry('product');
38
+ }
39
+
40
+ /**
41
+ * Check if the matrix can be displayed
42
+ *
43
+ * @return bool
44
+ */
45
+ public function canDisplayMatrix(){
46
+ $active = $this->getProduct()->getAuguriaMatrixActive() || is_null($this->getProduct()->getAuguriaMatrixActive()) && Mage::helper('auguria_productmatrix/config')->isProductMatrixActive() ? true : false;
47
+ $groups = !is_null($this->getProduct()->getAuguriaMatrixCustomerGroups()) ? explode(',', $this->getProduct()->getAuguriaMatrixCustomerGroups()) : Mage::helper('auguria_productmatrix/config')->getCustomerGroups(true);
48
+
49
+ return
50
+ $active
51
+ && !$this->getProduct()->getProductOptionsCollection()->getSize() // custom options are not managed in matrix
52
+ && in_array(Mage::getSingleton('customer/session')->getCustomerGroupId(), $groups); // filter by customer group
53
+ }
54
+
55
+ /**
56
+ * Get form url with parameters
57
+ *
58
+ * @return string
59
+ */
60
+ public function getAddUrl(){
61
+ $addUrlKey = Mage_Core_Controller_Front_Action::PARAM_NAME_URL_ENCODED;
62
+ $addUrlValue = Mage::getUrl('*/*/*', array('_use_rewrite' => true, '_current' => true));
63
+ $additional[$addUrlKey] = Mage::helper('core')->urlEncode($addUrlValue);
64
+ $additional['product'] = $this->getProduct()->getId();
65
+
66
+ return Mage::getUrl('auguria_productmatrix/checkout_cart/add', $additional);
67
+ }
68
+
69
+ /**
70
+ * Get configurable attributes informations
71
+ *
72
+ * @return array
73
+ */
74
+ public function getMatrixInformations()
75
+ {
76
+ if(is_null($this->_matrixInformations)){
77
+ $this->_matrixInformations = array();
78
+ foreach($this->getProduct()->getTypeInstance()->getConfigurableAttributesAsArray($this->getProduct()) as $_attribute){
79
+ $positions = array();
80
+ foreach($_attribute['values'] as $_key => $_value){
81
+ $positions[$_value['value_index']] = $_key;
82
+ }
83
+
84
+ // add position information (js object constraint) for each attribute option
85
+ $_attribute['matrix_option_id_to_position'] = $positions;
86
+ // assign information
87
+ $this->_matrixInformations[] = $_attribute;
88
+ }
89
+ }
90
+
91
+ return $this->_matrixInformations;
92
+ }
93
+
94
+ /**
95
+ * Get children of the configurable product
96
+ *
97
+ * @return array
98
+ */
99
+ public function getChildrenProducts()
100
+ {
101
+ // prepare children for js object
102
+ if(is_null($this->_childrenProducts)){
103
+ $this->_childrenProducts = array();
104
+ foreach ($this->getProduct()->getTypeInstance()->getUsedProducts($this->getProduct()) as $_product){
105
+ $this->_childrenProducts[$_product->getId()] = $_product->getData();
106
+
107
+ $this->_prepareProductsByOption($_product);
108
+ }
109
+ }
110
+
111
+ return $this->_childrenProducts;
112
+ }
113
+
114
+ /**
115
+ * Prepare products by option sorted by order
116
+ *
117
+ * @param Mage_Catalog_Model_Product $product
118
+ * @return void
119
+ */
120
+ protected function _prepareProductsByOption(Mage_Catalog_Model_Product $product)
121
+ {
122
+ $attributes = $this->getMatrixInformations();
123
+ $lastAttribute = end($attributes);
124
+ foreach (array_flip($lastAttribute['matrix_option_id_to_position']) as $_optionId){
125
+ if($product->getData($lastAttribute['attribute_code']) == $_optionId){
126
+ $this->_productsByOption[$_optionId][] = $product->getId();
127
+ }
128
+ }
129
+ }
130
+
131
+ /**
132
+ * Get products id by last attribute options
133
+ *
134
+ * @return array
135
+ */
136
+ public function getProductsByOption()
137
+ {
138
+ return $this->_productsByOption;
139
+ }
140
+
141
+ }
app/code/community/Auguria/ProductMatrix/Helper/Config.php ADDED
@@ -0,0 +1,49 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * @category Auguria
4
+ * @package Auguria_ProductMatrix
5
+ * @author Auguria
6
+ * @license http://opensource.org/licenses/gpl-3.0.html GNU General Public License version 3 (GPLv3)
7
+ */
8
+
9
+ class Auguria_ProductMatrix_Helper_Config extends Mage_Core_Helper_Abstract {
10
+
11
+ /* PATH TO CONFIGURATION */
12
+ const XML_PATH_PRODUCT_MATRIX_IS_ACTIVE = 'auguria_productmatrix/general/is_active';
13
+ const XML_PATH_PRODUCT_MATRIX_GROUPS = 'auguria_productmatrix/general/groups';
14
+ const XML_PATH_PRODUCT_MATRIX_TEMPLATE = 'auguria_productmatrix/general/template';
15
+
16
+ /**
17
+ * Check if the display of the matrix is active
18
+ *
19
+ * @return bool
20
+ */
21
+ public function isProductMatrixActive(){
22
+ return Mage::getStoreConfigFlag(self::XML_PATH_PRODUCT_MATRIX_IS_ACTIVE);
23
+ }
24
+
25
+ /**
26
+ * Get customer groups authorized by config
27
+ *
28
+ * @param bool $asArray
29
+ * @return string
30
+ */
31
+ public function getCustomerGroups($asArray = false){
32
+ $groupIds = Mage::getStoreConfig(self::XML_PATH_PRODUCT_MATRIX_GROUPS);
33
+
34
+ if($asArray){
35
+ return explode(',', $groupIds); // array
36
+ }
37
+
38
+ return $groupIds; // string with ids comma separated
39
+ }
40
+
41
+ /**
42
+ * Get selected template in config
43
+ *
44
+ * @return string
45
+ */
46
+ public function getMatrixTemplate(){
47
+ return Mage::getStoreConfig(self::XML_PATH_PRODUCT_MATRIX_TEMPLATE);
48
+ }
49
+ }
app/code/community/Auguria/ProductMatrix/Helper/Data.php ADDED
@@ -0,0 +1,9 @@
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * @category Auguria
4
+ * @package Auguria_ProductMatrix
5
+ * @author Auguria
6
+ * @license http://opensource.org/licenses/gpl-3.0.html GNU General Public License version 3 (GPLv3)
7
+ */
8
+
9
+ class Auguria_ProductMatrix_Helper_Data extends Mage_Core_Helper_Abstract {}
app/code/community/Auguria/ProductMatrix/Model/Entity/Attribute/Backend/Customer/Group.php ADDED
@@ -0,0 +1,31 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * @category Auguria
4
+ * @package Auguria_ProductMatrix
5
+ * @author Auguria
6
+ * @license http://opensource.org/licenses/gpl-3.0.html GNU General Public License version 3 (GPLv3)
7
+ */
8
+
9
+ class Auguria_ProductMatrix_Model_Entity_Attribute_Backend_Customer_Group extends Mage_Eav_Model_Entity_Attribute_Backend_Abstract
10
+ {
11
+ /**
12
+ * Prepare data for save
13
+ *
14
+ * @param Varien_Object $object
15
+ * @return Mage_Eav_Model_Entity_Attribute_Backend_Abstract
16
+ */
17
+ public function beforeSave($object)
18
+ {
19
+ $attributeCode = $this->getAttribute()->getAttributeCode();
20
+ $data = $object->getData($attributeCode);
21
+
22
+ if ($object->getData('use_config_' . $attributeCode)) {
23
+ $object->setData($attributeCode, '');
24
+ }elseif (is_array($data)) {
25
+ // $data = array_filter($data); otherwise delete NOT LOGGED IN customer group (value 0)
26
+ $object->setData($attributeCode, implode(',', $data));
27
+ }
28
+
29
+ return parent::beforeSave($object);
30
+ }
31
+ }
app/code/community/Auguria/ProductMatrix/Model/System/Config/Source/Matrix/Template.php ADDED
@@ -0,0 +1,12 @@
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * @category Auguria
4
+ * @package Auguria_ProductMatrix
5
+ * @author Auguria
6
+ * @license http://opensource.org/licenses/gpl-3.0.html GNU General Public License version 3 (GPLv3)
7
+ */
8
+
9
+ class Auguria_ProductMatrix_Model_System_Config_Source_Matrix_Template extends Auguria_Core_Model_System_Config_Source_Config
10
+ {
11
+ const CONFIG_OPTIONS_PATH = 'auguria/productmatrix/matrix/templates';
12
+ }
app/code/community/Auguria/ProductMatrix/controllers/Checkout/CartController.php ADDED
@@ -0,0 +1,167 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * @category Auguria
4
+ * @package Auguria_ProductMatrix
5
+ * @author Auguria
6
+ * @license http://opensource.org/licenses/gpl-3.0.html GNU General Public License version 3 (GPLv3)
7
+ */
8
+
9
+ class Auguria_ProductMatrix_Checkout_CartController extends Mage_Core_Controller_Front_Action
10
+ {
11
+ /**
12
+ * Retrieve shopping cart model object
13
+ *
14
+ * @return Mage_Checkout_Model_Cart
15
+ */
16
+ protected function _getCart()
17
+ {
18
+ return Mage::getSingleton('checkout/cart');
19
+ }
20
+
21
+ /**
22
+ * Get checkout session model instance
23
+ *
24
+ * @return Mage_Checkout_Model_Session
25
+ */
26
+ protected function _getSession()
27
+ {
28
+ return Mage::getSingleton('checkout/session');
29
+ }
30
+
31
+ /**
32
+ * Set back redirect url to response
33
+ *
34
+ * @return Mage_Checkout_CartController
35
+ */
36
+ protected function _goBack()
37
+ {
38
+ $returnUrl = $this->getRequest()->getParam('return_url');
39
+ if ($returnUrl) {
40
+
41
+ if (!$this->_isUrlInternal($returnUrl)) {
42
+ throw new Mage_Exception('External urls redirect to "' . $returnUrl . '" denied!');
43
+ }
44
+
45
+ $this->_getSession()->getMessages(true);
46
+ $this->getResponse()->setRedirect($returnUrl);
47
+ } elseif (!Mage::getStoreConfig('checkout/cart/redirect_to_cart')
48
+ && !$this->getRequest()->getParam('in_cart')
49
+ && $backUrl = $this->_getRefererUrl()
50
+ ) {
51
+ $this->getResponse()->setRedirect($backUrl);
52
+ } else {
53
+ if (($this->getRequest()->getActionName() == 'add') && !$this->getRequest()->getParam('in_cart')) {
54
+ $this->_getSession()->setContinueShoppingUrl($this->_getRefererUrl());
55
+ }
56
+ $this->_redirect('checkout/cart');
57
+ }
58
+ return $this;
59
+ }
60
+
61
+ /**
62
+ * Initialize product instance from request data
63
+ *
64
+ * @return Mage_Catalog_Model_Product || false
65
+ */
66
+ protected function _initProduct()
67
+ {
68
+ $productId = (int) $this->getRequest()->getParam('product');
69
+ if ($productId) {
70
+ $product = Mage::getModel('catalog/product')
71
+ ->setStoreId(Mage::app()->getStore()->getId())
72
+ ->load($productId);
73
+ if ($product->getId()) {
74
+ return $product;
75
+ }
76
+ }
77
+ return false;
78
+ }
79
+
80
+ /**
81
+ * Add product to shopping cart action
82
+ */
83
+ public function addAction()
84
+ {
85
+ $cart = $this->_getCart();
86
+ $params = $this->getRequest()->getParams();
87
+
88
+ try {
89
+ $product = $this->_initProduct();
90
+
91
+
92
+ foreach($params['matrix_products'] as $_child){
93
+
94
+ // get required params to add in cart
95
+ $_child['uenc'] = $params['uenc'];
96
+ $_child['product'] = $params['product'];
97
+
98
+ if (isset($_child['qty'])) {
99
+ $filter = new Zend_Filter_LocalizedToNormalized(
100
+ array('locale' => Mage::app()->getLocale()->getLocaleCode())
101
+ );
102
+ $_child['qty'] = $filter->filter($_child['qty']);
103
+ }
104
+
105
+ if(!array_key_exists('qty', $_child) || $_child['qty'] == 0){
106
+ continue; // check qty
107
+ }
108
+
109
+ $product = $this->_initProduct();
110
+
111
+ /**
112
+ * Check product availability
113
+ */
114
+ if (!$product) {
115
+ $this->_goBack();
116
+ return;
117
+ }
118
+
119
+ $related = $this->getRequest()->getParam('related_product');
120
+
121
+ $cart->addProduct($product, $_child);
122
+ if (!empty($related)) {
123
+ $cart->addProductsByIds(explode(',', $related));
124
+ }
125
+ }
126
+
127
+ $cart->save();
128
+
129
+ $this->_getSession()->setCartWasUpdated(true);
130
+
131
+ /**
132
+ * @todo remove wishlist observer processAddToCart
133
+ */
134
+ Mage::dispatchEvent('checkout_cart_add_product_complete',
135
+ array('product' => $product, 'request' => $this->getRequest(), 'response' => $this->getResponse())
136
+ );
137
+
138
+ if (!$this->_getSession()->getNoCartRedirect(true)) {
139
+ if (!$cart->getQuote()->getHasError()){
140
+ $message = $this->__('%s was added to your shopping cart.', Mage::helper('core')->escapeHtml($product->getName()));
141
+ $this->_getSession()->addSuccess($message);
142
+ }
143
+ $this->_goBack();
144
+ }
145
+ } catch (Mage_Core_Exception $e) {
146
+ if ($this->_getSession()->getUseNotice(true)) {
147
+ $this->_getSession()->addNotice(Mage::helper('core')->escapeHtml($e->getMessage()));
148
+ } else {
149
+ $messages = array_unique(explode("\n", $e->getMessage()));
150
+ foreach ($messages as $message) {
151
+ $this->_getSession()->addError(Mage::helper('core')->escapeHtml($message));
152
+ }
153
+ }
154
+
155
+ $url = $this->_getSession()->getRedirectUrl(true);
156
+ if ($url) {
157
+ $this->getResponse()->setRedirect($url);
158
+ } else {
159
+ $this->_redirectReferer(Mage::helper('checkout/cart')->getCartUrl());
160
+ }
161
+ } catch (Exception $e) {
162
+ $this->_getSession()->addException($e, $this->__('Cannot add the item to shopping cart.'));
163
+ Mage::logException($e);
164
+ $this->_goBack();
165
+ }
166
+ }
167
+ }
app/code/community/Auguria/ProductMatrix/etc/adminhtml.xml ADDED
@@ -0,0 +1,30 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?xml version="1.0"?>
2
+ <!--
3
+ /**
4
+ * @category Auguria
5
+ * @package Auguria_ProductMatrix
6
+ * @author Auguria
7
+ * @license http://opensource.org/licenses/gpl-3.0.html GNU General Public License version 3 (GPLv3)
8
+ */
9
+ -->
10
+ <config>
11
+ <acl>
12
+ <resources>
13
+ <admin>
14
+ <children>
15
+ <system>
16
+ <children>
17
+ <config>
18
+ <children>
19
+ <auguria_productmatrix translate="title" module="auguria_productmatrix">
20
+ <title>Auguria product matrix</title>
21
+ </auguria_productmatrix>
22
+ </children>
23
+ </config>
24
+ </children>
25
+ </system>
26
+ </children>
27
+ </admin>
28
+ </resources>
29
+ </acl>
30
+ </config>
app/code/community/Auguria/ProductMatrix/etc/config.xml ADDED
@@ -0,0 +1,138 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?xml version="1.0" encoding="UTF-8"?>
2
+ <!--
3
+ /**
4
+ * @category Auguria
5
+ * @package Auguria_ProductMatrix
6
+ * @author Auguria
7
+ * @license http://opensource.org/licenses/gpl-3.0.html GNU General Public License version 3 (GPLv3)
8
+ */
9
+ -->
10
+ <config>
11
+
12
+ <modules>
13
+ <Auguria_ProductMatrix>
14
+ <version>0.0.1</version>
15
+ </Auguria_ProductMatrix>
16
+ </modules>
17
+
18
+ <global>
19
+ <resources>
20
+ <auguria_productmatrix_setup>
21
+ <setup>
22
+ <module>Auguria_ProductMatrix</module>
23
+ <class>Mage_Catalog_Model_Resource_Setup</class>
24
+ </setup>
25
+ </auguria_productmatrix_setup>
26
+ </resources>
27
+ <blocks>
28
+ <auguria_productmatrix>
29
+ <class>Auguria_ProductMatrix_Block</class>
30
+ </auguria_productmatrix>
31
+ </blocks>
32
+ <helpers>
33
+ <auguria_productmatrix>
34
+ <class>Auguria_ProductMatrix_Helper</class>
35
+ </auguria_productmatrix>
36
+ </helpers>
37
+ <models>
38
+ <auguria_productmatrix>
39
+ <class>Auguria_ProductMatrix_Model</class>
40
+ </auguria_productmatrix>
41
+ </models>
42
+ </global>
43
+
44
+ <frontend>
45
+ <routers>
46
+ <auguria_productmatrix>
47
+ <use>standard</use>
48
+ <args>
49
+ <module>Auguria_ProductMatrix</module>
50
+ <frontName>matrix</frontName>
51
+ </args>
52
+ </auguria_productmatrix>
53
+ </routers>
54
+ <layout>
55
+ <updates>
56
+ <auguria_productmatrix>
57
+ <file>auguria/product_matrix.xml</file>
58
+ </auguria_productmatrix>
59
+ </updates>
60
+ </layout>
61
+ <translate>
62
+ <modules>
63
+ <Auguria_ProductMatrix>
64
+ <files>
65
+ <default>Auguria_ProductMatrix.csv</default>
66
+ </files>
67
+ </Auguria_ProductMatrix>
68
+ </modules>
69
+ </translate>
70
+ </frontend>
71
+
72
+ <admin>
73
+ <routers>
74
+ <adminhtml>
75
+ <args>
76
+ <modules>
77
+ <auguria_productmatrix before="Mage_Adminhtml">Auguria_ProductMatrix_Adminhtml</auguria_productmatrix>
78
+ </modules>
79
+ </args>
80
+ </adminhtml>
81
+ </routers>
82
+ <fieldsets>
83
+ <catalog_product_dataflow>
84
+ <auguria_active_matrix>
85
+ <use_config>1</use_config>
86
+ </auguria_active_matrix>
87
+ </catalog_product_dataflow>
88
+ </fieldsets>
89
+ </admin>
90
+
91
+ <adminhtml>
92
+ <layout>
93
+ <updates>
94
+ <auguria_productmatrix>
95
+ <file>auguria/product_matrix.xml</file>
96
+ </auguria_productmatrix>
97
+ </updates>
98
+ </layout>
99
+ <translate>
100
+ <modules>
101
+ <Auguria_ProductMatrix>
102
+ <files>
103
+ <default>Auguria_ProductMatrix.csv</default>
104
+ </files>
105
+ </Auguria_ProductMatrix>
106
+ </modules>
107
+ </translate>
108
+ </adminhtml>
109
+
110
+ <default>
111
+ <auguria_productmatrix>
112
+ <general>
113
+ <is_active>0</is_active>
114
+ <template>auguria/productmatrix/catalog/product/matrix/inline.phtml</template>
115
+ </general>
116
+ </auguria_productmatrix>
117
+ </default>
118
+
119
+ <!-- AUGURIA configuration -->
120
+
121
+ <auguria>
122
+ <productmatrix>
123
+ <matrix>
124
+ <templates translator="auguria_productmatrix">
125
+ <inline>
126
+ <label>Inline template</label>
127
+ <value>auguria/productmatrix/catalog/product/matrix/inline.phtml</value>
128
+ </inline>
129
+ <condensed>
130
+ <label>Condensed template</label>
131
+ <value>auguria/productmatrix/catalog/product/matrix/condensed.phtml</value>
132
+ </condensed>
133
+ </templates>
134
+ </matrix>
135
+ </productmatrix>
136
+ </auguria>
137
+
138
+ </config>
app/code/community/Auguria/ProductMatrix/etc/system.xml ADDED
@@ -0,0 +1,61 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <!--
2
+ /**
3
+ * @category Auguria
4
+ * @package Auguria_ProductMatrix
5
+ * @author Auguria
6
+ * @license http://opensource.org/licenses/gpl-3.0.html GNU General Public License version 3 (GPLv3)
7
+ */
8
+ -->
9
+ <config>
10
+ <sections>
11
+ <auguria_productmatrix translate="label" module="auguria_productmatrix">
12
+ <label>Product matrix</label>
13
+ <tab>auguria</tab>
14
+ <header_css>auguria-header</header_css>
15
+ <frontend_type>text</frontend_type>
16
+ <sort_order>200</sort_order>
17
+ <show_in_default>1</show_in_default>
18
+ <show_in_website>1</show_in_website>
19
+ <show_in_store>0</show_in_store>
20
+ <groups>
21
+ <general translate="label">
22
+ <label>General</label>
23
+ <frontend_type>text</frontend_type>
24
+ <sort_order>1</sort_order>
25
+ <show_in_default>1</show_in_default>
26
+ <show_in_website>1</show_in_website>
27
+ <show_in_store>0</show_in_store>
28
+ <fields>
29
+ <is_active translate="label">
30
+ <label>Display matrix on the configurable product page view</label>
31
+ <frontend_type>select</frontend_type>
32
+ <source_model>adminhtml/system_config_source_yesno</source_model>
33
+ <sort_order>1</sort_order>
34
+ <show_in_default>1</show_in_default>
35
+ <show_in_website>1</show_in_website>
36
+ <show_in_store>0</show_in_store>
37
+ </is_active>
38
+ <groups translate="label">
39
+ <label>Display for these groups only</label>
40
+ <frontend_type>multiselect</frontend_type>
41
+ <source_model>auguria_core/system_config_source_customer_group_multiselect</source_model>
42
+ <sort_order>2</sort_order>
43
+ <show_in_default>1</show_in_default>
44
+ <show_in_website>1</show_in_website>
45
+ <show_in_store>0</show_in_store>
46
+ </groups>
47
+ <template translate="label">
48
+ <label>Template to use</label>
49
+ <frontend_type>select</frontend_type>
50
+ <source_model>auguria_productmatrix/system_config_source_matrix_template</source_model>
51
+ <sort_order>3</sort_order>
52
+ <show_in_default>1</show_in_default>
53
+ <show_in_website>1</show_in_website>
54
+ <show_in_store>0</show_in_store>
55
+ </template>
56
+ </fields>
57
+ </general>
58
+ </groups>
59
+ </auguria_productmatrix>
60
+ </sections>
61
+ </config>
app/code/community/Auguria/ProductMatrix/sql/auguria_productmatrix_setup/install-0.0.1.php ADDED
@@ -0,0 +1,64 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * @category Auguria
4
+ * @package Auguria_ProductMatrix
5
+ * @author Auguria
6
+ * @license http://opensource.org/licenses/gpl-3.0.html GNU General Public License version 3 (GPLv3)
7
+ */
8
+
9
+ /* @var $this Mage_Catalog_Model_Resource_Setup */
10
+
11
+ // Create new attribute group ( render attribute element correctly )
12
+ $entityTypeId = $this->getEntityTypeId('catalog_product');
13
+
14
+ // add group for each existing attribute set
15
+ $attributeSets = $this->_conn->fetchAll('select * from '.$this->getTable('eav/attribute_set').' where entity_type_id=?', $entityTypeId);
16
+ foreach ($attributeSets as $attributeSet) {
17
+ $setId = $attributeSet['attribute_set_id'];
18
+ $this->addAttributeGroup($entityTypeId, $setId, 'Product matrix');
19
+ }
20
+
21
+ // only for configurable products
22
+ $productTypes = array(
23
+ Mage_Catalog_Model_Product_Type::TYPE_CONFIGURABLE
24
+ );
25
+ $productTypes = join(',', $productTypes);
26
+
27
+ // auguria_matrix_active : define if the matrix can be displayed on the product view page
28
+ $this->addAttribute(Mage_Catalog_Model_Product::ENTITY, 'auguria_matrix_active', array(
29
+ 'group' => 'Product matrix',
30
+ 'backend' => 'catalog/product_attribute_backend_boolean',
31
+ 'frontend' => '',
32
+ 'label' => 'Active matrix on the product view page',
33
+ 'input' => 'select',
34
+ 'source' => 'eav/entity_attribute_source_boolean',
35
+ 'global' => Mage_Catalog_Model_Resource_Eav_Attribute::SCOPE_WEBSITE,
36
+ 'visible' => true,
37
+ 'required' => false,
38
+ 'user_defined' => false,
39
+ 'default' => '',
40
+ 'apply_to' => $productTypes,
41
+ 'input_renderer' => 'auguria_productmatrix/adminhtml_catalog_product_helper_form_config',
42
+ 'visible_on_front' => false,
43
+ 'used_in_product_listing' => true
44
+ ));
45
+
46
+ // auguria_matrix_customer_groups : define the customer groups that can be displayed on the product view page
47
+ $this->addAttribute(Mage_Catalog_Model_Product::ENTITY, 'auguria_matrix_customer_groups', array(
48
+ 'group' => 'Product matrix',
49
+ 'backend' => 'auguria_productmatrix/entity_attribute_backend_customer_group',
50
+ 'frontend' => '',
51
+ 'label' => 'Customer groups authorized to display matrix on the product view page',
52
+ 'input' => 'multiselect',
53
+ 'type' => 'varchar',
54
+ 'source' => 'auguria_core/customer_attribute_source_group',
55
+ 'global' => Mage_Catalog_Model_Resource_Eav_Attribute::SCOPE_WEBSITE,
56
+ 'visible' => true,
57
+ 'required' => false,
58
+ 'user_defined' => false,
59
+ 'default' => '',
60
+ 'apply_to' => $productTypes,
61
+ 'input_renderer' => 'auguria_productmatrix/adminhtml_catalog_product_helper_form_config_customer_group',
62
+ 'visible_on_front' => false,
63
+ 'used_in_product_listing' => true
64
+ ));
app/design/adminhtml/default/default/layout/auguria/core.xml ADDED
@@ -0,0 +1,19 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?xml version="1.0"?>
2
+ <!--
3
+ /**
4
+ * @category Auguria
5
+ * @package Auguria_Core
6
+ * @author Auguria
7
+ * @license http://opensource.org/licenses/gpl-3.0.html GNU General Public License version 3 (GPLv3)
8
+ */
9
+ -->
10
+
11
+ <layout>
12
+
13
+ <default>
14
+ <reference name="head">
15
+ <action method="addCss"><link>auguria/core.css</link></action>
16
+ </reference>
17
+ </default>
18
+
19
+ </layout>
app/design/adminhtml/default/default/layout/auguria/product_matrix.xml ADDED
@@ -0,0 +1,20 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?xml version="1.0"?>
2
+ <!--
3
+ /**
4
+ * @category Auguria
5
+ * @package Auguria_ProductMatrix
6
+ * @author Auguria
7
+ * @license http://opensource.org/licenses/gpl-3.0.html GNU General Public License version 3 (GPLv3)
8
+ */
9
+ -->
10
+
11
+ <layout>
12
+
13
+ <!-- <adminhtml_catalog_product_configurable>
14
+ <reference name="product_tabs">
15
+ <action method="addTabAfter"><name>auguria_product_matrix</name><block>auguria_productmatrix/adminhtml_catalog_product_edit_tab_matrix</block><after>-</after></action>
16
+ <action method="bindShadowTabs"><first>auguria_product_matrix</first><second>configurable</second></action>
17
+ </reference>
18
+ </adminhtml_catalog_product_configurable> -->
19
+
20
+ </layout>
app/design/frontend/base/default/layout/auguria/product_matrix.xml ADDED
@@ -0,0 +1,24 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?xml version="1.0"?>
2
+ <!--
3
+ /**
4
+ * @category Auguria
5
+ * @package Auguria_ProductMatrix
6
+ * @author Auguria
7
+ * @license http://opensource.org/licenses/gpl-3.0.html GNU General Public License version 3 (GPLv3)
8
+ */
9
+ -->
10
+ <layout version="0.1.0">
11
+
12
+ <PRODUCT_TYPE_configurable>
13
+ <reference name="head">
14
+ <action method="addJs"><link>auguria/productmatrix/matrix.js</link></action>
15
+ <action method="addCss"><link>css/auguria/productmatrix/matrix.css</link></action>
16
+ </reference>
17
+ <reference name="product.info.additional">
18
+ <block type="auguria_productmatrix/catalog_product_matrix" name="auguria.productmatrix.catalog.product.matrix">
19
+ <action method="setTemplate"><template helper="auguria_productmatrix/config/getMatrixTemplate" /></action>
20
+ </block>
21
+ </reference>
22
+ </PRODUCT_TYPE_configurable>
23
+
24
+ </layout>
app/design/frontend/base/default/template/auguria/productmatrix/catalog/product/matrix/condensed.phtml ADDED
@@ -0,0 +1,310 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * @category Auguria
4
+ * @package Auguria_ProductMatrix
5
+ * @author Auguria
6
+ * @license http://opensource.org/licenses/gpl-3.0.html GNU General Public License version 3 (GPLv3)
7
+ */
8
+
9
+ /* @var Auguria_ProductMatrix_Block_Catalog_Product_Matrix */
10
+ ?>
11
+ <?php
12
+ $matrixInformations = $this->getMatrixInformations();
13
+ $lastAttribute = end($matrixInformations);
14
+ $attributesCount = count($matrixInformations);
15
+ $labelCount = $attributesCount;
16
+ $childrenProducts = $this->getChildrenProducts(); // all declinable products
17
+ $tierPrice = $this->getProduct()->getTierPrice();
18
+ ?>
19
+
20
+ <form action="<?php echo $this->getAddUrl() ?>" method="post" id="matrix_addtocart_form">
21
+
22
+ <table id="product-matrix" class="product-matrix data-table">
23
+ <caption><?php echo $this->__('Product matrix')?></caption>
24
+ <thead>
25
+ <tr>
26
+ <?php // Labels for all configurable attributes ?>
27
+ <?php foreach($matrixInformations as $_infos):?>
28
+ <th><?php echo $_infos['store_label']?></th>
29
+ <?php endforeach;?>
30
+
31
+ <?php // Labels for all options of the last configurable attribute ?>
32
+ <?php foreach($lastAttribute['values'] as $_value):?>
33
+ <th><?php echo $_value['store_label']?></th>
34
+ <?php endforeach;?>
35
+
36
+ <th><?php echo $this->__('Total quantity')?></th>
37
+ <th><?php echo $this->__('Total')?></th>
38
+ </tr>
39
+ </thead>
40
+ <tfoot>
41
+ <tr>
42
+ <?php if($labelCount > 1):?>
43
+ <th colspan="<?php echo $labelCount-1 ?>"></th>
44
+ <?php endif;?>
45
+ <th><?php echo $this->__('Total quantity')?></th>
46
+ <?php // total quantity ?>
47
+ <?php foreach($lastAttribute['values'] as $_value):?>
48
+ <th id="column-total-qty-<?php echo $_value['value_index']?>">0</th>
49
+ <?php endforeach;?>
50
+ <th id="column-total-qty">0</th>
51
+ <?php // Total ?>
52
+ <th id="column-total-price"><?php echo Mage::app()->getStore()->formatPrice(0)?></th>
53
+ </tr>
54
+ </tfoot>
55
+ <tbody id="product-matrix-body"></tbody>
56
+ </table>
57
+
58
+ <div class="no-display">
59
+ <input type="hidden" name="product" value="<?php echo $this->getProduct()->getId() ?>" />
60
+ <input type="hidden" name="related_product" id="related-products-field" value="" />
61
+ </div>
62
+
63
+ <button class="button btn-cart" title="<?php echo $this->__('Add to Cart')?>" type="submit"><span><span><?php echo $this->__('Add to Cart')?></span></span></button>
64
+
65
+ </form>
66
+
67
+ <script type="text/javascript">
68
+ //<![CDATA[
69
+
70
+ var matrixChildrenProducts = <?php echo Mage::helper('core')->jsonEncode($childrenProducts)?>; // children of the configurable product
71
+ var matrixInformations = <?php echo Mage::helper('core')->jsonEncode($matrixInformations)?>; // configurable attributes informations
72
+
73
+ // redefine matrix methods
74
+ var Matrix = Class.create(Matrix, {
75
+
76
+ initialize: function(config){
77
+ this.basePrice = parseFloat(config.basePrice); // base price for configurable product
78
+
79
+ this.tierPrice = config.tierPrice;
80
+ this.taxConfig = config.taxConfig;
81
+ this.productPrices = [];
82
+ this.productRows = [];
83
+ this.productOptionValues = [];
84
+
85
+ this.columnTotalQtyId = 'column-total-qty';
86
+ this.columnTotalPriceId = 'column-total-price';
87
+ this.columnTotalQtyValue = 0;
88
+ this.columnTotalPriceValue = 0;
89
+ },
90
+
91
+ // reload final price
92
+ reloadFinalPrice: function(productId, qty, oldQty){
93
+ var value = this.productPrices[productId].unit_price;
94
+ $('total-'+productId).update(this.formatPrice(value*qty)); // product total
95
+
96
+ // define product total prices
97
+ var oldPrice = this.productPrices[productId].old_unit_price*oldQty;
98
+ var newPrice = value*qty;
99
+
100
+ // define row total price
101
+ var inputTotal = $(this.productRows[productId]).down('td.row-total input');
102
+ var rowTotal = parseFloat(inputTotal.value);
103
+ var newTotal = rowTotal - oldPrice + newPrice;
104
+
105
+ // assign new prices
106
+ inputTotal.value = newTotal;
107
+ $(this.productRows[productId]).down('td.row-total div').update(this.formatPrice(newTotal));
108
+ },
109
+
110
+ // reload quantity
111
+ reloadQty: function(productId, qty, oldQty){
112
+ // line qty
113
+ $qtyElement = $(this.productRows[productId]).down('td.row-qty');
114
+ $qtyElement.update($qtyElement.innerHTML - oldQty + qty);
115
+
116
+ var qtyTotal = this.columnTotalQtyValue;
117
+ var newQtyTotal = qtyTotal-oldQty+qty;
118
+
119
+ // update column qty
120
+ var columnQtyElement = $('column-total-qty-' + this.productOptionValues[productId]);
121
+ columnQtyElement.update(columnQtyElement.innerHTML - oldQty + qty);
122
+
123
+ // update total qty
124
+ this.columnTotalQtyValue = newQtyTotal;
125
+ $(this.columnTotalQtyId).update(newQtyTotal);
126
+ },
127
+
128
+ // add product row id information
129
+ addProductToRow: function(productId, trElementId){
130
+ this.productRows[productId] = trElementId;
131
+ },
132
+
133
+ // add product option value information
134
+ addProductOptionValues: function(productId, value){
135
+ this.productOptionValues[productId] = value;
136
+ }
137
+ });
138
+
139
+ var matrix = new Matrix({'basePrice': spConfig.config.basePrice, 'tierPrice': <?php echo Mage::helper('core')->jsonEncode($tierPrice)?>, 'taxConfig': spConfig.taxConfig});
140
+
141
+ var $usedLastAttributeOptions = [];
142
+ var productsByOption = <?php echo Mage::helper('core')->jsonEncode($this->getProductsByOption())?>;
143
+
144
+ // complete body table HTML
145
+ for (var option in productsByOption){ // sorted by order for head and foot coherance
146
+ for (var key in productsByOption[option]) { // each products
147
+ if(isNaN(key)){break;}
148
+
149
+ var productId = productsByOption[option][key];
150
+ var product = matrixChildrenProducts[productId];
151
+ var prices = [];
152
+
153
+ // build product row
154
+ var trElement = new Element('tr')
155
+ var trElementId = 'row';
156
+ var superInputElements = [];
157
+
158
+ matrixInformations.each(function(attribute){ // each attributes filtered by position
159
+ var positionInValues = attribute.matrix_option_id_to_position[[product[attribute.attribute_code]]];
160
+ var option = attribute.values[positionInValues];
161
+
162
+ if(attribute.id == <?php echo $lastAttribute['id']?>){
163
+
164
+ var ulTextColumn = new Element('ul', {'class':'matrix_title'});
165
+
166
+ // quantite
167
+ var liElement = new Element('li').update('<?php echo $this->__('Quantity')?> : ');
168
+ ulTextColumn.insert({bottom: liElement});
169
+
170
+ // reference
171
+ var liElement = new Element('li').update('<?php echo $this->__('Reference')?> : ');
172
+ ulTextColumn.insert({bottom: liElement});
173
+
174
+ // price
175
+ var liElement = new Element('li').update('<?php echo $this->__('Price')?> : ');
176
+ ulTextColumn.insert({bottom: liElement});
177
+
178
+ // total price
179
+ var liElement = new Element('li').update('<?php echo $this->__('Total')?> : ');
180
+ ulTextColumn.insert({bottom: liElement});
181
+
182
+ var tdElement = new Element('td').update(ulTextColumn);
183
+ trElement.appendChild(tdElement);
184
+
185
+ //empty td for last attribute label column
186
+ //var tdElement = new Element('td');
187
+ //trElement.appendChild(tdElement);
188
+
189
+ var tdElementId = trElementId + '-' + attribute.attribute_id + '_' + option.value_index;
190
+ var tdElement = new Element('td', {'id': tdElementId});
191
+
192
+ // input configurable options values
193
+ var inputElement = new Element('input', {'type': 'hidden', 'name': 'matrix_products[' + product.entity_id + '][super_attribute]['+ attribute.attribute_id +']', 'value': option.value_index});
194
+ tdElement.appendChild(inputElement);
195
+
196
+ // other attributes option value
197
+ superInputElements.each(function(input){
198
+ tdElement.appendChild(input);
199
+ });
200
+
201
+ // add qty input element
202
+ var inputElement = new Element('input', {'class': 'input-text qty', 'type': 'text', 'title': 'Qty', 'value': '0', 'maxlength': '12', 'name': 'matrix_products[' + product.entity_id + '][qty]', 'id': product.entity_id});
203
+ if(product.is_in_stock == false){
204
+ inputElement.setAttribute('readonly', true);
205
+ inputElement.addClassName('disabled');
206
+ }
207
+ tdElement.appendChild(inputElement);
208
+
209
+ // add option price to calcul final product price
210
+ prices.push({'is_percent': option.is_percent, 'pricing_value': option.pricing_value});
211
+
212
+ // unit price
213
+ var finalPrice = matrix.loadPrice(product.entity_id, prices);
214
+
215
+ var ulElement = new Element('ul');
216
+
217
+ // reference
218
+ var liElement = new Element('li').update(product.sku);
219
+ ulElement.insert({bottom: liElement});
220
+
221
+ // price
222
+ var liElement = new Element('li', {'id': 'unit-price-'+product.entity_id}).update(matrix.formatPrice(finalPrice));
223
+ ulElement.insert({bottom: liElement});
224
+
225
+ // total price
226
+ var liElement = new Element('li', {'id': 'total-'+product.entity_id}).update(matrix.formatPrice(0.00));
227
+ ulElement.insert({bottom: liElement});
228
+
229
+ // product infos
230
+ tdElement.appendChild(ulElement);
231
+
232
+ matrix.addProductPrice(product.entity_id, finalPrice, prices); // add product price information to matrix
233
+
234
+ // add/update cell to tr
235
+ if(!$(tdElementId)){
236
+ trElement.appendChild(tdElement); // add cell
237
+ }else{
238
+ tdElement.childElements().each(function(elem){
239
+ $(tdElement.id).appendChild(elem); // update cell
240
+ });
241
+ }
242
+
243
+ // add empty cell with id no exists and no content
244
+ attribute.values.each(function(value){
245
+ var valueTdElementId = trElementId + '-' + attribute.attribute_id + '_' + value.value_index;
246
+ var valueTdElement = new Element('td', {'id': valueTdElementId});
247
+
248
+ // if td exists : row exists
249
+ if(!$(valueTdElementId) && tdElementId != valueTdElementId){
250
+ // add id to row
251
+ trElement.id = trElementId;
252
+ // add cell to tr
253
+ trElement.appendChild(valueTdElement);
254
+
255
+ if(!$(trElementId)){
256
+ // append row to body table
257
+ $('product-matrix-body').appendChild(trElement);
258
+ }
259
+ }
260
+ });
261
+
262
+ // total quantity
263
+ var tdElement = new Element('td', {'class': 'row-qty'});
264
+ trElement.appendChild(tdElement).update('0');
265
+
266
+ // Total
267
+ var tdElement = new Element('td', {'class': 'row-total'});
268
+ // input
269
+ var inputElement = new Element('input', {'type': 'hidden', 'name': 'matrix_products[' + trElementId + '][final_price]', 'value': 0.00});
270
+ inputElement.addClassName('disabled');
271
+ tdElement.appendChild(inputElement);
272
+ // text
273
+ var divElement = new Element('div').update(matrix.formatPrice('0.00'));
274
+ tdElement.appendChild(divElement);
275
+
276
+ trElement.appendChild(tdElement);
277
+
278
+ matrix.addProductToRow(product.entity_id, trElementId); // add row id information for product
279
+ matrix.addProductOptionValues(product.entity_id, option.value_index) // add last attribute option value information for product
280
+ }else{
281
+ var tdElement = new Element('td').update(option.store_label);
282
+ trElement.appendChild(tdElement);
283
+
284
+ trElementId += '-' + attribute.attribute_id + '_' + option.value_index;
285
+
286
+ // input configurable options values
287
+ var inputElement = new Element('input', {'type': 'hidden', 'name': 'matrix_products[' + product.entity_id + '][super_attribute]['+ attribute.attribute_id +']', 'value': option.value_index});
288
+ superInputElements[attribute.id] = inputElement;
289
+ }
290
+ });
291
+ }
292
+ }
293
+
294
+ decorateTable('product-matrix');
295
+
296
+ // update values when quantity is modified
297
+ document.observe("dom:loaded", function() {
298
+ $$('#product-matrix input.qty').each(function(elem){
299
+ var oldQty = 0;
300
+ elem.observe('focus', function(event){
301
+ oldQty = this.value; //get old qty
302
+ });
303
+ elem.observe('change', function(event){
304
+ matrix.reload(this.id, this.value, oldQty); // reload product total, grand total, total qty
305
+ });
306
+ });
307
+ });
308
+
309
+ //]]>
310
+ </script>
app/design/frontend/base/default/template/auguria/productmatrix/catalog/product/matrix/inline.phtml ADDED
@@ -0,0 +1,145 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * @category Auguria
4
+ * @package Auguria_ProductMatrix
5
+ * @author Auguria
6
+ * @license http://opensource.org/licenses/gpl-3.0.html GNU General Public License version 3 (GPLv3)
7
+ */
8
+
9
+ /* @var Auguria_ProductMatrix_Block_Catalog_Product_Matrix */
10
+ ?>
11
+ <?php
12
+ $matrixInformations = $this->getMatrixInformations();
13
+ $lastAttribute = end($matrixInformations);
14
+ $attributesCount = count($matrixInformations);
15
+ $labelCount = $attributesCount+2; // product name + reference
16
+ $childrenProducts = $this->getChildrenProducts(); // all declinable products
17
+ $tierPrice = $this->getProduct()->getTierPrice();
18
+ ?>
19
+
20
+ <form action="<?php echo $this->getAddUrl() ?>" method="post" id="matrix_addtocart_form">
21
+
22
+ <table id="product-matrix" class="product-matrix data-table">
23
+ <caption><?php echo $this->__('Product matrix')?></caption>
24
+ <thead>
25
+ <tr>
26
+ <th><?php echo $this->__('Product name')?></th>
27
+ <th><?php echo $this->__('Reference')?></th>
28
+
29
+ <?php // Labels for all configurable attributes ?>
30
+ <?php foreach($matrixInformations as $_infos):?>
31
+ <th><?php echo $_infos['store_label']?></th>
32
+ <?php endforeach;?>
33
+
34
+ <th><?php echo $this->__('Unit price')?></th>
35
+ <th><?php echo $this->__('Total quantity')?></th>
36
+ <th><?php echo $this->__('Total')?></th>
37
+ </tr>
38
+ </thead>
39
+ <tfoot>
40
+ <tr>
41
+ <th colspan="<?php echo $labelCount-1 ?>"></th>
42
+ <th><?php echo $this->__('Total quantity')?></th>
43
+ <th></th><?php // unit price ?>
44
+ <?php // total quantity ?>
45
+ <th id="column-total-qty">0</th>
46
+ <?php // Total ?>
47
+ <th id="column-total-price"><?php echo Mage::app()->getStore()->formatPrice(0)?></th>
48
+ </tr>
49
+ </tfoot>
50
+ <tbody id="product-matrix-body"></tbody>
51
+ </table>
52
+
53
+ <div class="no-display">
54
+ <input type="hidden" name="product" value="<?php echo $this->getProduct()->getId() ?>" />
55
+ <input type="hidden" name="related_product" id="related-products-field" value="" />
56
+ </div>
57
+
58
+ <button class="button btn-cart" title="<?php echo $this->__('Add to Cart')?>" type="submit"><span><span><?php echo $this->__('Add to Cart')?></span></span></button>
59
+
60
+ </form>
61
+
62
+ <script type="text/javascript">
63
+ //<![CDATA[
64
+
65
+ var matrix = new Matrix({'basePrice': spConfig.config.basePrice, 'tierPrice': <?php echo Mage::helper('core')->jsonEncode($tierPrice)?>, 'taxConfig': spConfig.taxConfig});
66
+
67
+ var matrixChildrenProducts = <?php echo Mage::helper('core')->jsonEncode($childrenProducts)?>; // children of the configurable product
68
+ var matrixInformations = <?php echo Mage::helper('core')->jsonEncode($matrixInformations)?>; // configurable attributes informations
69
+
70
+ // complete body table HTML
71
+ for (var key in matrixChildrenProducts) { // each products
72
+ var product = matrixChildrenProducts[key];
73
+ var prices = [];
74
+
75
+ // build product row
76
+ var trElement = new Element('tr', {'class': 'productId-' + product.entity_id});
77
+
78
+ // name
79
+ var tdElement = new Element('td').update(product.name);
80
+ trElement.appendChild(tdElement);
81
+
82
+ // reference
83
+ var tdElement = new Element('td').update(product.sku);
84
+ trElement.appendChild(tdElement);
85
+
86
+ matrixInformations.each(function(attribute){ // each attributes filtered by position
87
+ var positionInValues = attribute.matrix_option_id_to_position[[product[attribute.attribute_code]]];
88
+ var option = attribute.values[positionInValues];
89
+
90
+ var tdElement = new Element('td').update(option.store_label);
91
+
92
+ // input configurable options values
93
+ var inputElement = new Element('input', {'type': 'hidden', 'name': 'matrix_products[' + product.entity_id + '][super_attribute]['+ attribute.attribute_id +']', 'value': option.value_index});
94
+
95
+ tdElement.appendChild(inputElement);
96
+ trElement.appendChild(tdElement);
97
+
98
+ // add option price to calcul final product price
99
+ prices.push({'is_percent': option.is_percent, 'pricing_value': option.pricing_value});
100
+ });
101
+
102
+ // unit price
103
+ var finalPrice = matrix.loadPrice(product.entity_id, prices);
104
+ var tdElement = new Element('td', {'id': 'unit-price-'+product.entity_id}).update(matrix.formatPrice(finalPrice));
105
+ trElement.appendChild(tdElement);
106
+
107
+ matrix.addProductPrice(product.entity_id, finalPrice, prices); // add product price information to matrix
108
+
109
+ // total quantity
110
+ var tdElement = new Element('td');
111
+ // add qty input element
112
+ var inputElement = new Element('input', {'class': 'input-text qty', 'type': 'text', 'title': 'Qty', 'value': '0', 'maxlength': '12', 'name': 'matrix_products[' + product.entity_id + '][qty]', 'id': product.entity_id});
113
+ if(product.is_in_stock == false){
114
+ inputElement.setAttribute('readonly', true);
115
+ inputElement.addClassName('disabled');
116
+ }
117
+ tdElement.appendChild(inputElement);
118
+
119
+ trElement.appendChild(tdElement);
120
+
121
+ // Total
122
+ var tdElement = new Element('td', {'id': 'total-'+product.entity_id}).update(matrix.formatPrice('0.00'));
123
+ trElement.appendChild(tdElement);
124
+
125
+ // append row to body table
126
+ $('product-matrix-body').appendChild(trElement);
127
+ }
128
+
129
+ decorateTable('product-matrix');
130
+
131
+ // update values when quantity is modified
132
+ document.observe("dom:loaded", function() {
133
+ $$('#product-matrix input.qty').each(function(elem){
134
+ var oldQty = 0;
135
+ elem.observe('focus', function(event){
136
+ oldQty = this.value; //get old qty
137
+ });
138
+ elem.observe('change', function(event){
139
+ matrix.reload(this.id, this.value, oldQty); // reload product total, grand total, total qty
140
+ });
141
+ });
142
+ });
143
+
144
+ //]]>
145
+ </script>
app/etc/modules/Auguria_Core.xml ADDED
@@ -0,0 +1,17 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?xml version="1.0"?>
2
+ <!--
3
+ /**
4
+ * @category Auguria
5
+ * @package Auguria_Core
6
+ * @author Auguria
7
+ * @license http://opensource.org/licenses/gpl-3.0.html GNU General Public License version 3 (GPLv3)
8
+ */
9
+ -->
10
+ <config>
11
+ <modules>
12
+ <Auguria_Core>
13
+ <active>true</active>
14
+ <codePool>community</codePool>
15
+ </Auguria_Core>
16
+ </modules>
17
+ </config>
app/etc/modules/Auguria_ProductMatrix.xml ADDED
@@ -0,0 +1,20 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?xml version="1.0"?>
2
+ <!--
3
+ /**
4
+ * @category Auguria
5
+ * @package Auguria_ProductMatrix
6
+ * @author Auguria
7
+ * @license http://opensource.org/licenses/gpl-3.0.html GNU General Public License version 3 (GPLv3)
8
+ */
9
+ -->
10
+ <config>
11
+ <modules>
12
+ <Auguria_ProductMatrix>
13
+ <active>true</active>
14
+ <codePool>community</codePool>
15
+ <depends>
16
+ <Auguria_Core />
17
+ </depends>
18
+ </Auguria_ProductMatrix>
19
+ </modules>
20
+ </config>
app/locale/en_US/Auguria_Core.csv ADDED
File without changes
app/locale/en_US/Auguria_ProductMatrix.csv ADDED
@@ -0,0 +1,17 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ "Auguria product matrix","Auguria product matrix"
2
+ "General","General"
3
+ "Display matrix on the configurable product page view","Display matrix on the configurable product page view"
4
+ "Display for these groups only","Display for these groups only"
5
+ "Template to use","Template to use"
6
+ "Use Config Settings","Use Config Settings"
7
+ "Product matrix","Product matrix"
8
+ "Product matrix configuration","Product matrix configuration"
9
+ "%s was added to your shopping cart.","%s was added to your shopping cart."
10
+ "Cannot add the item to shopping cart.","Cannot add the item to shopping cart."
11
+ "Total quantity","Total quantity"
12
+ "Total","Total"
13
+ "Add to Cart","Add to Cart"
14
+ "Product name","Product name"
15
+ "Reference","Reference"
16
+ "reference :","reference :"
17
+ "Unit price","Unit price"
app/locale/fr_FR/Auguria_Core.csv ADDED
File without changes
app/locale/fr_FR/Auguria_ProductMatrix.csv ADDED
@@ -0,0 +1,20 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ "Auguria product matrix","Matrice de produits Auguria"
2
+ "General","Général"
3
+ "Display matrix on the configurable product page view","Afficher la matrice sur la fiche produit des configurables"
4
+ "Display for these groups only","Afficher pour ces groupes uniquement"
5
+ "Template to use","Template à utiliser"
6
+ "Use Config Settings","Utiliser la configuration par défaut"
7
+ "Product matrix","Matrice de produits"
8
+ "Product matrix configuration","Configuration de la matrice de produits"
9
+ "%s was added to your shopping cart.","%s a été ajouté à votre panier."
10
+ "Cannot add the item to shopping cart.","Impossible d'ajouter le produit au panier."
11
+ "Total quantity","Quantité totale"
12
+ "Total","Total"
13
+ "Price","Prix"
14
+ "Total price","Prix total"
15
+ "Add to Cart","Ajouter au panier"
16
+ "Product name","Nom du produit"
17
+ "Reference","Référence"
18
+ "reference :","référence :"
19
+ "Unit price","Prix unitaire"
20
+ "Quantity","Quantité"
js/auguria/productmatrix/matrix.js ADDED
@@ -0,0 +1,143 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ Matrix = Class.create();
2
+ Matrix.prototype = {
3
+
4
+ initialize: function(config){
5
+ this.basePrice = parseFloat(config.basePrice); // base price for configurable product
6
+
7
+ this.tierPrice = config.tierPrice;
8
+ this.taxConfig = config.taxConfig;
9
+ this.productPrices = [];
10
+
11
+ this.columnTotalQtyId = 'column-total-qty';
12
+ this.columnTotalPriceId = 'column-total-price';
13
+ this.columnTotalQtyValue = 0;
14
+ this.columnTotalPriceValue = 0;
15
+ },
16
+
17
+ // format price with currency (locale configuration)
18
+ formatPrice: function(price){
19
+
20
+ if (this.taxConfig.includeTax) {
21
+ var tax = price / (100 + this.taxConfig.defaultTax) * this.taxConfig.defaultTax;
22
+ var excl = price - tax;
23
+ var incl = excl*(1+(this.taxConfig.currentTax/100));
24
+ } else {
25
+ var tax = price * (this.taxConfig.currentTax / 100);
26
+ var excl = price;
27
+ var incl = excl + tax;
28
+ }
29
+
30
+ if (this.taxConfig.showIncludeTax || this.taxConfig.showBothPrices) {
31
+ price = incl;
32
+ } else {
33
+ price = excl;
34
+ }
35
+
36
+ var str = '';
37
+
38
+ if (optionsPrice.showBothPrices) {
39
+ str+= formatCurrency(excl, optionsPrice.priceFormat) + ' (' + formatCurrency(price, optionsPrice.priceFormat) + ' ' + this.taxConfig.inclTaxTitle + ')';
40
+ } else {
41
+ str += formatCurrency(price, optionsPrice.priceFormat)
42
+ }
43
+
44
+ return str;
45
+ },
46
+
47
+ // calcul final price
48
+ loadPrice: function(productId, options, basePrice, format){
49
+ var finalPrice = basePrice ? basePrice : this.basePrice;
50
+ var basePrice = basePrice ? basePrice : this.basePrice;
51
+
52
+ options.each(function(price){
53
+ if(price.pricing_value){
54
+ if(parseInt(price.is_percent) > 0){ // percent
55
+ finalPrice = finalPrice + basePrice * (parseFloat(price.pricing_value)/100);
56
+ }else{ // fixe
57
+ finalPrice = finalPrice + parseFloat(price.pricing_value);
58
+ }
59
+ }
60
+ });
61
+
62
+ // store format (currency...)
63
+ finalPrice = format ? this.formatPrice(finalPrice) : finalPrice;
64
+
65
+ return finalPrice;
66
+ },
67
+
68
+ // add product price in matrix
69
+ addProductPrice: function(productId, price, options){
70
+ this.productPrices[productId] = {'unit_price': price, 'old_unit_price': price, 'options': options};
71
+ },
72
+
73
+ // reload matrix
74
+ reload: function(productId, qty, oldQty){
75
+ qty = parseInt(qty);
76
+
77
+ if(this.tierPrice.length){
78
+ this.reloadUnitPrice(productId, qty, oldQty) // reload unit price (tier price)
79
+ }
80
+
81
+ this.reloadFinalPrice(productId, qty, oldQty); // reload final price
82
+ this.reloadQty(productId, qty, oldQty); // reload total
83
+ this.reloadPrice(productId, qty, oldQty); // reload quantity
84
+ },
85
+
86
+ // reload unit price coz of tier price
87
+ reloadUnitPrice: function(productId, qty, oldQty){
88
+ var basePrice = this.basePrice; // group price calculated
89
+ var unitPrice = this.productPrices[productId].unit_price; // required when adding a new product price
90
+ var qtyToCheck = 0;
91
+
92
+ this.productPrices[productId].old_unit_price = unitPrice;
93
+
94
+ // get tier price to use
95
+ var increment = 1;
96
+ this.tierPrice.each(function(tierPrice){
97
+ var tierPriceQty = parseInt(tierPrice.price_qty);
98
+ var tierProductPrice = parseFloat(tierPrice.price);
99
+
100
+ if(increment == 1 && qty < tierPriceQty){
101
+ unitPrice = basePrice; // no tier price, get the base price
102
+ }else if(qtyToCheck <= tierPriceQty && qty >= tierPriceQty){
103
+ unitPrice = (tierProductPrice < basePrice) ? tierProductPrice : basePrice; // new unitPrice
104
+ qtyToCheck = tierPriceQty; // qty for available tier price
105
+ }
106
+
107
+ increment ++;
108
+ });
109
+
110
+ unitPrice = this.loadPrice(productId, this.productPrices[productId].options, unitPrice); // get new unit price with options variation
111
+
112
+ this.productPrices[productId].unit_price = unitPrice; // update product price information in matrix
113
+ $('unit-price-' + productId).update(this.formatPrice(unitPrice));
114
+ },
115
+
116
+ // reload final price
117
+ reloadFinalPrice: function(productId, qty, oldQty){
118
+ var value = this.productPrices[productId].unit_price;
119
+ $('total-'+productId).update(this.formatPrice(value*qty));
120
+ },
121
+
122
+ // reload quantity
123
+ reloadQty: function(productId, qty, oldQty){
124
+ var qtyTotal = this.columnTotalQtyValue;
125
+ var newQtyTotal = qtyTotal-oldQty+qty;
126
+
127
+ this.columnTotalQtyValue = newQtyTotal;
128
+ $(this.columnTotalQtyId).update(newQtyTotal);
129
+ },
130
+
131
+ // reload grand total
132
+ reloadPrice: function(productId, qty, oldQty){
133
+ var unitPrice = this.productPrices[productId].unit_price;
134
+ var oldUnitPrice = this.productPrices[productId].old_unit_price;
135
+ var priceTotal = this.columnTotalPriceValue;
136
+
137
+ // substract old unit price with old quantity to the total and add the new unit price mutliplied by the new quantity
138
+ var newPriceTotal = priceTotal - oldUnitPrice*oldQty + unitPrice*qty;
139
+
140
+ this.columnTotalPriceValue = newPriceTotal;
141
+ $(this.columnTotalPriceId).update(this.formatPrice(newPriceTotal));
142
+ },
143
+ }
package.xml ADDED
@@ -0,0 +1,32 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?xml version="1.0"?>
2
+ <package>
3
+ <name>auguriaproductmatrix</name>
4
+ <version>0.0.1</version>
5
+ <stability>stable</stability>
6
+ <license uri="http://opensource.org/licenses/gpl-license.php">GNU General Public License</license>
7
+ <channel>community</channel>
8
+ <extends/>
9
+ <summary>Children products matrix of a configurable product on the product view page.</summary>
10
+ <description>&lt;strong&gt;Features&lt;/strong&gt;&lt;br /&gt;&#xD;
11
+ &lt;br /&gt;&#xD;
12
+ &lt;strong&gt;Handled by the extension&lt;/strong&gt;&lt;br /&gt;&#xD;
13
+ - possibility to active or not the extension by website (system configuration) and by product&lt;br /&gt;&#xD;
14
+ - possibility to define for which customer groups you want to show the matrix. Customizable by website (system configuration) and by product&lt;br /&gt;&#xD;
15
+ - possibility to choose which matrix template used by website (system configuration)&lt;br /&gt;&#xD;
16
+ - take care of customer price and tier prices&lt;br /&gt;&#xD;
17
+ - dynamic calculation of the quantity selected by product and for the matrix total price&lt;br /&gt;&#xD;
18
+ - dynamic calculation of the total price by product and of the matrix total price&lt;br /&gt;&#xD;
19
+ &lt;strong&gt;Not handled by the extension&lt;/strong&gt;&lt;br /&gt;&#xD;
20
+ - configurable products with custom options c'ant show the matrix&lt;br /&gt;&#xD;
21
+ - the shopping cart price rules of type (X bought = discount of Y%) are not taken in the matrix price calculation (works only on the cart step)&lt;br /&gt;&#xD;
22
+ - frontend templates are not responsive&lt;br /&gt;&lt;br /&gt;&#xD;
23
+ &#xD;
24
+ &lt;a href="http://www.auguria.com/magento/auguria-productmatrix.html"&gt;Documentation&lt;/a&gt;</description>
25
+ <notes>Compatibility with magento 1.9</notes>
26
+ <authors><author><name>Auguria</name><user>auguria</user><email>magento@auguria.net</email></author></authors>
27
+ <date>2014-07-16</date>
28
+ <time>10:11:09</time>
29
+ <contents><target name="magecommunity"><dir name="Auguria"><dir name="Core"><dir name="Helper"><file name="Data.php" hash="73bdf383ed70ef7a844149518637d4b1"/></dir><dir name="Model"><dir name="Attribute"><dir name="Backend"><dir name="Image"><file name="Abstract.php" hash="4ac4fc2b5653635b2c7d6a6761d32394"/></dir></dir></dir><dir name="Customer"><dir name="Attribute"><dir name="Source"><file name="Group.php" hash="275163848ce915273abf1b3bc752a112"/></dir></dir></dir><dir name="System"><dir name="Config"><dir name="Source"><file name="Config.php" hash="5e31ba47c019daa5575b9e442060f1d6"/><dir name="Customer"><dir name="Group"><file name="Multiselect.php" hash="7ffe45941e1a10491e0b161d5e5a2572"/></dir></dir></dir></dir></dir></dir><dir name="etc"><file name="config.xml" hash="152714fbae8487307145ad01929173fd"/><file name="system.xml" hash="addce60a6afe7b99f9bbb8fa813d9010"/></dir></dir><dir name="ProductMatrix"><dir name="Block"><dir name="Adminhtml"><dir name="Catalog"><dir name="Product"><dir name="Helper"><dir name="Form"><dir name="Config"><dir name="Customer"><file name="Group.php" hash="680fdb918ed46748b958ec81216f53dc"/></dir></dir><file name="Config.php" hash="1840c4361f72f3b315b246d4e2f6730d"/></dir></dir></dir></dir></dir><dir name="Catalog"><dir name="Product"><file name="Matrix.php" hash="2a583fff8439583ee8f020f15ddba7be"/></dir></dir></dir><dir name="Helper"><file name="Config.php" hash="d43481a7eab755045021929964737d36"/><file name="Data.php" hash="dde58fd53a58af02e865499bc39eeb2c"/></dir><dir name="Model"><dir name="Entity"><dir name="Attribute"><dir name="Backend"><dir name="Customer"><file name="Group.php" hash="eb28ab09e47ef15b7c22bc95e79bb4b2"/></dir></dir></dir></dir><dir name="System"><dir name="Config"><dir name="Source"><dir name="Matrix"><file name="Template.php" hash="dae57ce834d3793159b7998c8398381f"/></dir></dir></dir></dir></dir><dir name="controllers"><dir name="Checkout"><file name="CartController.php" hash="13188546ae21d338b2b6cfed634896a4"/></dir></dir><dir name="etc"><file name="adminhtml.xml" hash="43a734766e7c2aeb2a020d84d62fee2a"/><file name="config.xml" hash="1b4312bcc3f95f90410f51ce68f37596"/><file name="system.xml" hash="4b25c33b144bd116d42bb4d183724534"/></dir><dir name="sql"><dir name="auguria_productmatrix_setup"><file name="install-0.0.1.php" hash="68d2c8aaa6d304a6a42ba214afd8e5dd"/></dir></dir></dir></dir></target><target name="magedesign"><dir name="adminhtml"><dir name="default"><dir name="default"><dir name="layout"><dir name="auguria"><file name="core.xml" hash="73d41f963e258e406b8b9042b7b0f17b"/><file name="product_matrix.xml" hash="4bf81d781152deaabaeadd98c1f3ddec"/></dir></dir></dir></dir></dir><dir name="frontend"><dir name="base"><dir name="default"><dir name="template"><dir name="auguria"><dir name="productmatrix"><dir name="catalog"><dir name="product"><dir name="matrix"><file name="condensed.phtml" hash="e82105985e266f7cc7244484b4fe9d38"/><file name="inline.phtml" hash="3e99170882a23d9cce28657d2c4e676c"/></dir></dir></dir></dir></dir></dir><dir name="layout"><dir name="auguria"><file name="product_matrix.xml" hash="f5085b207570102b109862415d1ca6e6"/></dir></dir></dir></dir></dir></target><target name="magelocale"><dir name="en_US"><file name="Auguria_Core.csv" hash="d41d8cd98f00b204e9800998ecf8427e"/><file name="Auguria_ProductMatrix.csv" hash="e1cb725e3a29921da37d500a1809f834"/></dir><dir name="fr_FR"><file name="Auguria_Core.csv" hash="d41d8cd98f00b204e9800998ecf8427e"/><file name="Auguria_ProductMatrix.csv" hash="410afce641ac0abe9d889d3e853967ed"/></dir></target><target name="mageetc"><dir name="modules"><file name="Auguria_Core.xml" hash="1569ebe15f1c2b8e4b5c61b9bc797fe6"/><file name="Auguria_ProductMatrix.xml" hash="14ed53bc1b11812b148eca0579026ea6"/></dir></target><target name="mageskin"><dir name="adminhtml"><dir name="default"><dir name="default"><dir name="auguria"><file name="core.css" hash="f21626dc01765695d52346bb5da8c0cb"/><dir name="images"><file name="tab-header.png" hash="277234c8e4a9462fe0bf91c174cef179"/><file name="section-header.png" hash="277234c8e4a9462fe0bf91c174cef179"/></dir></dir></dir></dir></dir></target><target name="mage"><dir name="js"><dir name="auguria"><dir name="productmatrix"><file name="matrix.js" hash="500e6f440f3167625622b739a434734b"/></dir></dir></dir></target></contents>
30
+ <compatible/>
31
+ <dependencies><required><php><min>5.3.0</min><max>6.0.0</max></php></required></dependencies>
32
+ </package>
skin/adminhtml/default/default/auguria/core.css ADDED
@@ -0,0 +1,17 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <!--
2
+ /**
3
+ * @category Auguria
4
+ * @package Auguria_Core
5
+ * @author Auguria
6
+ * @license http://opensource.org/licenses/gpl-3.0.html GNU General Public License version 3 (GPLv3)
7
+ */
8
+ -->
9
+ li.auguria-tab dl dt.label {
10
+ background: url('images/tab-header.png') no-repeat scroll 40px 6px #ffffff;
11
+ height: 28px;
12
+ }
13
+ h3.auguria-header {
14
+ background: url("images/section-header.png") no-repeat scroll 4px 12px transparent;
15
+ padding: 11px 0 2px 140px;
16
+ height: 19px;
17
+ }
skin/adminhtml/default/default/auguria/images/section-header.png ADDED
Binary file
skin/adminhtml/default/default/auguria/images/tab-header.png ADDED
Binary file