Phxsolution_Manufactures - Version 0.1.0

Version Notes

Fixed some minor bugs.

Download this release

Release Info

Developer Prakash Vaniya
Extension Phxsolution_Manufactures
Version 0.1.0
Comparing to
See all releases


Version 0.1.0

Files changed (31) hide show
  1. app/code/community/Phxsolution/Manufactures/Block/Adminhtml/Catalog/Product/Grid.php +174 -0
  2. app/code/community/Phxsolution/Manufactures/Block/Adminhtml/Manufactures.php +38 -0
  3. app/code/community/Phxsolution/Manufactures/Block/Adminhtml/Manufactures/Edit.php +74 -0
  4. app/code/community/Phxsolution/Manufactures/Block/Adminhtml/Manufactures/Edit/Form.php +44 -0
  5. app/code/community/Phxsolution/Manufactures/Block/Adminhtml/Manufactures/Edit/Tab/Form.php +88 -0
  6. app/code/community/Phxsolution/Manufactures/Block/Adminhtml/Manufactures/Edit/Tabs.php +48 -0
  7. app/code/community/Phxsolution/Manufactures/Block/Adminhtml/Manufactures/Grid.php +151 -0
  8. app/code/community/Phxsolution/Manufactures/Block/Adminhtml/Manufactures/Renderer/Image.php +48 -0
  9. app/code/community/Phxsolution/Manufactures/Block/Manufactures.php +41 -0
  10. app/code/community/Phxsolution/Manufactures/Helper/Data.php +153 -0
  11. app/code/community/Phxsolution/Manufactures/Helper/Profit/Data.php +164 -0
  12. app/code/community/Phxsolution/Manufactures/Model/Manufactures.php +54 -0
  13. app/code/community/Phxsolution/Manufactures/Model/Mysql4/Manufactures.php +35 -0
  14. app/code/community/Phxsolution/Manufactures/Model/Mysql4/Manufactures/Collection.php +35 -0
  15. app/code/community/Phxsolution/Manufactures/Model/Product.php +31 -0
  16. app/code/community/Phxsolution/Manufactures/Model/Product/Type/Configurable/Price.php +167 -0
  17. app/code/community/Phxsolution/Manufactures/Model/Product/Type/Grouped/Price.php +95 -0
  18. app/code/community/Phxsolution/Manufactures/Model/Product/Type/Price.php +167 -0
  19. app/code/community/Phxsolution/Manufactures/Model/Profit.php +40 -0
  20. app/code/community/Phxsolution/Manufactures/controllers/Adminhtml/ManufacturesController.php +286 -0
  21. app/code/community/Phxsolution/Manufactures/controllers/IndexController.php +37 -0
  22. app/code/community/Phxsolution/Manufactures/controllers/ProductsController.php +37 -0
  23. app/code/community/Phxsolution/Manufactures/etc/config.xml +194 -0
  24. app/code/community/Phxsolution/Manufactures/etc/system.xml +79 -0
  25. app/code/community/Phxsolution/Manufactures/sql/manufactures_setup/mysql4-install-0.1.0.php +51 -0
  26. app/design/adminhtml/default/default/layout/manufactures.xml +33 -0
  27. app/design/frontend/base/default/layout/manufactures.xml +54 -0
  28. app/design/frontend/base/default/template/manufactures/manufactures-products.phtml +118 -0
  29. app/design/frontend/base/default/template/manufactures/manufactures.phtml +77 -0
  30. app/etc/modules/Phxsolution_Manufactures.xml +34 -0
  31. package.xml +18 -0
app/code/community/Phxsolution/Manufactures/Block/Adminhtml/Catalog/Product/Grid.php ADDED
@@ -0,0 +1,174 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /*
3
+ /**
4
+ * PHXSolution Manufactures Commission Manager
5
+ *
6
+ * NOTICE OF LICENSE
7
+ *
8
+ * This source file is subject to the Open Software License (OSL 3.0)
9
+ * that is bundled with this package in the file LICENSE.txt.
10
+ * It is also available through the world-wide-web at this URL:
11
+ * http://opensource.org/licenses/osl-3.0.php
12
+ * If you did not receive a copy of the license and are unable to
13
+ * obtain it through the world-wide-web, please send an email
14
+ * to license@magentocommerce.com so you can be sent a copy immediately.
15
+ *
16
+ * Original code copyright (c) 2008 Irubin Consulting Inc. DBA Varien
17
+ *
18
+ * @category Manufactures Block
19
+ * @package Phxsolution_Manufactures
20
+ * @author Prakash Vaniya
21
+ * @contact contact@phxsolution.com
22
+ * @site www.phxsolution.com
23
+ * @copyright Copyright (c) 2014 PHXSolution Manufactures
24
+ * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
25
+ */
26
+ ?>
27
+ <?php
28
+ class Phxsolution_Manufactures_Block_Adminhtml_Catalog_Product_Grid extends Mage_Adminhtml_Block_Catalog_Product_Grid
29
+ {
30
+ /* Overwritten to be able to add custom columns to the product grid. Normally
31
+ * one would overwrite the function _prepareCollection, but it won't work because
32
+ * you have to call parent::_prepareCollection() first to get the collection.
33
+ *
34
+ * But since parent::_prepareCollection() also finishes the collection, the
35
+ * joins and attributes to select added in the overwritten _prepareCollection()
36
+ * are 'forgotten'.
37
+ *
38
+ * By overwriting setCollection (which is called in parent::_prepareCollection()),
39
+ * we are able to add the join and/or attribute select in a proper way.
40
+ *
41
+ */
42
+ public function setCollection($collection)
43
+ {
44
+ /* @var $collection Mage_Catalog_Model_Resource_Product_Collection */
45
+
46
+ $store = $this->_getStore();
47
+
48
+ // Add our custom attributes
49
+ $collection->addAttributeToSelect('manufacturer');
50
+
51
+ parent::setCollection($collection);
52
+ }
53
+
54
+ protected function _prepareColumns()
55
+ {
56
+ if(Mage::helper('manufactures')->getIsEnabled())
57
+ {
58
+ $store = $this->_getStore();
59
+
60
+ $this->addColumnAfter('manufacturer',
61
+ array(
62
+ 'header'=> Mage::helper('catalog')->__('Manufacturer'),
63
+ 'width' => '80px',
64
+ 'index' => 'manufacturer',
65
+ 'type' => 'options',
66
+ 'options' => $this->_getAttributeOptions('manufacturer'),
67
+ ),
68
+ 'sku'
69
+ );
70
+
71
+ $this->addColumnAfter('manufacturer_profit',
72
+ array(
73
+ 'header'=> Mage::helper('catalog')->__('Commission'),
74
+ 'width' => '80px',
75
+ 'index' => 'manufacturer_profit',
76
+ 'sortable' => false,
77
+ 'type' => 'number',
78
+ 'frame_callback' => array($this, 'callbackProfit'),
79
+ 'filter_condition_callback' => array($this, 'callbackFilterProfit')
80
+ ),
81
+ 'manufacturer'
82
+ );
83
+
84
+ $this->addColumnAfter('gross_price',
85
+ array(
86
+ 'header'=> Mage::helper('catalog')->__('Gross Price'),
87
+ 'type' => 'price',
88
+ 'sortable' => false,
89
+ 'currency_code' => $store->getBaseCurrency()->getCode(),
90
+ 'index' => 'gross_price',
91
+ 'frame_callback' => array($this, 'callbackGrossPrice'),
92
+ 'filter_condition_callback' => array($this, 'callbackFilterGrossPrice')
93
+ ),
94
+ 'price'
95
+ );
96
+ }
97
+ return parent::_prepareColumns();
98
+ }
99
+
100
+ public function callbackProfit($value, $row, $column, $isExport){
101
+ $mInfo = Mage::getModel('manufactures/manufactures')->getCollection()->addFilter('option_id', $row->getManufacturer())->getData();
102
+ $mInfo = $mInfo[0];
103
+
104
+ if($mInfo["profit_value"] == NULL)
105
+ return "";
106
+ else{
107
+ return $mInfo["profit_value"]. (($mInfo["profit"] == 1)?"%":" Fixed");
108
+ }
109
+ }
110
+ protected function callbackFilterProfit($collection, $column)
111
+ {
112
+ $value = $column->getFilter()->getValue();
113
+ if ($value == null) {
114
+ return;
115
+ }
116
+ $mcollections = Mage::getModel('manufactures/manufactures')->getCollection();
117
+ $mcollections->addFieldToFilter('profit_value', array('gteq' =>$value["from"]));
118
+ $mcollections->addFieldToFilter('profit_value', array('lteq' =>$value["to"]));
119
+
120
+ $productIds = array();
121
+ foreach ($mcollections as $mcollection) {
122
+ $productCollections = Mage::getModel('catalog/product')->getCollection();
123
+ $productCollections->addFieldToFilter('manufacturer', array('eq' =>$mcollection->getOptionId()));
124
+ foreach ($productCollections as $productCollection) {
125
+ $productIds[] = $productCollection->getId();
126
+ }
127
+ }
128
+ $collection->addFieldToFilter('entity_id', array('in' => $productIds));
129
+ }
130
+
131
+ public function callbackGrossPrice($value, $row, $column, $isExport){
132
+
133
+ $mInfo = Mage::getModel('manufactures/manufactures')->getCollection()->addFilter('option_id', $row->getManufacturer())->getData();
134
+ $mInfo = $mInfo[0];
135
+
136
+ if($mInfo["profit_value"] == NULL)
137
+ if($row->getPrice() == NULL)
138
+ return ;
139
+ else
140
+ return Mage::helper('core')->currency($row->getPrice(), true, false);
141
+ else{
142
+ $price = $row->getPrice();
143
+
144
+ if($mInfo["profit"] == 1){
145
+ $totolPrice = ($price * $mInfo["profit_value"])/100;
146
+ $grossPrice = ($price + $totolPrice);
147
+ }else{
148
+ $grossPrice = ($price + $mInfo["profit_value"]);
149
+ }
150
+
151
+ return Mage::helper('core')->currency($grossPrice, true, false);
152
+ }
153
+ }
154
+ protected function callbackFilterGrossPrice($collection, $column)
155
+ {
156
+ $value = $column->getFilter()->getValue();
157
+
158
+ if ($value == null) {
159
+ return;
160
+ }
161
+ }
162
+
163
+ protected function _getAttributeOptions($attribute_code)
164
+ {
165
+ $attribute = Mage::getModel('eav/config')->getAttribute('catalog_product', $attribute_code);
166
+ $options = array();
167
+ foreach( $attribute->getSource()->getAllOptions(true, true) as $option ) {
168
+ if($option['value'] != ""){
169
+ $options[$option['value']] = $option['label'];
170
+ }
171
+ }
172
+ return $options;
173
+ }
174
+ }
app/code/community/Phxsolution/Manufactures/Block/Adminhtml/Manufactures.php ADDED
@@ -0,0 +1,38 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /*
3
+ /**
4
+ * PHXSolution Manufactures Commission Manager
5
+ *
6
+ * NOTICE OF LICENSE
7
+ *
8
+ * This source file is subject to the Open Software License (OSL 3.0)
9
+ * that is bundled with this package in the file LICENSE.txt.
10
+ * It is also available through the world-wide-web at this URL:
11
+ * http://opensource.org/licenses/osl-3.0.php
12
+ * If you did not receive a copy of the license and are unable to
13
+ * obtain it through the world-wide-web, please send an email
14
+ * to license@magentocommerce.com so you can be sent a copy immediately.
15
+ *
16
+ * Original code copyright (c) 2008 Irubin Consulting Inc. DBA Varien
17
+ *
18
+ * @category Manufactures Block
19
+ * @package Phxsolution_Manufactures
20
+ * @author Prakash Vaniya
21
+ * @contact contact@phxsolution.com
22
+ * @site www.phxsolution.com
23
+ * @copyright Copyright (c) 2014 PHXSolution Manufactures
24
+ * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
25
+ */
26
+ ?>
27
+ <?php
28
+ class Phxsolution_Manufactures_Block_Adminhtml_Manufactures extends Mage_Adminhtml_Block_Widget_Grid_Container
29
+ {
30
+ public function __construct()
31
+ {
32
+ $this->_controller = 'adminhtml_manufactures';
33
+ $this->_blockGroup = 'manufactures';
34
+ $this->_headerText = Mage::helper('manufactures')->__('Manufacturers List');
35
+ $this->_addButtonLabel = Mage::helper('manufactures')->__('Add Manufacturer');
36
+ parent::__construct();
37
+ }
38
+ }
app/code/community/Phxsolution/Manufactures/Block/Adminhtml/Manufactures/Edit.php ADDED
@@ -0,0 +1,74 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /*
3
+ /**
4
+ * PHXSolution Manufactures Commission Manager
5
+ *
6
+ * NOTICE OF LICENSE
7
+ *
8
+ * This source file is subject to the Open Software License (OSL 3.0)
9
+ * that is bundled with this package in the file LICENSE.txt.
10
+ * It is also available through the world-wide-web at this URL:
11
+ * http://opensource.org/licenses/osl-3.0.php
12
+ * If you did not receive a copy of the license and are unable to
13
+ * obtain it through the world-wide-web, please send an email
14
+ * to license@magentocommerce.com so you can be sent a copy immediately.
15
+ *
16
+ * Original code copyright (c) 2008 Irubin Consulting Inc. DBA Varien
17
+ *
18
+ * @category Manufactures Block
19
+ * @package Phxsolution_Manufactures
20
+ * @author Prakash Vaniya
21
+ * @contact contact@phxsolution.com
22
+ * @site www.phxsolution.com
23
+ * @copyright Copyright (c) 2014 PHXSolution Manufactures
24
+ * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
25
+ */
26
+ ?>
27
+ <?php
28
+ class Phxsolution_Manufactures_Block_Adminhtml_Manufactures_Edit extends Mage_Adminhtml_Block_Widget_Form_Container
29
+ {
30
+ public function __construct()
31
+ {
32
+ parent::__construct();
33
+
34
+ $this->_objectId = 'id';
35
+ $this->_blockGroup = 'manufactures';
36
+ $this->_controller = 'adminhtml_manufactures';
37
+
38
+ $this->_updateButton('save', 'label', Mage::helper('manufactures')->__('Save'));
39
+ $this->_updateButton('delete', 'label', Mage::helper('manufactures')->__('Delete'));
40
+
41
+ $this->_addButton('saveandcontinue', array(
42
+ 'label' => Mage::helper('adminhtml')->__('Save And Continue Edit'),
43
+ 'onclick' => 'saveAndContinueEdit()',
44
+ 'class' => 'save',
45
+ ), -100);
46
+
47
+ $this->_formScripts[] = "
48
+ function toggleEditor() {
49
+ if (tinyMCE.getInstanceById('manufactures_content') == null) {
50
+ tinyMCE.execCommand('mceAddControl', false, 'manufactures_content');
51
+ } else {
52
+ tinyMCE.execCommand('mceRemoveControl', false, 'manufactures_content');
53
+ }
54
+ }
55
+
56
+ function saveAndContinueEdit(){
57
+ editForm.submit($('edit_form').action+'back/edit/');
58
+ }
59
+ ";
60
+ }
61
+
62
+ public function getHeaderText()
63
+ {
64
+ $manufacturesModel = Mage::getModel('manufactures/manufactures')->load($this->getRequest()->getParam('id'));
65
+ $manufacturesId = $manufacturesModel->getOptionId();
66
+ $manufacturesLabel = Mage::helper('manufactures')->getManufacturesLabel($manufacturesId);
67
+
68
+ if( Mage::registry('manufactures_data') && Mage::registry('manufactures_data')->getId() ) {
69
+ return Mage::helper('manufactures')->__("Edit Manufacturer '%s'", $manufacturesLabel);
70
+ } else {
71
+ return Mage::helper('manufactures')->__('Add Manufacturer');
72
+ }
73
+ }
74
+ }
app/code/community/Phxsolution/Manufactures/Block/Adminhtml/Manufactures/Edit/Form.php ADDED
@@ -0,0 +1,44 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /*
3
+ /**
4
+ * PHXSolution Manufactures Commission Manager
5
+ *
6
+ * NOTICE OF LICENSE
7
+ *
8
+ * This source file is subject to the Open Software License (OSL 3.0)
9
+ * that is bundled with this package in the file LICENSE.txt.
10
+ * It is also available through the world-wide-web at this URL:
11
+ * http://opensource.org/licenses/osl-3.0.php
12
+ * If you did not receive a copy of the license and are unable to
13
+ * obtain it through the world-wide-web, please send an email
14
+ * to license@magentocommerce.com so you can be sent a copy immediately.
15
+ *
16
+ * Original code copyright (c) 2008 Irubin Consulting Inc. DBA Varien
17
+ *
18
+ * @category Manufactures Block
19
+ * @package Phxsolution_Manufactures
20
+ * @author Prakash Vaniya
21
+ * @contact contact@phxsolution.com
22
+ * @site www.phxsolution.com
23
+ * @copyright Copyright (c) 2014 PHXSolution Manufactures
24
+ * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
25
+ */
26
+ ?>
27
+ <?php
28
+ class Phxsolution_Manufactures_Block_Adminhtml_Manufactures_Edit_Form extends Mage_Adminhtml_Block_Widget_Form
29
+ {
30
+ protected function _prepareForm()
31
+ {
32
+ $form = new Varien_Data_Form(array(
33
+ 'id' => 'edit_form',
34
+ 'action' => $this->getUrl('*/*/save', array('id' => $this->getRequest()->getParam('id'))),
35
+ 'method' => 'post',
36
+ 'enctype' => 'multipart/form-data'
37
+ )
38
+ );
39
+
40
+ $form->setUseContainer(true);
41
+ $this->setForm($form);
42
+ return parent::_prepareForm();
43
+ }
44
+ }
app/code/community/Phxsolution/Manufactures/Block/Adminhtml/Manufactures/Edit/Tab/Form.php ADDED
@@ -0,0 +1,88 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /*
3
+ /**
4
+ * PHXSolution Manufactures Commission Manager
5
+ *
6
+ * NOTICE OF LICENSE
7
+ *
8
+ * This source file is subject to the Open Software License (OSL 3.0)
9
+ * that is bundled with this package in the file LICENSE.txt.
10
+ * It is also available through the world-wide-web at this URL:
11
+ * http://opensource.org/licenses/osl-3.0.php
12
+ * If you did not receive a copy of the license and are unable to
13
+ * obtain it through the world-wide-web, please send an email
14
+ * to license@magentocommerce.com so you can be sent a copy immediately.
15
+ *
16
+ * Original code copyright (c) 2008 Irubin Consulting Inc. DBA Varien
17
+ *
18
+ * @category Manufactures Block
19
+ * @package Phxsolution_Manufactures
20
+ * @author Prakash Vaniya
21
+ * @contact contact@phxsolution.com
22
+ * @site www.phxsolution.com
23
+ * @copyright Copyright (c) 2014 PHXSolution Manufactures
24
+ * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
25
+ */
26
+ ?>
27
+ <?php
28
+ class Phxsolution_Manufactures_Block_Adminhtml_Manufactures_Edit_Tab_Form extends Mage_Adminhtml_Block_Widget_Form
29
+ {
30
+ protected function _prepareForm()
31
+ {
32
+ $form = new Varien_Data_Form();
33
+ $this->setForm($form);
34
+ $fieldset = $form->addFieldset('manufactures_form', array('legend'=>Mage::helper('manufactures')->__('Manufacturer information')));
35
+
36
+ $AttributeInfo = Mage::getSingleton('manufactures/manufactures')->getAttributeInfo('manufacturer');
37
+
38
+ $fieldset->addField('attribute_id', 'hidden', array(
39
+ 'name' => 'attribute_id',
40
+ 'value' => $AttributeInfo["attribute_id"],
41
+ ));
42
+ $form->setValues(Mage::registry('manufactures_data')->setData("attribute_id",$AttributeInfo["attribute_id"]));
43
+
44
+ $fieldset->addField('option_id', 'select', array(
45
+ 'label' => Mage::helper('manufactures')->__('Name'),
46
+ 'class' => 'validate-select',
47
+ 'required' => true,
48
+ 'name' => 'option_id',
49
+ 'values' => Mage::getSingleton('manufactures/manufactures')->getAttributeOptions('manufacturer'),
50
+ ));
51
+
52
+ $fieldset->addField('profit_value', 'text', array(
53
+ 'label' => Mage::helper('manufactures')->__('Profit Value'),
54
+ 'class' => 'required-entry validate-digits',
55
+ 'required' => true,
56
+ 'name' => 'profit_value',
57
+ 'maxlength' => '2',
58
+
59
+ ));
60
+
61
+ $fieldset->addField('profit', 'select', array(
62
+ 'label' => Mage::helper('manufactures')->__('Profit In'),
63
+ 'name' => 'profit',
64
+ 'values' => Mage::getSingleton('manufactures/profit')->getOptionArray(),
65
+ ));
66
+
67
+ $fieldset->addField('image', 'image', array(
68
+ 'label' => Mage::helper('manufactures')->__('Logo'),
69
+ 'name' => 'image',
70
+ 'note' => '(*.jpg, *.png, *.gif)',
71
+ ));
72
+ $fieldset->addField('note', 'text', array(
73
+ 'label' => Mage::helper('manufactures')->__('note'),
74
+ 'required' => false,
75
+ 'name' => 'note',
76
+ ));
77
+
78
+ if ( Mage::getSingleton('adminhtml/session')->getManufacturesData() )
79
+ {
80
+ $form->setValues(Mage::getSingleton('adminhtml/session')->getManufacturesData());
81
+ Mage::getSingleton('adminhtml/session')->setManufacturesData(null);
82
+ } elseif ( Mage::registry('manufactures_data') ) {
83
+ $form->setValues(Mage::registry('manufactures_data')->getData());
84
+ }
85
+
86
+ return parent::_prepareForm();
87
+ }
88
+ }
app/code/community/Phxsolution/Manufactures/Block/Adminhtml/Manufactures/Edit/Tabs.php ADDED
@@ -0,0 +1,48 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /*
3
+ /**
4
+ * PHXSolution Manufactures Commission Manager
5
+ *
6
+ * NOTICE OF LICENSE
7
+ *
8
+ * This source file is subject to the Open Software License (OSL 3.0)
9
+ * that is bundled with this package in the file LICENSE.txt.
10
+ * It is also available through the world-wide-web at this URL:
11
+ * http://opensource.org/licenses/osl-3.0.php
12
+ * If you did not receive a copy of the license and are unable to
13
+ * obtain it through the world-wide-web, please send an email
14
+ * to license@magentocommerce.com so you can be sent a copy immediately.
15
+ *
16
+ * Original code copyright (c) 2008 Irubin Consulting Inc. DBA Varien
17
+ *
18
+ * @category Manufactures Block
19
+ * @package Phxsolution_Manufactures
20
+ * @author Prakash Vaniya
21
+ * @contact contact@phxsolution.com
22
+ * @site www.phxsolution.com
23
+ * @copyright Copyright (c) 2014 PHXSolution Manufactures
24
+ * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
25
+ */
26
+ ?>
27
+ <?php
28
+ class Phxsolution_Manufactures_Block_Adminhtml_Manufactures_Edit_Tabs extends Mage_Adminhtml_Block_Widget_Tabs
29
+ {
30
+ public function __construct()
31
+ {
32
+ parent::__construct();
33
+ $this->setId('manufactures_tabs');
34
+ $this->setDestElementId('edit_form');
35
+ $this->setName(Mage::helper('manufactures')->__('Manufacturer Information'));
36
+ }
37
+
38
+ protected function _beforeToHtml()
39
+ {
40
+ $this->addTab('form_section', array(
41
+ 'label' => Mage::helper('manufactures')->__('Manufacturer Information'),
42
+ 'title' => Mage::helper('manufactures')->__('Manufacturer Information'),
43
+ 'content' => $this->getLayout()->createBlock('manufactures/adminhtml_manufactures_edit_tab_form')->toHtml(),
44
+ ));
45
+
46
+ return parent::_beforeToHtml();
47
+ }
48
+ }
app/code/community/Phxsolution/Manufactures/Block/Adminhtml/Manufactures/Grid.php ADDED
@@ -0,0 +1,151 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /*
3
+ /**
4
+ * PHXSolution Manufactures Commission Manager
5
+ *
6
+ * NOTICE OF LICENSE
7
+ *
8
+ * This source file is subject to the Open Software License (OSL 3.0)
9
+ * that is bundled with this package in the file LICENSE.txt.
10
+ * It is also available through the world-wide-web at this URL:
11
+ * http://opensource.org/licenses/osl-3.0.php
12
+ * If you did not receive a copy of the license and are unable to
13
+ * obtain it through the world-wide-web, please send an email
14
+ * to license@magentocommerce.com so you can be sent a copy immediately.
15
+ *
16
+ * Original code copyright (c) 2008 Irubin Consulting Inc. DBA Varien
17
+ *
18
+ * @category Manufactures Block
19
+ * @package Phxsolution_Manufactures
20
+ * @author Prakash Vaniya
21
+ * @contact contact@phxsolution.com
22
+ * @site www.phxsolution.com
23
+ * @copyright Copyright (c) 2014 PHXSolution Manufactures
24
+ * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
25
+ */
26
+ ?>
27
+ <?php
28
+ class Phxsolution_Manufactures_Block_Adminhtml_Manufactures_Grid extends Mage_Adminhtml_Block_Widget_Grid
29
+ {
30
+ public function __construct()
31
+ {
32
+ parent::__construct();
33
+ $this->setId('manufacturesGrid');
34
+ $this->setDefaultSort('manufactures_id');
35
+ $this->setDefaultDir('ASC');
36
+ $this->setSaveParametersInSession(true);
37
+ }
38
+
39
+ protected function _prepareCollection()
40
+ {
41
+ $collection = Mage::getModel('manufactures/manufactures')->getCollection();
42
+ $this->setCollection($collection);
43
+ return parent::_prepareCollection();
44
+ }
45
+
46
+ protected function _prepareColumns()
47
+ {
48
+ $this->addColumn('manufactures_id', array(
49
+ 'header' => Mage::helper('manufactures')->__('ID'),
50
+ 'align' =>'right',
51
+ 'width' => '50px',
52
+ 'index' => 'manufactures_id',
53
+ ));
54
+
55
+ $this->addColumn('option_id', array(
56
+ 'header' => Mage::helper('manufactures')->__('Name'),
57
+ 'align' =>'left',
58
+ 'index' => 'option_id',
59
+ 'type' => 'options',
60
+ 'options' => Mage::getSingleton('manufactures/manufactures')->getAttributeOptions('manufacturer'),
61
+ ));
62
+
63
+
64
+ $this->addColumn('image', array(
65
+ 'header' => Mage::helper('manufactures')->__('Logo'),
66
+ 'align' =>'left',
67
+ "width" => "80px",
68
+ 'index' => 'image',
69
+ 'renderer' => 'manufactures/adminhtml_manufactures_renderer_image'
70
+ ));
71
+ $this->addColumn('note', array(
72
+ 'header' => Mage::helper('manufactures')->__('Note'),
73
+ 'index' => 'note',
74
+ ));
75
+
76
+ $this->addColumn('profit_value', array(
77
+ 'header' => Mage::helper('manufactures')->__('Profit Value'),
78
+ 'align' =>'left',
79
+ 'width' => '110px',
80
+ 'index' => 'profit_value',
81
+ ));
82
+
83
+ $this->addColumn('profit', array(
84
+ 'header' => Mage::helper('manufactures')->__('Profit In'),
85
+ 'align' => 'left',
86
+ 'width' => '110px',
87
+ 'index' => 'profit',
88
+ 'type' => 'options',
89
+ 'options' => Mage::getSingleton('manufactures/profit')->getOptionArray()
90
+ ));
91
+
92
+ $this->addColumn('action',
93
+ array(
94
+ 'header' => Mage::helper('manufactures')->__('Action'),
95
+ 'width' => '100',
96
+ 'type' => 'action',
97
+ 'getter' => 'getId',
98
+ 'actions' => array(
99
+ array(
100
+ 'caption' => Mage::helper('manufactures')->__('Edit'),
101
+ 'url' => array('base'=> '*/*/edit'),
102
+ 'field' => 'id'
103
+ )
104
+ ),
105
+ 'filter' => false,
106
+ 'sortable' => false,
107
+ 'index' => 'stores',
108
+ 'is_system' => true,
109
+ ));
110
+
111
+ //$this->addExportType('*/*/exportCsv', Mage::helper('manufactures')->__('CSV'));
112
+ //$this->addExportType('*/*/exportXml', Mage::helper('manufactures')->__('XML'));
113
+
114
+ return parent::_prepareColumns();
115
+ }
116
+
117
+ protected function _prepareMassaction()
118
+ {
119
+ $this->setMassactionIdField('manufactures_id');
120
+ $this->getMassactionBlock()->setFormFieldName('manufactures');
121
+
122
+ $this->getMassactionBlock()->addItem('delete', array(
123
+ 'label' => Mage::helper('manufactures')->__('Delete'),
124
+ 'url' => $this->getUrl('*/*/massDelete'),
125
+ 'confirm' => Mage::helper('manufactures')->__('Are you sure?')
126
+ ));
127
+
128
+ $profits = Mage::getSingleton('manufactures/profit')->getOptionArray();
129
+
130
+ array_unshift($profits, array('label'=>'', 'value'=>''));
131
+ $this->getMassactionBlock()->addItem('profit', array(
132
+ 'label'=> Mage::helper('manufactures')->__('Change Profit Type'),
133
+ 'url' => $this->getUrl('*/*/massProfit', array('_current'=>true)),
134
+ 'additional' => array(
135
+ 'visibility' => array(
136
+ 'name' => 'profit',
137
+ 'type' => 'select',
138
+ 'class' => 'required-entry',
139
+ 'label' => Mage::helper('manufactures')->__('Profit'),
140
+ 'values' => $profits
141
+ )
142
+ )
143
+ ));
144
+ return $this;
145
+ }
146
+
147
+ public function getRowUrl($row)
148
+ {
149
+ return $this->getUrl('*/*/edit', array('id' => $row->getId()));
150
+ }
151
+ }
app/code/community/Phxsolution/Manufactures/Block/Adminhtml/Manufactures/Renderer/Image.php ADDED
@@ -0,0 +1,48 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /*
3
+ /**
4
+ * PHXSolution Manufactures Commission Manager
5
+ *
6
+ * NOTICE OF LICENSE
7
+ *
8
+ * This source file is subject to the Open Software License (OSL 3.0)
9
+ * that is bundled with this package in the file LICENSE.txt.
10
+ * It is also available through the world-wide-web at this URL:
11
+ * http://opensource.org/licenses/osl-3.0.php
12
+ * If you did not receive a copy of the license and are unable to
13
+ * obtain it through the world-wide-web, please send an email
14
+ * to license@magentocommerce.com so you can be sent a copy immediately.
15
+ *
16
+ * Original code copyright (c) 2008 Irubin Consulting Inc. DBA Varien
17
+ *
18
+ * @category Manufactures Block
19
+ * @package Phxsolution_Manufactures
20
+ * @author Prakash Vaniya
21
+ * @contact contact@phxsolution.com
22
+ * @site www.phxsolution.com
23
+ * @copyright Copyright (c) 2014 PHXSolution Manufactures
24
+ * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
25
+ */
26
+ ?>
27
+ <?php
28
+ class Phxsolution_Manufactures_Block_Adminhtml_Manufactures_Renderer_Image extends Mage_Adminhtml_Block_Widget_Grid_Column_Renderer_Abstract{
29
+
30
+ public function render(Varien_Object $row)
31
+ {
32
+ $noImage = Mage::helper('manufactures')->getNoImage();
33
+ $getImage = $row->getData($this->getColumn()->getIndex());
34
+ $finalImage = ($getImage) ? Mage::getBaseUrl('media').$getImage : Mage::getBaseUrl('media').$noImage;
35
+
36
+ if($noImage || $getImage)
37
+ {
38
+ $html = '<img ';
39
+ $html .= 'id="' . $this->getColumn()->getId() . '" ';
40
+ $html .= 'src="'. $finalImage . '"';
41
+ $html .= 'class="grid-image ' . $this->getColumn()->getInlineCss().'"';
42
+ $html .= 'style="width:75px;height:75px"' . '"/>';
43
+ return $html;
44
+ }
45
+ else
46
+ return '';
47
+ }
48
+ }
app/code/community/Phxsolution/Manufactures/Block/Manufactures.php ADDED
@@ -0,0 +1,41 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /*
3
+ /**
4
+ * PHXSolution Manufactures Commission Manager
5
+ *
6
+ * NOTICE OF LICENSE
7
+ *
8
+ * This source file is subject to the Open Software License (OSL 3.0)
9
+ * that is bundled with this package in the file LICENSE.txt.
10
+ * It is also available through the world-wide-web at this URL:
11
+ * http://opensource.org/licenses/osl-3.0.php
12
+ * If you did not receive a copy of the license and are unable to
13
+ * obtain it through the world-wide-web, please send an email
14
+ * to license@magentocommerce.com so you can be sent a copy immediately.
15
+ *
16
+ * Original code copyright (c) 2008 Irubin Consulting Inc. DBA Varien
17
+ *
18
+ * @category Manufactures Block
19
+ * @package Phxsolution_Manufactures
20
+ * @author Prakash Vaniya
21
+ * @contact contact@phxsolution.com
22
+ * @site www.phxsolution.com
23
+ * @copyright Copyright (c) 2014 PHXSolution Manufactures
24
+ * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
25
+ */
26
+ ?>
27
+ <?php
28
+ class Phxsolution_Manufactures_Block_Manufactures extends Mage_Core_Block_Template
29
+ {
30
+ public function _prepareLayout()
31
+ {
32
+ return parent::_prepareLayout();
33
+ }
34
+ public function getManufactures()
35
+ {
36
+ if (!$this->hasData('manufactures')) {
37
+ $this->setData('manufactures', Mage::registry('manufactures'));
38
+ }
39
+ return $this->getData('manufactures');
40
+ }
41
+ }
app/code/community/Phxsolution/Manufactures/Helper/Data.php ADDED
@@ -0,0 +1,153 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /*
3
+ /**
4
+ * PHXSolution Manufactures Commission Manager
5
+ *
6
+ * NOTICE OF LICENSE
7
+ *
8
+ * This source file is subject to the Open Software License (OSL 3.0)
9
+ * that is bundled with this package in the file LICENSE.txt.
10
+ * It is also available through the world-wide-web at this URL:
11
+ * http://opensource.org/licenses/osl-3.0.php
12
+ * If you did not receive a copy of the license and are unable to
13
+ * obtain it through the world-wide-web, please send an email
14
+ * to license@magentocommerce.com so you can be sent a copy immediately.
15
+ *
16
+ * Original code copyright (c) 2008 Irubin Consulting Inc. DBA Varien
17
+ *
18
+ * @category Manufactures Helper
19
+ * @package Phxsolution_Manufactures
20
+ * @author Prakash Vaniya
21
+ * @contact contact@phxsolution.com
22
+ * @site www.phxsolution.com
23
+ * @copyright Copyright (c) 2014 PHXSolution Manufactures
24
+ * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
25
+ */
26
+ ?>
27
+ <?php
28
+ class Phxsolution_Manufactures_Helper_Data extends Mage_Core_Helper_Abstract
29
+ {
30
+ public function getIsEnabled()
31
+ {
32
+ return Mage::getStoreConfig('manufactures_section/settings/enabled');
33
+ }
34
+ public function getNoImage()
35
+ {
36
+ $noImage = 'manufactures/logos/'.Mage::getStoreConfig('manufactures_section/settings/logo');
37
+ if(Mage::getStoreConfig('manufactures_section/settings/logo'))
38
+ return $noImage;
39
+ return '';
40
+ }
41
+ public function getManufacturesLabel($manufactures_id)
42
+ {
43
+ $attribute = Mage::getModel('eav/config')->getAttribute('catalog_product', 'manufacturer');
44
+ $allOptions = $attribute->getSource()->getAllOptions(true, true);
45
+ foreach ($allOptions as $key => $value)
46
+ {
47
+ if($manufactures_id==$value['value'])
48
+ return $value['label'];
49
+ }
50
+ }
51
+ public function checkImage($image)
52
+ {
53
+ //checks if the file is a browser compatible image
54
+ $mimes = array('image/gif','image/jpeg','image/pjpeg','image/png');
55
+ //get mime type
56
+ $mime = getimagesize($image);
57
+ $mime = $mime['mime'];
58
+
59
+ $extensions = array('jpg','png','gif','jpeg');
60
+ $extension = strtolower( pathinfo( $image, PATHINFO_EXTENSION ) );
61
+
62
+ if ( in_array( $extension , $extensions ) AND in_array( $mime, $mimes ) )
63
+ return true;
64
+ else
65
+ return false;
66
+ }
67
+ public function installSampleData()
68
+ {
69
+ // installs default data to manufactures list
70
+ $manufactures = array(
71
+ array(
72
+ 'attribute_id' => 102,
73
+ 'option_id' => 1,
74
+ 'profit_value' => 10,
75
+ 'profit' => 1,
76
+ 'image' => '',
77
+ 'note' => 'Test note.',
78
+ 'created_time' => now(),
79
+ 'update_time' => now(),
80
+ ),
81
+ array(
82
+ 'attribute_id' => 102,
83
+ 'option_id' => 2,
84
+ 'profit_value' => 10,
85
+ 'profit' => 2,
86
+ 'image' => '',
87
+ 'note' => 'Test note.',
88
+ 'created_time' => now(),
89
+ 'update_time' => now(),
90
+ ),
91
+ );
92
+ foreach ($manufactures as $item) {
93
+ Mage::getModel('manufactures/manufactures')
94
+ ->setData($item)
95
+ ->save();
96
+ }
97
+ }
98
+ public function formatPrice($price)
99
+ {
100
+ $returnPrice = $price;
101
+
102
+ list($first,$decimal) = explode('.', $price);
103
+ if($decimal>0)
104
+ $returnPrice = number_format($price,2);
105
+ else
106
+ $returnPrice = $first;
107
+ return Mage::helper('core')->currency($returnPrice,true,false);
108
+ }
109
+ public function getPriceHtml($_product)
110
+ {
111
+ $price = $_product->getPrice();
112
+ $finalPrice = $_product->getFinalPrice();
113
+ $html = '';
114
+
115
+ if($price>0 || $finalPrice>0)
116
+ {
117
+ $formattedPrice = $this->formatPrice($price);
118
+ $formattedFinalPrice = $this->formatPrice($finalPrice);
119
+
120
+ $html .= '<div class="price-box">';
121
+ if($finalPrice<$price)
122
+ {
123
+ $html .= '<p class="old-price">';
124
+ $html .= '<span class="price-label">Regular Price:</span>';
125
+ $html .= '<span class="price">';
126
+ $html .= $formattedPrice;
127
+ $html .= '</span>';
128
+ $html .= '</p>';
129
+
130
+ $html .= '<p class="special-price">';
131
+ $html .= '<span class="price-label">Special Price:</span>';
132
+ $html .= '<span class="price">';
133
+ $html .= $formattedFinalPrice;
134
+ $html .= '</span>';
135
+ $html .= '</p>';
136
+ }
137
+ elseif($finalPrice>$price)
138
+ {
139
+ $html .= '<span class="regular-price">';
140
+ $html .= '<span class="price">'.$formattedFinalPrice.'</span>';
141
+ $html .= '</span>';
142
+ }
143
+ else
144
+ {
145
+ $html .= '<span class="regular-price">';
146
+ $html .= '<span class="price">'.$formattedPrice.'</span>';
147
+ $html .= '</span>';
148
+ }
149
+ $html .= '</div>';
150
+ }
151
+ return $html;
152
+ }
153
+ }
app/code/community/Phxsolution/Manufactures/Helper/Profit/Data.php ADDED
@@ -0,0 +1,164 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /*
3
+ /**
4
+ * PHXSolution Manufactures Commission Manager
5
+ *
6
+ * NOTICE OF LICENSE
7
+ *
8
+ * This source file is subject to the Open Software License (OSL 3.0)
9
+ * that is bundled with this package in the file LICENSE.txt.
10
+ * It is also available through the world-wide-web at this URL:
11
+ * http://opensource.org/licenses/osl-3.0.php
12
+ * If you did not receive a copy of the license and are unable to
13
+ * obtain it through the world-wide-web, please send an email
14
+ * to license@magentocommerce.com so you can be sent a copy immediately.
15
+ *
16
+ * Original code copyright (c) 2008 Irubin Consulting Inc. DBA Varien
17
+ *
18
+ * @category Manufactures Helper
19
+ * @package Phxsolution_Manufactures
20
+ * @author Prakash Vaniya
21
+ * @contact contact@phxsolution.com
22
+ * @site www.phxsolution.com
23
+ * @copyright Copyright (c) 2014 PHXSolution Manufactures
24
+ * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
25
+ */
26
+ ?>
27
+ <?php
28
+ class Phxsolution_Manufactures_Helper_Profit_Data extends Mage_Tax_Helper_Data
29
+ {
30
+ public function getPrice($product, $price, $includingTax = null, $shippingAddress = null, $billingAddress = null,
31
+ $ctc = null, $store = null, $priceIncludesTax = null
32
+ )
33
+ {
34
+ if (!$price) {
35
+ return $price;
36
+ }
37
+ if(Mage::helper('manufactures')->getIsEnabled())
38
+ {
39
+ if($price == $product->getPrice()){
40
+ $profit = $this->addManufactureProfit($product);
41
+ $price = $price + $profit;
42
+ }
43
+ }
44
+
45
+ $store = Mage::app()->getStore($store);
46
+ if (!$this->needPriceConversion($store)) {
47
+ return $store->roundPrice($price);
48
+ }
49
+ if (is_null($priceIncludesTax)) {
50
+ $priceIncludesTax = $this->priceIncludesTax($store);
51
+ }
52
+
53
+ $percent = $product->getTaxPercent();
54
+ $includingPercent = null;
55
+
56
+ $taxClassId = $product->getTaxClassId();
57
+ if (is_null($percent)) {
58
+ if ($taxClassId) {
59
+ $request = Mage::getSingleton('tax/calculation')
60
+ ->getRateRequest($shippingAddress, $billingAddress, $ctc, $store);
61
+ $percent = Mage::getSingleton('tax/calculation')
62
+ ->getRate($request->setProductClassId($taxClassId));
63
+ }
64
+ }
65
+ if ($taxClassId && $priceIncludesTax) {
66
+ $request = Mage::getSingleton('tax/calculation')->getRateRequest(false, false, false, $store);
67
+ $includingPercent = Mage::getSingleton('tax/calculation')
68
+ ->getRate($request->setProductClassId($taxClassId));
69
+ }
70
+
71
+ if ($percent === false || is_null($percent)) {
72
+ if ($priceIncludesTax && !$includingPercent) {
73
+ return $price;
74
+ }
75
+ }
76
+
77
+ $product->setTaxPercent($percent);
78
+
79
+ if (!is_null($includingTax)) {
80
+ if ($priceIncludesTax) {
81
+ if ($includingTax) {
82
+ /**
83
+ * Recalculate price include tax in case of different rates
84
+ */
85
+ if ($includingPercent != $percent) {
86
+ $price = $this->_calculatePrice($price, $includingPercent, false);
87
+ /**
88
+ * Using regular rounding. Ex:
89
+ * price incl tax = 52.76
90
+ * store tax rate = 19.6%
91
+ * customer tax rate= 19%
92
+ *
93
+ * price excl tax = 52.76 / 1.196 = 44.11371237 ~ 44.11
94
+ * tax = 44.11371237 * 0.19 = 8.381605351 ~ 8.38
95
+ * price incl tax = 52.49531773 ~ 52.50 != 52.49
96
+ *
97
+ * that why we need round prices excluding tax before applying tax
98
+ * this calculation is used for showing prices on catalog pages
99
+ */
100
+ if ($percent != 0) {
101
+ $price = $this->getCalculator()->round($price);
102
+ $price = $this->_calculatePrice($price, $percent, true);
103
+ }
104
+ }
105
+ } else {
106
+ $price = $this->_calculatePrice($price, $includingPercent, false);
107
+ }
108
+ } else {
109
+ if ($includingTax) {
110
+ $price = $this->_calculatePrice($price, $percent, true);
111
+ }
112
+ }
113
+ } else {
114
+ if ($priceIncludesTax) {
115
+ switch ($this->getPriceDisplayType($store)) {
116
+ case Mage_Tax_Model_Config::DISPLAY_TYPE_EXCLUDING_TAX:
117
+ case Mage_Tax_Model_Config::DISPLAY_TYPE_BOTH:
118
+ $price = $this->_calculatePrice($price, $includingPercent, false);
119
+ break;
120
+
121
+ case Mage_Tax_Model_Config::DISPLAY_TYPE_INCLUDING_TAX:
122
+ $price = $this->_calculatePrice($price, $includingPercent, false);
123
+ $price = $this->_calculatePrice($price, $percent, true);
124
+ break;
125
+ }
126
+ } else {
127
+ switch ($this->getPriceDisplayType($store)) {
128
+ case Mage_Tax_Model_Config::DISPLAY_TYPE_INCLUDING_TAX:
129
+ $price = $this->_calculatePrice($price, $percent, true);
130
+ break;
131
+
132
+ case Mage_Tax_Model_Config::DISPLAY_TYPE_BOTH:
133
+ case Mage_Tax_Model_Config::DISPLAY_TYPE_EXCLUDING_TAX:
134
+ break;
135
+ }
136
+ }
137
+ }
138
+ return $store->roundPrice($price);
139
+ }
140
+
141
+ public function addManufactureProfit($product)
142
+ {
143
+ $productInfo = Mage::getModel('catalog/product')->load($product->getId());
144
+ $profit = 0;
145
+ if($productInfo->getManufacturer()){
146
+ $mInfo = Mage::getModel('manufactures/manufactures')->getCollection()->addFilter('option_id', $productInfo->getManufacturer())->getData();
147
+ $mInfo = $mInfo[0];
148
+ $price = $product->getPrice();
149
+ if($mInfo["profit_value"] != NULL){
150
+
151
+ if($mInfo["profit"] == 1){
152
+ $profit = ($price * $mInfo["profit_value"])/100;
153
+ }else{
154
+ $profit = $mInfo["profit_value"];
155
+ }
156
+ return $profit;
157
+ }else{
158
+ return $profit;
159
+ }
160
+ }else{
161
+ return $profit;
162
+ }
163
+ }
164
+ }
app/code/community/Phxsolution/Manufactures/Model/Manufactures.php ADDED
@@ -0,0 +1,54 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /*
3
+ /**
4
+ * PHXSolution Manufactures Commission Manager
5
+ *
6
+ * NOTICE OF LICENSE
7
+ *
8
+ * This source file is subject to the Open Software License (OSL 3.0)
9
+ * that is bundled with this package in the file LICENSE.txt.
10
+ * It is also available through the world-wide-web at this URL:
11
+ * http://opensource.org/licenses/osl-3.0.php
12
+ * If you did not receive a copy of the license and are unable to
13
+ * obtain it through the world-wide-web, please send an email
14
+ * to license@magentocommerce.com so you can be sent a copy immediately.
15
+ *
16
+ * Original code copyright (c) 2008 Irubin Consulting Inc. DBA Varien
17
+ *
18
+ * @category Manufactures Model
19
+ * @package Phxsolution_Manufactures
20
+ * @author Prakash Vaniya
21
+ * @contact contact@phxsolution.com
22
+ * @site www.phxsolution.com
23
+ * @copyright Copyright (c) 2014 PHXSolution Manufactures
24
+ * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
25
+ */
26
+ ?>
27
+ <?php
28
+ class Phxsolution_Manufactures_Model_Manufactures extends Mage_Core_Model_Abstract
29
+ {
30
+ public function _construct()
31
+ {
32
+ parent::_construct();
33
+ $this->_init('manufactures/manufactures');
34
+ }
35
+
36
+ static public function getAttributeInfo($attribute_code)
37
+ {
38
+ $attribute_details = Mage::getSingleton("eav/config")->getAttribute('catalog_product', $attribute_code);
39
+ return $attribute = $attribute_details->getData(); // returns array
40
+ }
41
+
42
+ static public function getAttributeOptions($attribute_code)
43
+ {
44
+ $attribute = Mage::getModel('eav/config')->getAttribute('catalog_product', $attribute_code);
45
+ $options = array();
46
+ $options[""] = "Select Manufacture";
47
+ foreach( $attribute->getSource()->getAllOptions(true, true) as $option ) {
48
+ if($option['value'] != ""){
49
+ $options[$option['value']] = $option['label'];
50
+ }
51
+ }
52
+ return $options;
53
+ }
54
+ }
app/code/community/Phxsolution/Manufactures/Model/Mysql4/Manufactures.php ADDED
@@ -0,0 +1,35 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /*
3
+ /**
4
+ * PHXSolution Manufactures Commission Manager
5
+ *
6
+ * NOTICE OF LICENSE
7
+ *
8
+ * This source file is subject to the Open Software License (OSL 3.0)
9
+ * that is bundled with this package in the file LICENSE.txt.
10
+ * It is also available through the world-wide-web at this URL:
11
+ * http://opensource.org/licenses/osl-3.0.php
12
+ * If you did not receive a copy of the license and are unable to
13
+ * obtain it through the world-wide-web, please send an email
14
+ * to license@magentocommerce.com so you can be sent a copy immediately.
15
+ *
16
+ * Original code copyright (c) 2008 Irubin Consulting Inc. DBA Varien
17
+ *
18
+ * @category Manufactures Model
19
+ * @package Phxsolution_Manufactures
20
+ * @author Prakash Vaniya
21
+ * @contact contact@phxsolution.com
22
+ * @site www.phxsolution.com
23
+ * @copyright Copyright (c) 2014 PHXSolution Manufactures
24
+ * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
25
+ */
26
+ ?>
27
+ <?php
28
+ class Phxsolution_Manufactures_Model_Mysql4_Manufactures extends Mage_Core_Model_Mysql4_Abstract
29
+ {
30
+ public function _construct()
31
+ {
32
+ // Note that the manufactures_id refers to the key field in your database table.
33
+ $this->_init('manufactures/manufactures', 'manufactures_id');
34
+ }
35
+ }
app/code/community/Phxsolution/Manufactures/Model/Mysql4/Manufactures/Collection.php ADDED
@@ -0,0 +1,35 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /*
3
+ /**
4
+ * PHXSolution Manufactures Commission Manager
5
+ *
6
+ * NOTICE OF LICENSE
7
+ *
8
+ * This source file is subject to the Open Software License (OSL 3.0)
9
+ * that is bundled with this package in the file LICENSE.txt.
10
+ * It is also available through the world-wide-web at this URL:
11
+ * http://opensource.org/licenses/osl-3.0.php
12
+ * If you did not receive a copy of the license and are unable to
13
+ * obtain it through the world-wide-web, please send an email
14
+ * to license@magentocommerce.com so you can be sent a copy immediately.
15
+ *
16
+ * Original code copyright (c) 2008 Irubin Consulting Inc. DBA Varien
17
+ *
18
+ * @category Manufactures Model
19
+ * @package Phxsolution_Manufactures
20
+ * @author Prakash Vaniya
21
+ * @contact contact@phxsolution.com
22
+ * @site www.phxsolution.com
23
+ * @copyright Copyright (c) 2014 PHXSolution Manufactures
24
+ * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
25
+ */
26
+ ?>
27
+ <?php
28
+ class Phxsolution_Manufactures_Model_Mysql4_Manufactures_Collection extends Mage_Core_Model_Mysql4_Collection_Abstract
29
+ {
30
+ public function _construct()
31
+ {
32
+ parent::_construct();
33
+ $this->_init('manufactures/manufactures');
34
+ }
35
+ }
app/code/community/Phxsolution/Manufactures/Model/Product.php ADDED
@@ -0,0 +1,31 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /*
3
+ /**
4
+ * PHXSolution Manufactures Commission Manager
5
+ *
6
+ * NOTICE OF LICENSE
7
+ *
8
+ * This source file is subject to the Open Software License (OSL 3.0)
9
+ * that is bundled with this package in the file LICENSE.txt.
10
+ * It is also available through the world-wide-web at this URL:
11
+ * http://opensource.org/licenses/osl-3.0.php
12
+ * If you did not receive a copy of the license and are unable to
13
+ * obtain it through the world-wide-web, please send an email
14
+ * to license@magentocommerce.com so you can be sent a copy immediately.
15
+ *
16
+ * Original code copyright (c) 2008 Irubin Consulting Inc. DBA Varien
17
+ *
18
+ * @category Manufactures Model
19
+ * @package Phxsolution_Manufactures
20
+ * @author Prakash Vaniya
21
+ * @contact contact@phxsolution.com
22
+ * @site www.phxsolution.com
23
+ * @copyright Copyright (c) 2014 PHXSolution Manufactures
24
+ * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
25
+ */
26
+ ?>
27
+ <?php
28
+ class Phxsolution_Manufactures_Model_Product extends Mage_Catalog_Model_Product
29
+ {
30
+
31
+ }
app/code/community/Phxsolution/Manufactures/Model/Product/Type/Configurable/Price.php ADDED
@@ -0,0 +1,167 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /*
3
+ /**
4
+ * PHXSolution Manufactures Commission Manager
5
+ *
6
+ * NOTICE OF LICENSE
7
+ *
8
+ * This source file is subject to the Open Software License (OSL 3.0)
9
+ * that is bundled with this package in the file LICENSE.txt.
10
+ * It is also available through the world-wide-web at this URL:
11
+ * http://opensource.org/licenses/osl-3.0.php
12
+ * If you did not receive a copy of the license and are unable to
13
+ * obtain it through the world-wide-web, please send an email
14
+ * to license@magentocommerce.com so you can be sent a copy immediately.
15
+ *
16
+ * Original code copyright (c) 2008 Irubin Consulting Inc. DBA Varien
17
+ *
18
+ * @category Manufactures Model
19
+ * @package Phxsolution_Manufactures
20
+ * @author Prakash Vaniya
21
+ * @contact contact@phxsolution.com
22
+ * @site www.phxsolution.com
23
+ * @copyright Copyright (c) 2014 PHXSolution Manufactures
24
+ * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
25
+ */
26
+ ?>
27
+ <?php
28
+ class Phxsolution_Manufactures_Model_Product_Type_Configurable_Price extends Mage_Catalog_Model_Product_Type_Configurable_Price
29
+ {
30
+ /**
31
+ * Get product final price
32
+ *
33
+ * @param double $qty
34
+ * @param Mage_Catalog_Model_Product $product
35
+ * @return double
36
+ */
37
+ public function getFinalPrice($qty=null, $product)
38
+ {
39
+ if (is_null($qty) && !is_null($product->getCalculatedFinalPrice())) {
40
+ return $product->getCalculatedFinalPrice();
41
+ }
42
+
43
+ $basePrice = $this->getBasePrice($product, $qty);
44
+ $finalPrice = $basePrice;
45
+ $product->setFinalPrice($finalPrice);
46
+ Mage::dispatchEvent('catalog_product_get_final_price', array('product' => $product, 'qty' => $qty));
47
+ $finalPrice = $product->getData('final_price');
48
+
49
+ $finalPrice += $this->getTotalConfigurableItemsPrice($product, $finalPrice);
50
+ $finalPrice += $this->_applyOptionsPrice($product, $qty, $basePrice) - $basePrice;
51
+ $finalPrice = max(0, $finalPrice);
52
+
53
+ $profit = $this->addManufactureProfit($product);
54
+ $finalPrice = $finalPrice + $profit;
55
+
56
+ $product->setFinalPrice($finalPrice);
57
+ return $finalPrice;
58
+ }
59
+
60
+ /**
61
+ * Get product tier price by qty
62
+ *
63
+ * @param float $qty
64
+ * @param Mage_Catalog_Model_Product $product
65
+ * @return float
66
+ */
67
+ public function getTierPrice($qty = null, $product)
68
+ {
69
+
70
+ $allGroups = Mage_Customer_Model_Group::CUST_GROUP_ALL;
71
+ $prices = $product->getData('tier_price');
72
+ if (is_null($prices)) {
73
+ $attribute = $product->getResource()->getAttribute('tier_price');
74
+ if ($attribute) {
75
+ $attribute->getBackend()->afterLoad($product);
76
+ $prices = $product->getData('tier_price');
77
+ }
78
+ }
79
+
80
+ if (is_null($prices) || !is_array($prices)) {
81
+ if (!is_null($qty)) {
82
+ return $product->getPrice();
83
+ }
84
+ return array(array(
85
+ 'price' => $product->getPrice(),
86
+ 'website_price' => $product->getPrice(),
87
+ 'price_qty' => 1,
88
+ 'cust_group' => $allGroups,
89
+ ));
90
+ }
91
+
92
+ $custGroup = $this->_getCustomerGroupId($product);
93
+ if ($qty) {
94
+ $prevQty = 1;
95
+ $prevPrice = $product->getPrice();
96
+ $prevGroup = $allGroups;
97
+
98
+ foreach ($prices as $price) {
99
+ if ($price['cust_group']!=$custGroup && $price['cust_group']!=$allGroups) {
100
+ // tier not for current customer group nor is for all groups
101
+ continue;
102
+ }
103
+ if ($qty < $price['price_qty']) {
104
+ // tier is higher than product qty
105
+ continue;
106
+ }
107
+ if ($price['price_qty'] < $prevQty) {
108
+ // higher tier qty already found
109
+ continue;
110
+ }
111
+ if ($price['price_qty'] == $prevQty && $prevGroup != $allGroups && $price['cust_group'] == $allGroups) {
112
+ // found tier qty is same as current tier qty but current tier group is ALL_GROUPS
113
+ continue;
114
+ }
115
+ if ($price['website_price'] < $prevPrice) {
116
+ $prevPrice = $price['website_price'];
117
+ $prevQty = $price['price_qty'];
118
+ $prevGroup = $price['cust_group'];
119
+ }
120
+ }
121
+
122
+ return $prevPrice;
123
+ } else {
124
+ $qtyCache = array();
125
+ foreach ($prices as $i => $price) {
126
+ if ($price['cust_group'] != $custGroup && $price['cust_group'] != $allGroups) {
127
+ unset($prices[$i]);
128
+ } else if (isset($qtyCache[$price['price_qty']])) {
129
+ $j = $qtyCache[$price['price_qty']];
130
+ if ($prices[$j]['website_price'] > $price['website_price']) {
131
+ unset($prices[$j]);
132
+ $qtyCache[$price['price_qty']] = $i;
133
+ } else {
134
+ unset($prices[$i]);
135
+ }
136
+ } else {
137
+ $qtyCache[$price['price_qty']] = $i;
138
+ }
139
+ }
140
+ }
141
+ return ($prices) ? $prices : array();
142
+ }
143
+
144
+ public function addManufactureProfit($product)
145
+ {
146
+ $productInfo = Mage::getModel('catalog/product')->load($product->getId());
147
+ $profit = 0;
148
+ if($productInfo->getManufacturer()){
149
+ $mInfo = Mage::getModel('manufactures/manufactures')->getCollection()->addFilter('option_id', $productInfo->getManufacturer())->getData();
150
+ $mInfo = $mInfo[0];
151
+ $price = $product->getPrice();
152
+ if($mInfo["profit_value"] != NULL){
153
+
154
+ if($mInfo["profit"] == 1){
155
+ $profit = ($price * $mInfo["profit_value"])/100;
156
+ }else{
157
+ $profit = $mInfo["profit_value"];
158
+ }
159
+ return $profit;
160
+ }else{
161
+ return $profit;
162
+ }
163
+ }else{
164
+ return $profit;
165
+ }
166
+ }
167
+ }
app/code/community/Phxsolution/Manufactures/Model/Product/Type/Grouped/Price.php ADDED
@@ -0,0 +1,95 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /*
3
+ /**
4
+ * PHXSolution Manufactures Commission Manager
5
+ *
6
+ * NOTICE OF LICENSE
7
+ *
8
+ * This source file is subject to the Open Software License (OSL 3.0)
9
+ * that is bundled with this package in the file LICENSE.txt.
10
+ * It is also available through the world-wide-web at this URL:
11
+ * http://opensource.org/licenses/osl-3.0.php
12
+ * If you did not receive a copy of the license and are unable to
13
+ * obtain it through the world-wide-web, please send an email
14
+ * to license@magentocommerce.com so you can be sent a copy immediately.
15
+ *
16
+ * Original code copyright (c) 2008 Irubin Consulting Inc. DBA Varien
17
+ *
18
+ * @category Manufactures Model
19
+ * @package Phxsolution_Manufactures
20
+ * @author Prakash Vaniya
21
+ * @contact contact@phxsolution.com
22
+ * @site www.phxsolution.com
23
+ * @copyright Copyright (c) 2014 PHXSolution Manufactures
24
+ * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
25
+ */
26
+ ?>
27
+ <?php
28
+ class Phxsolution_Manufactures_Model_Product_Type_Grouped_Price extends Mage_Catalog_Model_Product_Type_Grouped_Price
29
+ {
30
+ /**
31
+ * Returns product final price depending on options chosen
32
+ *
33
+ * @param double $qty
34
+ * @param Mage_Catalog_Model_Product $product
35
+ * @return double
36
+ */
37
+ public function getFinalPrice($qty=null, $product)
38
+ {
39
+ if (is_null($qty) && !is_null($product->getCalculatedFinalPrice())) {
40
+ return $product->getCalculatedFinalPrice();
41
+ }
42
+
43
+ $finalPrice = parent::getFinalPrice($qty, $product);
44
+ if ($product->hasCustomOptions()) {
45
+ /* @var $typeInstance Mage_Catalog_Model_Product_Type_Grouped */
46
+ $typeInstance = $product->getTypeInstance(true);
47
+ $associatedProducts = $typeInstance->setStoreFilter($product->getStore(), $product)
48
+ ->getAssociatedProducts($product);
49
+ foreach ($associatedProducts as $childProduct) {
50
+ /* @var $childProduct Mage_Catalog_Model_Product */
51
+ $option = $product->getCustomOption('associated_product_' . $childProduct->getId());
52
+ if (!$option) {
53
+ continue;
54
+ }
55
+ $childQty = $option->getValue();
56
+ if (!$childQty) {
57
+ continue;
58
+ }
59
+ $finalPrice += $childProduct->getFinalPrice($childQty) * $childQty;
60
+ }
61
+ }
62
+
63
+ $profit = $this->addManufactureProfit($product);
64
+ $finalPrice = $finalPrice + $profit;
65
+
66
+ $product->setFinalPrice($finalPrice);
67
+ Mage::dispatchEvent('catalog_product_type_grouped_price', array('product' => $product));
68
+
69
+ return max(0, $product->getData('final_price'));
70
+ }
71
+
72
+ public function addManufactureProfit($product)
73
+ {
74
+ $productInfo = Mage::getModel('catalog/product')->load($product->getId());
75
+ $profit = 0;
76
+ if($productInfo->getManufacturer()){
77
+ $mInfo = Mage::getModel('manufactures/manufactures')->getCollection()->addFilter('option_id', $productInfo->getManufacturer())->getData();
78
+ $mInfo = $mInfo[0];
79
+ $price = $product->getPrice();
80
+ if($mInfo["profit_value"] != NULL){
81
+
82
+ if($mInfo["profit"] == 1){
83
+ $profit = ($price * $mInfo["profit_value"])/100;
84
+ }else{
85
+ $profit = $mInfo["profit_value"];
86
+ }
87
+ return $profit;
88
+ }else{
89
+ return $profit;
90
+ }
91
+ }else{
92
+ return $profit;
93
+ }
94
+ }
95
+ }
app/code/community/Phxsolution/Manufactures/Model/Product/Type/Price.php ADDED
@@ -0,0 +1,167 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /*
3
+ /**
4
+ * PHXSolution Manufactures Commission Manager
5
+ *
6
+ * NOTICE OF LICENSE
7
+ *
8
+ * This source file is subject to the Open Software License (OSL 3.0)
9
+ * that is bundled with this package in the file LICENSE.txt.
10
+ * It is also available through the world-wide-web at this URL:
11
+ * http://opensource.org/licenses/osl-3.0.php
12
+ * If you did not receive a copy of the license and are unable to
13
+ * obtain it through the world-wide-web, please send an email
14
+ * to license@magentocommerce.com so you can be sent a copy immediately.
15
+ *
16
+ * Original code copyright (c) 2008 Irubin Consulting Inc. DBA Varien
17
+ *
18
+ * @category Manufactures Model
19
+ * @package Phxsolution_Manufactures
20
+ * @author Prakash Vaniya
21
+ * @contact contact@phxsolution.com
22
+ * @site www.phxsolution.com
23
+ * @copyright Copyright (c) 2014 PHXSolution Manufactures
24
+ * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
25
+ */
26
+ ?>
27
+ <?php
28
+ class Phxsolution_Manufactures_Model_Product_Type_Price extends Mage_Catalog_Model_Product_Type_Price
29
+ {
30
+ /**
31
+ * Retrieve product final price
32
+ *
33
+ * @param float|null $qty
34
+ * @param Mage_Catalog_Model_Product $product
35
+ * @return float
36
+ */
37
+ public function getFinalPrice($qty = null, $product)
38
+ {
39
+ if (is_null($qty) && !is_null($product->getCalculatedFinalPrice())) {
40
+ return $product->getCalculatedFinalPrice();
41
+ }
42
+
43
+ $finalPrice = $this->getBasePrice($product, $qty);
44
+ $product->setFinalPrice($finalPrice);
45
+
46
+ Mage::dispatchEvent('catalog_product_get_final_price', array('product' => $product, 'qty' => $qty));
47
+
48
+ $finalPrice = $product->getData('final_price');
49
+ $finalPrice = $this->_applyOptionsPrice($product, $qty, $finalPrice);
50
+ $finalPrice = max(0, $finalPrice);
51
+
52
+ $profit = $this->addManufactureProfit($product);
53
+ $finalPrice = $finalPrice + $profit;
54
+
55
+ $product->setFinalPrice($finalPrice);
56
+
57
+ return $finalPrice;
58
+ }
59
+
60
+ /**
61
+ * Get product tier price by qty
62
+ *
63
+ * @param float $qty
64
+ * @param Mage_Catalog_Model_Product $product
65
+ * @return float
66
+ */
67
+ public function getTierPrice($qty = null, $product)
68
+ {
69
+
70
+ $allGroups = Mage_Customer_Model_Group::CUST_GROUP_ALL;
71
+ $prices = $product->getData('tier_price');
72
+ if (is_null($prices)) {
73
+ $attribute = $product->getResource()->getAttribute('tier_price');
74
+ if ($attribute) {
75
+ $attribute->getBackend()->afterLoad($product);
76
+ $prices = $product->getData('tier_price');
77
+ }
78
+ }
79
+
80
+ if (is_null($prices) || !is_array($prices)) {
81
+ if (!is_null($qty)) {
82
+ return $product->getPrice();
83
+ }
84
+ return array(array(
85
+ 'price' => $product->getPrice(),
86
+ 'website_price' => $product->getPrice(),
87
+ 'price_qty' => 1,
88
+ 'cust_group' => $allGroups,
89
+ ));
90
+ }
91
+
92
+ $custGroup = $this->_getCustomerGroupId($product);
93
+ if ($qty) {
94
+ $prevQty = 1;
95
+ $prevPrice = $product->getPrice();
96
+ $prevGroup = $allGroups;
97
+
98
+ foreach ($prices as $price) {
99
+ if ($price['cust_group']!=$custGroup && $price['cust_group']!=$allGroups) {
100
+ // tier not for current customer group nor is for all groups
101
+ continue;
102
+ }
103
+ if ($qty < $price['price_qty']) {
104
+ // tier is higher than product qty
105
+ continue;
106
+ }
107
+ if ($price['price_qty'] < $prevQty) {
108
+ // higher tier qty already found
109
+ continue;
110
+ }
111
+ if ($price['price_qty'] == $prevQty && $prevGroup != $allGroups && $price['cust_group'] == $allGroups) {
112
+ // found tier qty is same as current tier qty but current tier group is ALL_GROUPS
113
+ continue;
114
+ }
115
+ if ($price['website_price'] < $prevPrice) {
116
+ $prevPrice = $price['website_price'];
117
+ $prevQty = $price['price_qty'];
118
+ $prevGroup = $price['cust_group'];
119
+ }
120
+ }
121
+
122
+ return $prevPrice;
123
+ } else {
124
+ $qtyCache = array();
125
+ foreach ($prices as $i => $price) {
126
+ if ($price['cust_group'] != $custGroup && $price['cust_group'] != $allGroups) {
127
+ unset($prices[$i]);
128
+ } else if (isset($qtyCache[$price['price_qty']])) {
129
+ $j = $qtyCache[$price['price_qty']];
130
+ if ($prices[$j]['website_price'] > $price['website_price']) {
131
+ unset($prices[$j]);
132
+ $qtyCache[$price['price_qty']] = $i;
133
+ } else {
134
+ unset($prices[$i]);
135
+ }
136
+ } else {
137
+ $qtyCache[$price['price_qty']] = $i;
138
+ }
139
+ }
140
+ }
141
+ return ($prices) ? $prices : array();
142
+ }
143
+
144
+ public function addManufactureProfit($product)
145
+ {
146
+ $productInfo = Mage::getModel('catalog/product')->load($product->getId());
147
+ $profit = 0;
148
+ if($productInfo->getManufacturer()){
149
+ $mInfo = Mage::getModel('manufactures/manufactures')->getCollection()->addFilter('option_id', $productInfo->getManufacturer())->getData();
150
+ $mInfo = $mInfo[0];
151
+ $price = $product->getPrice();
152
+ if($mInfo["profit_value"] != NULL){
153
+
154
+ if($mInfo["profit"] == 1){
155
+ $profit = ($price * $mInfo["profit_value"])/100;
156
+ }else{
157
+ $profit = $mInfo["profit_value"];
158
+ }
159
+ return $profit;
160
+ }else{
161
+ return $profit;
162
+ }
163
+ }else{
164
+ return $profit;
165
+ }
166
+ }
167
+ }
app/code/community/Phxsolution/Manufactures/Model/Profit.php ADDED
@@ -0,0 +1,40 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /*
3
+ /**
4
+ * PHXSolution Manufactures Commission Manager
5
+ *
6
+ * NOTICE OF LICENSE
7
+ *
8
+ * This source file is subject to the Open Software License (OSL 3.0)
9
+ * that is bundled with this package in the file LICENSE.txt.
10
+ * It is also available through the world-wide-web at this URL:
11
+ * http://opensource.org/licenses/osl-3.0.php
12
+ * If you did not receive a copy of the license and are unable to
13
+ * obtain it through the world-wide-web, please send an email
14
+ * to license@magentocommerce.com so you can be sent a copy immediately.
15
+ *
16
+ * Original code copyright (c) 2008 Irubin Consulting Inc. DBA Varien
17
+ *
18
+ * @category Manufactures Model
19
+ * @package Phxsolution_Manufactures
20
+ * @author Prakash Vaniya
21
+ * @contact contact@phxsolution.com
22
+ * @site www.phxsolution.com
23
+ * @copyright Copyright (c) 2014 PHXSolution Manufactures
24
+ * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
25
+ */
26
+ ?>
27
+ <?php
28
+ class Phxsolution_Manufactures_Model_Profit extends Varien_Object
29
+ {
30
+ const PROFIT_ENABLED = 1;
31
+ const PROFIT_DISABLED = 2;
32
+
33
+ static public function getOptionArray()
34
+ {
35
+ return array(
36
+ self::PROFIT_ENABLED => Mage::helper('manufactures')->__('Percentage(%)'),
37
+ self::PROFIT_DISABLED => Mage::helper('manufactures')->__('Fixed')
38
+ );
39
+ }
40
+ }
app/code/community/Phxsolution/Manufactures/controllers/Adminhtml/ManufacturesController.php ADDED
@@ -0,0 +1,286 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /*
3
+ /**
4
+ * PHXSolution Manufactures Commission Manager
5
+ *
6
+ * NOTICE OF LICENSE
7
+ *
8
+ * This source file is subject to the Open Software License (OSL 3.0)
9
+ * that is bundled with this package in the file LICENSE.txt.
10
+ * It is also available through the world-wide-web at this URL:
11
+ * http://opensource.org/licenses/osl-3.0.php
12
+ * If you did not receive a copy of the license and are unable to
13
+ * obtain it through the world-wide-web, please send an email
14
+ * to license@magentocommerce.com so you can be sent a copy immediately.
15
+ *
16
+ * Original code copyright (c) 2008 Irubin Consulting Inc. DBA Varien
17
+ *
18
+ * @category Manufactures Controllers
19
+ * @package Phxsolution_Manufactures
20
+ * @author Prakash Vaniya
21
+ * @contact contact@phxsolution.com
22
+ * @site www.phxsolution.com
23
+ * @copyright Copyright (c) 2014 PHXSolution Manufactures
24
+ * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
25
+ */
26
+ ?>
27
+ <?php
28
+ class Phxsolution_Manufactures_Adminhtml_ManufacturesController extends Mage_Adminhtml_Controller_action
29
+ {
30
+ protected function _initAction()
31
+ {
32
+ $this->loadLayout()
33
+ ->_setActiveMenu('manufactures/items')
34
+ ->_title($this->__('Manufactures List'))
35
+ ->_addBreadcrumb(Mage::helper('adminhtml')->__('Manufacters List'), Mage::helper('adminhtml')->__('Manufacters List'));
36
+
37
+ return $this;
38
+ }
39
+ public function indexAction()
40
+ {
41
+ $manufacturesCollection = Mage::getModel('manufactures/manufactures')->getCollection();
42
+ if(!count($manufacturesCollection))
43
+ Mage::helper('manufactures')->installSampleData();
44
+
45
+ $this->_initAction()
46
+ ->renderLayout();
47
+ }
48
+ public function editAction()
49
+ {
50
+ $id = $this->getRequest()->getParam('id');
51
+ $model = Mage::getModel('manufactures/manufactures')->load($id);
52
+
53
+ if ($model->getId() || $id == 0) {
54
+ $data = Mage::getSingleton('adminhtml/session')->getFormData(true);
55
+ if (!empty($data)) {
56
+ $model->setData($data);
57
+ }
58
+
59
+ Mage::register('manufactures_data', $model);
60
+
61
+ $this->loadLayout();
62
+ $this->_setActiveMenu('manufactures/items');
63
+
64
+ $this->_addBreadcrumb(Mage::helper('adminhtml')->__('Manufacters List'), Mage::helper('adminhtml')->__('Manufacters List'));
65
+ $this->_addBreadcrumb(Mage::helper('adminhtml')->__('Item News'), Mage::helper('adminhtml')->__('Item News'));
66
+
67
+ $this->getLayout()->getBlock('head')->setCanLoadExtJs(true);
68
+
69
+ $this->_addContent($this->getLayout()->createBlock('manufactures/adminhtml_manufactures_edit'))
70
+ ->_addLeft($this->getLayout()->createBlock('manufactures/adminhtml_manufactures_edit_tabs'));
71
+
72
+ $this->renderLayout();
73
+ } else {
74
+ Mage::getSingleton('adminhtml/session')->addError(Mage::helper('manufactures')->__('Item does not exist'));
75
+ $this->_redirect('*/*/');
76
+ }
77
+ }
78
+ public function newAction()
79
+ {
80
+ $this->_forward('edit');
81
+ }
82
+ public function saveAction()
83
+ {
84
+ if ($data = $this->getRequest()->getPost())
85
+ {
86
+ $option_id = $this->getRequest()->getParam('option_id');
87
+ $id = $this->getRequest()->getParam('id');
88
+ $model = Mage::getModel('manufactures/manufactures');
89
+ $model->setData($data)
90
+ ->setId($id);
91
+
92
+ try
93
+ {
94
+ // save image
95
+ if((bool)$data['image']['delete']==1)
96
+ {
97
+ $data['image']='';
98
+ }
99
+ else
100
+ {
101
+ if (isset($_FILES))
102
+ {
103
+ if ($_FILES['image']['name'])
104
+ {
105
+ unset($data['image']);
106
+ if($id)
107
+ {
108
+ if($model->getData('image'))
109
+ {
110
+ $io = new Varien_Io_File();
111
+ $io->rm(Mage::getBaseDir('media').DS.implode(DS,explode('/',$model->getData('image'))));
112
+ }
113
+ }
114
+ $path = Mage::getBaseDir('media') . DS . 'manufactures' . DS .'logos'.DS;
115
+ $uploader = new Varien_File_Uploader('image');
116
+ $uploader->setAllowedExtensions(array('jpg','png','gif'));
117
+ $uploader->setAllowRenameFiles(false);
118
+ $uploader->setFilesDispersion(false);
119
+ $destFile = $path.$_FILES['image']['name'];
120
+ $filename = $uploader->getNewFileName($destFile);
121
+ $uploader->save($path, $filename);
122
+
123
+ $model['image'] = 'manufactures/logos/'.$filename;
124
+ }
125
+ else
126
+ {
127
+ if($data['image']['value'])
128
+ $model['image'] = $data['image']['value'];
129
+ }
130
+
131
+ }
132
+ else
133
+ Mage::getSingleton('adminhtml/session')->addError('_FILES not set');
134
+ }
135
+ // save image
136
+
137
+ if($note = $this->getRequest()->getParam('note'))
138
+ $model->setNote($note);
139
+ if ($model->getCreatedTime == NULL || $model->getUpdateTime() == NULL)
140
+ {
141
+ $model->setCreatedTime(now())
142
+ ->setUpdateTime(now());
143
+ }
144
+ else
145
+ {
146
+ $model->setUpdateTime(now());
147
+ }
148
+
149
+ $available = $this->checkExist($option_id, $id);
150
+ if($available == NULL)
151
+ {
152
+ $model->save();
153
+ Mage::getSingleton('adminhtml/session')->addSuccess(Mage::helper('manufactures')->__('Item was successfully saved'));
154
+ Mage::getSingleton('adminhtml/session')->setFormData(false);
155
+ }
156
+ else
157
+ {
158
+ Mage::getSingleton('adminhtml/session')->addError(Mage::helper('manufactures')->__('The Manufacture has already assigned profile value'));
159
+ Mage::getSingleton('adminhtml/session')->setFormData($data);
160
+ $this->_redirect('*/*/edit', array('id' => $model->getId()));
161
+ return;
162
+ }
163
+ if ($this->getRequest()->getParam('back'))
164
+ {
165
+ $this->_redirect('*/*/edit', array('id' => $model->getId()));
166
+ return;
167
+ }
168
+ $this->_redirect('*/*/');
169
+ return;
170
+ }
171
+ catch (Exception $e)
172
+ {
173
+ Mage::getSingleton('adminhtml/session')->addError($e->getMessage());
174
+ Mage::getSingleton('adminhtml/session')->setFormData($data);
175
+ $this->_redirect('*/*/edit', array('id' => $this->getRequest()->getParam('id')));
176
+ return;
177
+ }
178
+ }
179
+ Mage::getSingleton('adminhtml/session')->addError(Mage::helper('manufactures')->__('Unable to find item to save'));
180
+ $this->_redirect('*/*/');
181
+ }
182
+ public function checkExist($option_id, $id)
183
+ {
184
+ $modelInfo = Mage::getModel('manufactures/manufactures')->getCollection()->addFilter('option_id', $option_id)->getData();
185
+ if($modelInfo[0]["manufactures_id"] == $id){
186
+ return;
187
+ }else{
188
+ return $modelInfo[0]["manufactures_id"];
189
+ }
190
+ return;
191
+ }
192
+ public function deleteAction()
193
+ {
194
+ if( $this->getRequest()->getParam('id') > 0 ) {
195
+ try {
196
+ $model = Mage::getModel('manufactures/manufactures');
197
+
198
+ $model->setId($this->getRequest()->getParam('id'))
199
+ ->delete();
200
+
201
+ Mage::getSingleton('adminhtml/session')->addSuccess(Mage::helper('adminhtml')->__('Item was successfully deleted'));
202
+ $this->_redirect('*/*/');
203
+ } catch (Exception $e) {
204
+ Mage::getSingleton('adminhtml/session')->addError($e->getMessage());
205
+ $this->_redirect('*/*/edit', array('id' => $this->getRequest()->getParam('id')));
206
+ }
207
+ }
208
+ $this->_redirect('*/*/');
209
+ }
210
+ public function massDeleteAction()
211
+ {
212
+ $manufacturesIds = $this->getRequest()->getParam('manufactures');
213
+ if(!is_array($manufacturesIds)) {
214
+ Mage::getSingleton('adminhtml/session')->addError(Mage::helper('adminhtml')->__('Please select item(s)'));
215
+ } else {
216
+ try {
217
+ foreach ($manufacturesIds as $manufacturesId) {
218
+ $manufactures = Mage::getModel('manufactures/manufactures')->load($manufacturesId);
219
+ $manufactures->delete();
220
+ }
221
+ Mage::getSingleton('adminhtml/session')->addSuccess(
222
+ Mage::helper('adminhtml')->__(
223
+ 'Total of %d record(s) were successfully deleted', count($manufacturesIds)
224
+ )
225
+ );
226
+ } catch (Exception $e) {
227
+ Mage::getSingleton('adminhtml/session')->addError($e->getMessage());
228
+ }
229
+ }
230
+ $this->_redirect('*/*/index');
231
+ }
232
+ public function massProfitAction()
233
+ {
234
+ $manufacturesIds = $this->getRequest()->getParam('manufactures');
235
+ if(!is_array($manufacturesIds)) {
236
+ Mage::getSingleton('adminhtml/session')->addError($this->__('Please select item(s)'));
237
+ } else {
238
+ try {
239
+ foreach ($manufacturesIds as $manufacturesId) {
240
+ $manufactures = Mage::getSingleton('manufactures/manufactures')
241
+ ->load($manufacturesId)
242
+ ->setProfit($this->getRequest()->getParam('profit'))
243
+ ->setIsMassupdate(true)
244
+ ->save();
245
+ }
246
+ $this->_getSession()->addSuccess(
247
+ $this->__('Total of %d record(s) were successfully updated', count($manufacturesIds))
248
+ );
249
+ } catch (Exception $e) {
250
+ $this->_getSession()->addError($e->getMessage());
251
+ }
252
+ }
253
+ $this->_redirect('*/*/index');
254
+ }
255
+ public function exportCsvAction()
256
+ {
257
+ $fileName = 'manufactures.csv';
258
+ $content = $this->getLayout()->createBlock('manufactures/adminhtml_manufactures_grid')
259
+ ->getCsv();
260
+
261
+ $this->_sendUploadResponse($fileName, $content);
262
+ }
263
+ public function exportXmlAction()
264
+ {
265
+ $fileName = 'manufactures.xml';
266
+ $content = $this->getLayout()->createBlock('manufactures/adminhtml_manufactures_grid')
267
+ ->getXml();
268
+
269
+ $this->_sendUploadResponse($fileName, $content);
270
+ }
271
+ protected function _sendUploadResponse($fileName, $content, $contentType='application/octet-stream')
272
+ {
273
+ $response = $this->getResponse();
274
+ $response->setHeader('HTTP/1.1 200 OK','');
275
+ $response->setHeader('Pragma', 'public', true);
276
+ $response->setHeader('Cache-Control', 'must-revalidate, post-check=0, pre-check=0', true);
277
+ $response->setHeader('Content-Disposition', 'attachment; filename='.$fileName);
278
+ $response->setHeader('Last-Modified', date('r'));
279
+ $response->setHeader('Accept-Ranges', 'bytes');
280
+ $response->setHeader('Content-Length', strlen($content));
281
+ $response->setHeader('Content-type', $contentType);
282
+ $response->setBody($content);
283
+ $response->sendResponse();
284
+ die;
285
+ }
286
+ }
app/code/community/Phxsolution/Manufactures/controllers/IndexController.php ADDED
@@ -0,0 +1,37 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /*
3
+ /**
4
+ * PHXSolution Manufactures Commission Manager
5
+ *
6
+ * NOTICE OF LICENSE
7
+ *
8
+ * This source file is subject to the Open Software License (OSL 3.0)
9
+ * that is bundled with this package in the file LICENSE.txt.
10
+ * It is also available through the world-wide-web at this URL:
11
+ * http://opensource.org/licenses/osl-3.0.php
12
+ * If you did not receive a copy of the license and are unable to
13
+ * obtain it through the world-wide-web, please send an email
14
+ * to license@magentocommerce.com so you can be sent a copy immediately.
15
+ *
16
+ * Original code copyright (c) 2008 Irubin Consulting Inc. DBA Varien
17
+ *
18
+ * @category Manufactures Controllers
19
+ * @package Phxsolution_Manufactures
20
+ * @author Prakash Vaniya
21
+ * @contact contact@phxsolution.com
22
+ * @site www.phxsolution.com
23
+ * @copyright Copyright (c) 2014 PHXSolution Manufactures
24
+ * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
25
+ */
26
+ ?>
27
+ <?php
28
+ class Phxsolution_Manufactures_IndexController extends Mage_Core_Controller_Front_Action
29
+ {
30
+ public function indexAction()
31
+ {
32
+ if(!Mage::helper('manufactures')->getIsEnabled())
33
+ Mage::getSingleton('core/session')->addError('This feature is disabled, please contact administrator.');
34
+ $this->loadLayout();
35
+ $this->renderLayout();
36
+ }
37
+ }
app/code/community/Phxsolution/Manufactures/controllers/ProductsController.php ADDED
@@ -0,0 +1,37 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /*
3
+ /**
4
+ * PHXSolution Manufactures Commission Manager
5
+ *
6
+ * NOTICE OF LICENSE
7
+ *
8
+ * This source file is subject to the Open Software License (OSL 3.0)
9
+ * that is bundled with this package in the file LICENSE.txt.
10
+ * It is also available through the world-wide-web at this URL:
11
+ * http://opensource.org/licenses/osl-3.0.php
12
+ * If you did not receive a copy of the license and are unable to
13
+ * obtain it through the world-wide-web, please send an email
14
+ * to license@magentocommerce.com so you can be sent a copy immediately.
15
+ *
16
+ * Original code copyright (c) 2008 Irubin Consulting Inc. DBA Varien
17
+ *
18
+ * @category Manufactures Controllers
19
+ * @package Phxsolution_Manufactures
20
+ * @author Prakash Vaniya
21
+ * @contact contact@phxsolution.com
22
+ * @site www.phxsolution.com
23
+ * @copyright Copyright (c) 2014 PHXSolution Manufactures
24
+ * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
25
+ */
26
+ ?>
27
+ <?php
28
+ class Phxsolution_Manufactures_ProductsController extends Mage_Core_Controller_Front_Action
29
+ {
30
+ public function indexAction()
31
+ {
32
+ if(!Mage::helper('manufactures')->getIsEnabled())
33
+ Mage::getSingleton('core/session')->addError('This feature is disabled, please contact administrator.');
34
+ $this->loadLayout();
35
+ $this->renderLayout();
36
+ }
37
+ }
app/code/community/Phxsolution/Manufactures/etc/config.xml ADDED
@@ -0,0 +1,194 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?xml version="1.0"?>
2
+ <!--
3
+ /**
4
+ * PHXSolution Manufactures Commission Manager
5
+ *
6
+ * NOTICE OF LICENSE
7
+ *
8
+ * This source file is subject to the Open Software License (OSL 3.0)
9
+ * that is bundled with this package in the file LICENSE.txt.
10
+ * It is also available through the world-wide-web at this URL:
11
+ * http://opensource.org/licenses/osl-3.0.php
12
+ * If you did not receive a copy of the license and are unable to
13
+ * obtain it through the world-wide-web, please send an email
14
+ * to license@magentocommerce.com so you can be sent a copy immediately.
15
+ *
16
+ * Original code copyright (c) 2008 Irubin Consulting Inc. DBA Varien
17
+ *
18
+ * @category Module Configuration
19
+ * @package Phxsolution_Manufactures
20
+ * @author Prakash Vaniya
21
+ * @contact contact@phxsolution.com
22
+ * @site www.phxsolution.com
23
+ * @copyright Copyright (c) 2014 PHXSolution Manufactures
24
+ * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
25
+ */
26
+ -->
27
+ <config>
28
+ <modules>
29
+ <Phxsolution_Manufactures>
30
+ <version>0.1.0</version>
31
+ </Phxsolution_Manufactures>
32
+ </modules>
33
+ <frontend>
34
+ <!-- <routers>
35
+ <manufactures>
36
+ <use>standard</use>
37
+ <args>
38
+ <module>Phxsolution_Manufactures</module>
39
+ <frontName>manufactures</frontName>
40
+ </args>
41
+ </manufactures>
42
+ </routers> -->
43
+ <layout>
44
+ <updates>
45
+ <manufactures>
46
+ <file>manufactures.xml</file>
47
+ </manufactures>
48
+ </updates>
49
+ </layout>
50
+ </frontend>
51
+ <admin>
52
+ <routers>
53
+ <manufactures>
54
+ <use>admin</use>
55
+ <args>
56
+ <module>Phxsolution_Manufactures</module>
57
+ <frontName>manufactures</frontName>
58
+ </args>
59
+ </manufactures>
60
+ </routers>
61
+ </admin>
62
+ <adminhtml>
63
+ <menu>
64
+ <manufactures module="manufactures">
65
+ <depends>
66
+ <config>manufactures_section/settings/enabled</config>
67
+ </depends>
68
+ <title>Manufacturers</title>
69
+ <sort_order>71</sort_order>
70
+ <children>
71
+ <items module="manufactures">
72
+ <title>Manufacturers List</title>
73
+ <sort_order>0</sort_order>
74
+ <action>manufactures/adminhtml_manufactures</action>
75
+ </items>
76
+ </children>
77
+ </manufactures>
78
+ </menu>
79
+ <acl>
80
+ <resources>
81
+ <all>
82
+ <title>Allow Everything</title>
83
+ </all>
84
+ <admin>
85
+ <children>
86
+ <Phxsolution_Manufactures>
87
+ <title>Manufactures Module</title>
88
+ <sort_order>10</sort_order>
89
+ </Phxsolution_Manufactures>
90
+ </children>
91
+ </admin>
92
+ </resources>
93
+ </acl>
94
+ <acl>
95
+ <resources>
96
+ <admin>
97
+ <children>
98
+ <system>
99
+ <children>
100
+ <config>
101
+ <children>
102
+ <manufactures_section translate="title" module="manufactures">
103
+ <title>Manufactures Commission Manager</title>
104
+ </manufactures_section>
105
+ </children>
106
+ </config>
107
+ </children>
108
+ </system>
109
+ </children>
110
+ </admin>
111
+ </resources>
112
+ </acl>
113
+ <layout>
114
+ <updates>
115
+ <manufactures>
116
+ <file>manufactures.xml</file>
117
+ </manufactures>
118
+ </updates>
119
+ </layout>
120
+ </adminhtml>
121
+ <global>
122
+ <models>
123
+ <catalog>
124
+ <rewrite>
125
+ <product_type_price>Phxsolution_Manufactures_Model_Product_Type_Price</product_type_price>
126
+ <product_type_configurable_price>Phxsolution_Manufactures_Model_Product_Type_Configurable_Price</product_type_configurable_price>
127
+ <product_type_grouped_price>Phxsolution_Manufactures_Model_Product_Type_Grouped_Price</product_type_grouped_price>
128
+ <product>Phxsolution_Manufactures_Model_Product</product>
129
+ </rewrite>
130
+ </catalog>
131
+
132
+ <manufactures>
133
+ <class>Phxsolution_Manufactures_Model</class>
134
+ <resourceModel>manufactures_mysql4</resourceModel>
135
+ </manufactures>
136
+ <manufactures_mysql4>
137
+ <class>Phxsolution_Manufactures_Model_Mysql4</class>
138
+ <entities>
139
+ <manufactures>
140
+ <table>manufactures</table>
141
+ </manufactures>
142
+ </entities>
143
+ </manufactures_mysql4>
144
+ </models>
145
+ <resources>
146
+ <manufactures_setup>
147
+ <setup>
148
+ <module>Phxsolution_Manufactures</module>
149
+ </setup>
150
+ <connection>
151
+ <use>core_setup</use>
152
+ </connection>
153
+ </manufactures_setup>
154
+ <manufactures_write>
155
+ <connection>
156
+ <use>core_write</use>
157
+ </connection>
158
+ </manufactures_write>
159
+ <manufactures_read>
160
+ <connection>
161
+ <use>core_read</use>
162
+ </connection>
163
+ </manufactures_read>
164
+ </resources>
165
+ <blocks>
166
+ <manufactures>
167
+ <class>Phxsolution_Manufactures_Block</class>
168
+ </manufactures>
169
+ <adminhtml>
170
+ <rewrite>
171
+ <catalog_product_grid>Phxsolution_Manufactures_Block_Adminhtml_Catalog_Product_Grid</catalog_product_grid>
172
+ </rewrite>
173
+ </adminhtml>
174
+ </blocks>
175
+ <helpers>
176
+ <manufactures>
177
+ <class>Phxsolution_Manufactures_Helper</class>
178
+ </manufactures>
179
+ <tax>
180
+                 <rewrite>
181
+                     <data>Phxsolution_Manufactures_Helper_Profit_Data</data>
182
+                 </rewrite>
183
+             </tax>
184
+ </helpers>
185
+ </global>
186
+ <default>
187
+ <manufactures_section>
188
+ <settings>
189
+ <enabled>1</enabled>
190
+ <attribute_identifier>210</attribute_identifier>
191
+ </settings>
192
+ </manufactures_section>
193
+ </default>
194
+ </config>
app/code/community/Phxsolution/Manufactures/etc/system.xml ADDED
@@ -0,0 +1,79 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?xml version="1.0"?>
2
+ <!--
3
+ /**
4
+ * PHXSolution Manufactures Commission Manager
5
+ *
6
+ * NOTICE OF LICENSE
7
+ *
8
+ * This source file is subject to the Open Software License (OSL 3.0)
9
+ * that is bundled with this package in the file LICENSE.txt.
10
+ * It is also available through the world-wide-web at this URL:
11
+ * http://opensource.org/licenses/osl-3.0.php
12
+ * If you did not receive a copy of the license and are unable to
13
+ * obtain it through the world-wide-web, please send an email
14
+ * to license@magentocommerce.com so you can be sent a copy immediately.
15
+ *
16
+ * Original code copyright (c) 2008 Irubin Consulting Inc. DBA Varien
17
+ *
18
+ * @category Module System Configuration
19
+ * @package Phxsolution_Manufactures
20
+ * @author Prakash Vaniya
21
+ * @contact contact@phxsolution.com
22
+ * @site www.phxsolution.com
23
+ * @copyright Copyright (c) 2014 PHXSolution Manufactures
24
+ * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
25
+ */
26
+ -->
27
+ <config>
28
+ <tabs>
29
+ <manufactures_tab translate="label" module="manufactures">
30
+ <label>Phxsolution Extensions</label>
31
+ <sort_order>1</sort_order>
32
+ </manufactures_tab>
33
+ </tabs>
34
+ <sections>
35
+ <manufactures_section translate="label" module="manufactures">
36
+ <label>Manufacturers Commission Manager</label>
37
+ <tab>manufactures_tab</tab>
38
+ <sort_order>1</sort_order>
39
+ <show_in_default>1</show_in_default>
40
+ <show_in_website>1</show_in_website>
41
+ <show_in_store>1</show_in_store>
42
+ <groups>
43
+ <settings translate="label">
44
+ <label>Settings</label>
45
+ <sort_order>1</sort_order>
46
+ <show_in_default>1</show_in_default>
47
+ <show_in_website>1</show_in_website>
48
+ <show_in_store>1</show_in_store>
49
+ <expanded>1</expanded>
50
+ <fields>
51
+ <enabled translate="label">
52
+ <label>Enable</label>
53
+ <frontend_type>select</frontend_type>
54
+ <source_model>adminhtml/system_config_source_yesno</source_model>
55
+ <sort_order>1</sort_order>
56
+ <show_in_default>1</show_in_default>
57
+ <show_in_website>1</show_in_website>
58
+ <show_in_store>1</show_in_store>
59
+ </enabled>
60
+ </fields>
61
+ <fields>
62
+ <logo translate="label comment">
63
+ <label>No-Logo</label>
64
+ <comment>Allowed file types: jpeg, gif, png.</comment>
65
+ <frontend_type>image</frontend_type>
66
+ <backend_model>adminhtml/system_config_backend_image</backend_model>
67
+ <upload_dir config="system/filesystem/media" scope_info="1">manufactures/logos/</upload_dir>
68
+ <base_url type="media" scope_info="1">manufactures/logos/</base_url>
69
+ <sort_order>2</sort_order>
70
+ <show_in_default>1</show_in_default>
71
+ <show_in_website>1</show_in_website>
72
+ <show_in_store>1</show_in_store>
73
+ </logo>
74
+ </fields>
75
+ </settings>
76
+ </groups>
77
+ </manufactures_section>
78
+ </sections>
79
+ </config>
app/code/community/Phxsolution/Manufactures/sql/manufactures_setup/mysql4-install-0.1.0.php ADDED
@@ -0,0 +1,51 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /*
3
+ /**
4
+ * PHXSolution Manufactures Commission Manager
5
+ *
6
+ * NOTICE OF LICENSE
7
+ *
8
+ * This source file is subject to the Open Software License (OSL 3.0)
9
+ * that is bundled with this package in the file LICENSE.txt.
10
+ * It is also available through the world-wide-web at this URL:
11
+ * http://opensource.org/licenses/osl-3.0.php
12
+ * If you did not receive a copy of the license and are unable to
13
+ * obtain it through the world-wide-web, please send an email
14
+ * to license@magentocommerce.com so you can be sent a copy immediately.
15
+ *
16
+ * Original code copyright (c) 2008 Irubin Consulting Inc. DBA Varien
17
+ *
18
+ * @category Manufactures Database Table Setup
19
+ * @package Phxsolution_Manufactures
20
+ * @author Prakash Vaniya
21
+ * @contact contact@phxsolution.com
22
+ * @site www.phxsolution.com
23
+ * @copyright Copyright (c) 2014 PHXSolution Manufactures
24
+ * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
25
+ */
26
+ ?>
27
+ <?php
28
+
29
+ $installer = $this;
30
+
31
+ $installer->startSetup();
32
+
33
+ $installer->run("
34
+
35
+ -- DROP TABLE IF EXISTS {$this->getTable('manufactures')};
36
+ CREATE TABLE {$this->getTable('manufactures')} (
37
+ `manufactures_id` int(11) unsigned NOT NULL auto_increment,
38
+ `attribute_id` smallint(6) NOT NULL default '0',
39
+ `option_id` smallint(6) NOT NULL default '0',
40
+ `profit_value` int(11) NOT NULL default '0',
41
+ `profit` smallint(6) NOT NULL default '0',
42
+ `image` varchar(255) NOT NULL default '',
43
+ `note` varchar(255) NOT NULL default '',
44
+ `created_time` datetime NULL,
45
+ `update_time` datetime NULL,
46
+ PRIMARY KEY (`manufactures_id`)
47
+ ) ENGINE=InnoDB DEFAULT CHARSET=utf8;
48
+
49
+ ");
50
+
51
+ $installer->endSetup();
app/design/adminhtml/default/default/layout/manufactures.xml ADDED
@@ -0,0 +1,33 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?xml version="1.0"?>
2
+ <!--
3
+ /**
4
+ * PHXSolution Manufactures Commission Manager
5
+ *
6
+ * NOTICE OF LICENSE
7
+ *
8
+ * This source file is subject to the Open Software License (OSL 3.0)
9
+ * that is bundled with this package in the file LICENSE.txt.
10
+ * It is also available through the world-wide-web at this URL:
11
+ * http://opensource.org/licenses/osl-3.0.php
12
+ * If you did not receive a copy of the license and are unable to
13
+ * obtain it through the world-wide-web, please send an email
14
+ * to license@magentocommerce.com so you can be sent a copy immediately.
15
+ *
16
+ * Original code copyright (c) 2008 Irubin Consulting Inc. DBA Varien
17
+ *
18
+ * @category Manufactures Adminhtml Design Layout
19
+ * @package Phxsolution_Manufactures
20
+ * @author Prakash Vaniya
21
+ * @contact contact@phxsolution.com
22
+ * @site www.phxsolution.com
23
+ * @copyright Copyright (c) 2014 PHXSolution Manufactures
24
+ * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
25
+ */
26
+ -->
27
+ <layout version="0.1.0">
28
+ <manufactures_adminhtml_manufactures_index>
29
+ <reference name="content">
30
+ <block type="manufactures/adminhtml_manufactures" name="manufactures" />
31
+ </reference>
32
+ </manufactures_adminhtml_manufactures_index>
33
+ </layout>
app/design/frontend/base/default/layout/manufactures.xml ADDED
@@ -0,0 +1,54 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?xml version="1.0"?>
2
+ <!--
3
+ /**
4
+ * PHXSolution Manufactures Commission Manager
5
+ *
6
+ * NOTICE OF LICENSE
7
+ *
8
+ * This source file is subject to the Open Software License (OSL 3.0)
9
+ * that is bundled with this package in the file LICENSE.txt.
10
+ * It is also available through the world-wide-web at this URL:
11
+ * http://opensource.org/licenses/osl-3.0.php
12
+ * If you did not receive a copy of the license and are unable to
13
+ * obtain it through the world-wide-web, please send an email
14
+ * to license@magentocommerce.com so you can be sent a copy immediately.
15
+ *
16
+ * Original code copyright (c) 2008 Irubin Consulting Inc. DBA Varien
17
+ *
18
+ * @category Manufactures Frontend Design Layout
19
+ * @package Phxsolution_Manufactures
20
+ * @author Prakash Vaniya
21
+ * @contact contact@phxsolution.com
22
+ * @site www.phxsolution.com
23
+ * @copyright Copyright (c) 2014 PHXSolution Manufactures
24
+ * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
25
+ */
26
+ -->
27
+ <layout version="0.1.0">
28
+ <default>
29
+ <reference name="root">
30
+ <action method="setTemplate"><template>page/1column.phtml</template></action>
31
+ </reference>
32
+ <reference name="top.links">
33
+ <action method="addLink" translate="label title" ifconfig="manufactures_section/settings/enabled">
34
+ <label>Manufacturers</label>
35
+ <url>manufactures/</url>
36
+ <title>Manufacturers List</title>
37
+ <prepare>true</prepare>
38
+ <urlParams/>
39
+ <position>150</position>
40
+ <liParams>id="manufactures-list"</liParams>
41
+ </action>
42
+ </reference>
43
+ </default>
44
+ <manufactures_index_index>
45
+ <reference name="content">
46
+ <block type="manufactures/manufactures" name="manufactures" template="manufactures/manufactures.phtml" />
47
+ </reference>
48
+ </manufactures_index_index>
49
+ <manufactures_products_index>
50
+ <reference name="content">
51
+ <block type="manufactures/manufactures" name="manufactures-products" template="manufactures/manufactures-products.phtml" />
52
+ </reference>
53
+ </manufactures_products_index>
54
+ </layout>
app/design/frontend/base/default/template/manufactures/manufactures-products.phtml ADDED
@@ -0,0 +1,118 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /*
3
+ /**
4
+ * PHXSolution Manufactures Commission Manager
5
+ *
6
+ * NOTICE OF LICENSE
7
+ *
8
+ * This source file is subject to the Open Software License (OSL 3.0)
9
+ * that is bundled with this package in the file LICENSE.txt.
10
+ * It is also available through the world-wide-web at this URL:
11
+ * http://opensource.org/licenses/osl-3.0.php
12
+ * If you did not receive a copy of the license and are unable to
13
+ * obtain it through the world-wide-web, please send an email
14
+ * to license@magentocommerce.com so you can be sent a copy immediately.
15
+ *
16
+ * Original code copyright (c) 2008 Irubin Consulting Inc. DBA Varien
17
+ *
18
+ * @category Manufactures Frontend Design Template
19
+ * @package Phxsolution_Manufactures
20
+ * @author Prakash Vaniya
21
+ * @contact contact@phxsolution.com
22
+ * @site www.phxsolution.com
23
+ * @copyright Copyright (c) 2014 PHXSolution Manufactures
24
+ * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
25
+ */
26
+ ?>
27
+ <?php if(Mage::helper('manufactures')->getIsEnabled()): ?>
28
+ <div class='manufactures-products-list'>
29
+ <?php
30
+ $manufactures_id = $this->getRequest()->getParam('id');
31
+ if($manufactures_id != null && $manufactures_id != '')
32
+ {
33
+ $productModel = Mage::getModel('catalog/product');
34
+ $collection = $productModel->getCollection()
35
+ ->addFieldToFilter('manufacturer', $manufactures_id)
36
+ ->addAttributeToSelect('*');
37
+ if(count($collection))
38
+ {
39
+ echo '<div class="category-products">';
40
+ $i=0; $_columnCount=4;
41
+ foreach ($collection as $_product)
42
+ {
43
+ $productId = $_product->getId();
44
+ $productName = $_product->getName();
45
+ $productUurl = $_product->getProductUrl();
46
+ $productSmallImage = $this->helper('catalog/image')->init($_product, 'small_image')->resize(135);
47
+
48
+ if ($i++%$_columnCount==0)
49
+ echo '<ul class="products-grid">';
50
+
51
+ if(($i-1)%$_columnCount==0)
52
+ $firstLastClass = 'first';
53
+ elseif($i%$_columnCount==0)
54
+ $firstLastClass = 'last';
55
+ else
56
+ $firstLastClass = '';
57
+ echo '<li class="item '.$firstLastClass.'">';
58
+ echo '<a href="'.$productUurl.'" title="'.$productName.'" class="product-image">';
59
+ echo '<img src="'.$productSmallImage.'" width="135" height="135" alt="'.$productName.'" />';
60
+ echo '</a>';
61
+ echo '<h2 class="product-name">';
62
+ echo '<a href="'.$productUurl.'" title="'.$productName.'">';
63
+ echo $productName;
64
+ echo '</a>';
65
+ echo '</h2>';
66
+
67
+ echo Mage::helper('manufactures')->getPriceHtml($_product);
68
+
69
+ echo '<div class="actions">';
70
+ if($_product->isSaleable()):
71
+ $_url = Mage::helper('checkout/cart')->getAddUrl($_product);
72
+ $setLocation = "setLocation('$_url')";
73
+ echo '<button type="button" title="'.$this->__('Add to Cart').'" class="button btn-cart" onclick="'.$setLocation.'">';
74
+ echo '<span><span>'.$this->__('Add to Cart').'</span></span>';
75
+ echo '</button>';
76
+ else:
77
+ echo '<p class="availability out-of-stock">';
78
+ echo '<span>'.$this->__('Out of stock').'</span>';
79
+ echo '</p>';
80
+ endif;
81
+ echo '<ul class="add-to-links">';
82
+ if ($this->helper('wishlist')->isAllow()):
83
+ $wishlistAddUrl = $this->helper('wishlist')->getAddUrl($_product);
84
+ echo "<li>";
85
+ echo "<a href='".$wishlistAddUrl."' class='link-wishlist'>";
86
+ echo $this->__('Add to Wishlist');
87
+ echo "</a>";
88
+ echo "</li>";
89
+ endif;
90
+ if($_compareUrl=Mage::helper('catalog/product_compare')->getAddUrl($_product)):
91
+ echo '<li>';
92
+ echo '<span class="separator">|</span> <a href="'.$_compareUrl.'" class="link-compare">'.$this->__('Add to Compare').'</a>';
93
+ echo '</li>';
94
+ endif;
95
+ echo '</ul>';
96
+ echo '</div>';
97
+ echo '</li>';
98
+
99
+ if ($i%$_columnCount==0 || $i==count($collection))
100
+ echo '</ul>';
101
+ }//endforeach
102
+ }
103
+ else
104
+ {
105
+ echo '<p class="note-msg">';
106
+ echo $this->__('There are no products matching the selection.');
107
+ echo '</p>';
108
+ }
109
+ }
110
+ else
111
+ {
112
+ echo '<p class="note-msg">';
113
+ echo $this->__('Sufficient parameters not found.');
114
+ echo '</p>';
115
+ }
116
+ ?>
117
+ </div>
118
+ <?php endif; ?>
app/design/frontend/base/default/template/manufactures/manufactures.phtml ADDED
@@ -0,0 +1,77 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /*
3
+ /**
4
+ * PHXSolution Manufactures Commission Manager
5
+ *
6
+ * NOTICE OF LICENSE
7
+ *
8
+ * This source file is subject to the Open Software License (OSL 3.0)
9
+ * that is bundled with this package in the file LICENSE.txt.
10
+ * It is also available through the world-wide-web at this URL:
11
+ * http://opensource.org/licenses/osl-3.0.php
12
+ * If you did not receive a copy of the license and are unable to
13
+ * obtain it through the world-wide-web, please send an email
14
+ * to license@magentocommerce.com so you can be sent a copy immediately.
15
+ *
16
+ * Original code copyright (c) 2008 Irubin Consulting Inc. DBA Varien
17
+ *
18
+ * @category Manufactures Frontend Design Template
19
+ * @package Phxsolution_Manufactures
20
+ * @author Prakash Vaniya
21
+ * @contact contact@phxsolution.com
22
+ * @site www.phxsolution.com
23
+ * @copyright Copyright (c) 2014 PHXSolution Manufactures
24
+ * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
25
+ */
26
+ ?>
27
+ <?php if(Mage::helper('manufactures')->getIsEnabled()): ?>
28
+ <style type='text/css'>
29
+ .manufactures-list {margin: 25px;}
30
+ .manufactures-list ul li {display: inline; margin: 10px; float: left;}
31
+ </style>
32
+ <h4>
33
+ <?php echo $this->__('Manufacturers List') ?>
34
+ </h4>
35
+ <?php
36
+ $manufactures = Mage::getModel('manufactures/manufactures')->getCollection();
37
+ if(count($manufactures))
38
+ {
39
+ echo "<div class='manufactures-list'>";
40
+ echo "<ul>";
41
+ foreach ($manufactures as $key => $value)
42
+ {
43
+ $manufactures_id = $value->getOptionId();
44
+ $getManufacturesLabel = Mage::helper('manufactures')->getManufacturesLabel($manufactures_id);
45
+ $noImage = Mage::getBaseUrl('media').Mage::helper('manufactures')->getNoImage();
46
+
47
+ if($image = $value->getImage())
48
+ {
49
+ $imageUrl = Mage::getBaseUrl('media').$image;
50
+ $liContent = "<img src='$imageUrl' height='75' width='75' />";
51
+ }
52
+ elseif(Mage::helper('manufactures')->checkImage($noImage))
53
+ {
54
+ $liContent = "<img src='$noImage' height='75' width='75' />";
55
+ }
56
+ else
57
+ {
58
+ $liContent = "<span>".$getManufacturesLabel."</span>";
59
+ }
60
+ $productsUrl = Mage::getUrl('manufactures').'products?id='.$manufactures_id;
61
+ echo "<li class='manufactures_id_".$manufactures_id."'>";
62
+ echo "<a href='$productsUrl' title='$getManufacturesLabel' class='$noImage'>";
63
+ echo $liContent;
64
+ echo "</a>";
65
+ echo "</li>";
66
+ }
67
+ echo "</ul>";
68
+ echo "</div>";
69
+ }
70
+ else
71
+ {
72
+ echo '<p class="note-msg">';
73
+ echo $this->__('There are no item in list.');
74
+ echo '</p>';
75
+ }
76
+ ?>
77
+ <?php endif; ?>
app/etc/modules/Phxsolution_Manufactures.xml ADDED
@@ -0,0 +1,34 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?xml version="1.0"?>
2
+ <!--
3
+ /**
4
+ * PHXSolution Manufactures Commission Manager
5
+ *
6
+ * NOTICE OF LICENSE
7
+ *
8
+ * This source file is subject to the Open Software License (OSL 3.0)
9
+ * that is bundled with this package in the file LICENSE.txt.
10
+ * It is also available through the world-wide-web at this URL:
11
+ * http://opensource.org/licenses/osl-3.0.php
12
+ * If you did not receive a copy of the license and are unable to
13
+ * obtain it through the world-wide-web, please send an email
14
+ * to license@magentocommerce.com so you can be sent a copy immediately.
15
+ *
16
+ * Original code copyright (c) 2008 Irubin Consulting Inc. DBA Varien
17
+ *
18
+ * @category Module Global Configuration
19
+ * @package Phxsolution_Manufactures
20
+ * @author Prakash Vaniya
21
+ * @contact contact@phxsolution.com
22
+ * @site www.phxsolution.com
23
+ * @copyright Copyright (c) 2014 PHXSolution Manufactures
24
+ * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
25
+ */
26
+ -->
27
+ <config>
28
+ <modules>
29
+ <Phxsolution_Manufactures>
30
+ <active>true</active>
31
+ <codePool>community</codePool>
32
+ </Phxsolution_Manufactures>
33
+ </modules>
34
+ </config>
package.xml ADDED
@@ -0,0 +1,18 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?xml version="1.0"?>
2
+ <package>
3
+ <name>Phxsolution_Manufactures</name>
4
+ <version>0.1.0</version>
5
+ <stability>stable</stability>
6
+ <license uri="http://opensource.org/licenses/osl-3.0.php">OSLv3.0</license>
7
+ <channel>community</channel>
8
+ <extends/>
9
+ <summary>Manufacturers Commission Manager as name suggests admin can add commission to price, can set logos and notes.</summary>
10
+ <description>Manufacturers Commission Manager as name suggests admin can add commission to price, can set logos and notes.</description>
11
+ <notes>Fixed some minor bugs.</notes>
12
+ <authors><author><name>Prakash Vaniya</name><user>phxsolution</user><email>contact@phxsolution.com</email></author></authors>
13
+ <date>2014-12-17</date>
14
+ <time>11:41:24</time>
15
+ <contents><target name="mageetc"><dir name="modules"><file name="Phxsolution_Manufactures.xml" hash="c4e4c800bff15e20084b16bd8380bfa7"/></dir></target><target name="magecommunity"><dir name="Phxsolution"><dir name="Manufactures"><dir name="Block"><dir name="Adminhtml"><dir name="Catalog"><dir name="Product"><file name="Grid.php" hash="a6e455d526c678cdabbad4308aaa03f0"/></dir></dir><dir name="Manufactures"><dir name="Edit"><file name="Form.php" hash="cd2ca969ec9a49d65cd9fe90fffd9ead"/><dir name="Tab"><file name="Form.php" hash="d4e68f9a6ccee18243cf4a0da9b988e3"/></dir><file name="Tabs.php" hash="1d7c0e0f37ca38fc24c3e33f5a48a8e8"/></dir><file name="Edit.php" hash="9a641f8d248c2a67c0d3a8d40fe9dfd1"/><file name="Grid.php" hash="a75568f6cc0ec289cd249621efb628cd"/><dir name="Renderer"><file name="Image.php" hash="70798a9c2f8f180aebaaa3487c8817d5"/></dir></dir><file name="Manufactures.php" hash="144640a8d3823577f7680d698cc8fa94"/></dir><file name="Manufactures.php" hash="7c505770fdf0fc209ee9d46f5c7fd23d"/></dir><dir name="Helper"><file name="Data.php" hash="a0c09e65842fe2c1a3b797a2096d2843"/><dir name="Profit"><file name="Data.php" hash="3f26f1c6cae4862f7f8871f8c5d3a303"/></dir></dir><dir name="Model"><file name="Manufactures.php" hash="72edd8ade576c47b2ad3a00b9419baad"/><dir name="Mysql4"><dir name="Manufactures"><file name="Collection.php" hash="6b723ed4118e685a9ac68c121d715b34"/></dir><file name="Manufactures.php" hash="b1b22cd9d92ce74499dda8e58392fc32"/></dir><dir name="Product"><dir name="Type"><dir name="Configurable"><file name="Price.php" hash="1d0412931df1f3b18be9b90f4beebd7f"/></dir><dir name="Grouped"><file name="Price.php" hash="20ed8ae57f9968c41461a89702551ac2"/></dir><file name="Price.php" hash="fd6dd72e2c0d7cd994355ebf1e928a98"/></dir></dir><file name="Product.php" hash="a2eaebdc6c00230915ff12588df869e8"/><file name="Profit.php" hash="8fefaa0d23115eb1cff21942c53a2364"/></dir><dir name="controllers"><dir name="Adminhtml"><file name="ManufacturesController.php" hash="272eaf4f621640a51a899ccf381fef49"/></dir><file name="IndexController.php" hash="34eb171a8c52e2ce6342652fea2029bf"/><file name="ProductsController.php" hash="196f36c0c3b4cdbf0114e61a4620c9ad"/></dir><dir name="etc"><file name="config.xml" hash="9a787c38f6f9bf9217022496b6e89e5c"/><file name="system.xml" hash="38fc4d353135208ea760475fc8bc3286"/></dir><dir name="sql"><dir name="manufactures_setup"><file name="mysql4-install-0.1.0.php" hash="6a1982f52f89a867e91a53b028137032"/></dir></dir></dir></dir></target><target name="magedesign"><dir name="frontend"><dir name="base"><dir name="default"><dir name="layout"><file name="manufactures.xml" hash="8a838f42efc13a4f008303acdeece5b6"/></dir><dir name="template"><dir name="manufactures"><file name="manufactures-products.phtml" hash="06b2172737c208f1a661de6d8ae605a9"/><file name="manufactures.phtml" hash="b4ee54c5d77e9da3598ad073a7ca4bca"/></dir></dir></dir></dir></dir><dir name="adminhtml"><dir name="default"><dir name="default"><dir name="layout"><file name="manufactures.xml" hash="50ba990184a4be71515a426908188046"/></dir></dir></dir></dir></target></contents>
16
+ <compatible/>
17
+ <dependencies><required><php><min>5.2.0</min><max>6.0.0</max></php></required></dependencies>
18
+ </package>