Sitewards_PriceCheck_Framework - Version 1.0.1

Version Notes

Moved code to community pool.
Fixed issue with zero price when extension is disabled.

Download this release

Release Info

Developer Sitewards Magento Team
Extension Sitewards_PriceCheck_Framework
Version 1.0.1
Comparing to
See all releases


Code changes from version 1.0.0 to 1.0.1

app/code/{local → community}/Sitewards/PriceCheck/Helper/Data.php RENAMED
@@ -1,77 +1,77 @@
1
- <?php
2
- /**
3
- * Sitewards GmbH
4
- *
5
- * This class is used to help the Sitewards_PriceCheck_Helper_Data class and requires the following functions to be created
6
- * getBestPrice,
7
- * getGroupCode,
8
- * getPriceFromCustomer,
9
- * getPackingInfo
10
- *
11
- * @category Mage
12
- * @package Sitewards_StockCheck
13
- * @copyright Copyright (c) 2011 Sitewards GmbH. (http://www.sitewards.com)
14
- * @license OSL
15
- * @version 1.0.0
16
- */
17
- class Sitewards_PriceCheck_Helper_Data extends Mage_Core_Helper_Abstract {
18
- /**
19
- *
20
- * @param int $intQuantity requested level of quantity for a product
21
- * @param array $arrPrices an array of all avalible prices in the following format
22
- * $arrPrices[] = array(
23
- * 'price' => '1.00',
24
- * 'website_price' => '1.00',
25
- * 'price_qty' => 12,
26
- * 'cust_group' => 12
27
- * );
28
- * @param float $fltProductPrice the current product price
29
- * @return float the best price from the quantity provided
30
- */
31
- public function getBestPrice($intQuantity, $arrPrices, $fltProductPrice) {
32
- Mage::throwException('PriceCheck extension not correctly setup. Please complete the function getBestPrice in the helper '.get_class());
33
- }
34
-
35
- /**
36
- *
37
- * @param int $intGroupId the group id as stored in magento
38
- * @return string which is a unique identifier for a customer group in your system
39
- */
40
- public function getGroupCode($intGroupId) {
41
- Mage::throwException('PriceCheck extension not correctly setup. Please complete the function getGroupCode in the helper '.get_class());
42
- }
43
-
44
- /**
45
- *
46
- * @param string $strProductIdentifier unique identifier for a product - defaults to Magento ProductId
47
- * @param int $intCustomerId unique identifier for a customer - defaults to Magento CustomerId
48
- * @param boolean $bolArrayFormat to format the return in an array
49
- * @return array|float an array of price information or a single price array should be fromated as
50
- * $arrPrices[] = array(
51
- * 'price' => '1.00',
52
- * 'website_price' => '1.00',
53
- * 'price_qty' => 12,
54
- * 'cust_group' => 12
55
- * );
56
- */
57
- public function getPriceFromCustomer($strProductIdentifier, $intCustomerId, $bolArrayFormat = false) {
58
- Mage::throwException('PriceCheck extension not correctly setup. Please complete the function getPriceFromCustomer in the helper '.get_class());
59
- }
60
-
61
- /**
62
- *
63
- * @param string $strProductIdentifier unique identifier for a product - defaults to Magento ProductId
64
- * @param int $intCustomerId unique identifier for a customer - defaults to Magento CustomerId
65
- * @param boolean $bolForDebug to return all information for debug display
66
- * @return array an array of packing information should be fromated as
67
- * $arrPackingInfo = array(
68
- * 'price_per_piece' => price/pricing_unit,
69
- * 'price_per_unit' => price,
70
- * 'packing_unit' => number of items in a packing unit,
71
- * 'pricing_unit' => number of items in a pricing unit
72
- * );
73
- */
74
- public function getPackingInfo($strProductIdentifier, $intCustomerId, $bolForDebug = false) {
75
- Mage::throwException('PriceCheck extension not correctly setup. Please complete the function getPackingInfo in the helper '.get_class());
76
- }
77
  }
1
+ <?php
2
+ /**
3
+ * Sitewards GmbH
4
+ *
5
+ * This class is used to help the Sitewards_PriceCheck_Helper_Data class and requires the following functions to be created
6
+ * getBestPrice,
7
+ * getGroupCode,
8
+ * getPriceFromCustomer,
9
+ * getPackingInfo
10
+ *
11
+ * @category Mage
12
+ * @package Sitewards_StockCheck
13
+ * @copyright Copyright (c) 2011 Sitewards GmbH. (http://www.sitewards.com)
14
+ * @license OSL
15
+ * @version 1.0.0
16
+ */
17
+ class Sitewards_PriceCheck_Helper_Data extends Mage_Core_Helper_Abstract {
18
+ /**
19
+ *
20
+ * @param int $intQuantity requested level of quantity for a product
21
+ * @param array $arrPrices an array of all avalible prices in the following format
22
+ * $arrPrices[] = array(
23
+ * 'price' => '1.00',
24
+ * 'website_price' => '1.00',
25
+ * 'price_qty' => 12,
26
+ * 'cust_group' => 12
27
+ * );
28
+ * @param float $fltProductPrice the current product price
29
+ * @return float the best price from the quantity provided
30
+ */
31
+ public function getBestPrice($intQuantity, $arrPrices, $fltProductPrice) {
32
+ Mage::throwException('PriceCheck extension not correctly setup. Please complete the function getBestPrice in the helper '.get_class());
33
+ }
34
+
35
+ /**
36
+ *
37
+ * @param int $intGroupId the group id as stored in magento
38
+ * @return string which is a unique identifier for a customer group in your system
39
+ */
40
+ public function getGroupCode($intGroupId) {
41
+ Mage::throwException('PriceCheck extension not correctly setup. Please complete the function getGroupCode in the helper '.get_class());
42
+ }
43
+
44
+ /**
45
+ *
46
+ * @param string $strProductIdentifier unique identifier for a product - defaults to Magento ProductId
47
+ * @param int $intCustomerId unique identifier for a customer - defaults to Magento CustomerId
48
+ * @param boolean $bolArrayFormat to format the return in an array
49
+ * @return array|float an array of price information or a single price array should be fromated as
50
+ * $arrPrices[] = array(
51
+ * 'price' => '1.00',
52
+ * 'website_price' => '1.00',
53
+ * 'price_qty' => 12,
54
+ * 'cust_group' => 12
55
+ * );
56
+ */
57
+ public function getPriceFromCustomer($strProductIdentifier, $intCustomerId, $bolArrayFormat = false) {
58
+ Mage::throwException('PriceCheck extension not correctly setup. Please complete the function getPriceFromCustomer in the helper '.get_class());
59
+ }
60
+
61
+ /**
62
+ *
63
+ * @param string $strProductIdentifier unique identifier for a product - defaults to Magento ProductId
64
+ * @param int $intCustomerId unique identifier for a customer - defaults to Magento CustomerId
65
+ * @param boolean $bolForDebug to return all information for debug display
66
+ * @return array an array of packing information should be fromated as
67
+ * $arrPackingInfo = array(
68
+ * 'price_per_piece' => price/pricing_unit,
69
+ * 'price_per_unit' => price,
70
+ * 'packing_unit' => number of items in a packing unit,
71
+ * 'pricing_unit' => number of items in a pricing unit
72
+ * );
73
+ */
74
+ public function getPackingInfo($strProductIdentifier, $intCustomerId, $bolForDebug = false) {
75
+ Mage::throwException('PriceCheck extension not correctly setup. Please complete the function getPackingInfo in the helper '.get_class());
76
+ }
77
  }
app/code/{local → community}/Sitewards/PriceCheck/Model/Price.php RENAMED
@@ -1,248 +1,248 @@
1
- <?php
2
- /**
3
- *
4
- * @category Mage
5
- * @package Sitewards_PriceCheck
6
- * @copyright Copyright (c) 2011 Sitewards GmbH. (http://www.sitewards.com)
7
- * @license OSL
8
- * @version 1.0.0
9
- * @author David Manners <david.manners@sitewards.com>
10
- *
11
- * This class is used to disable Magento´s default Pricing calculations
12
- */
13
- class Sitewards_PriceCheck_Model_Price extends Mage_Catalog_Model_Product_Type_Price
14
- {
15
- protected $strProductIdentifierName;
16
- protected $strCustomerIdentifierName;
17
- protected $strHelperName;
18
- protected $bolExtensionActive;
19
-
20
- public function __construct() {
21
- $this->strProductIdentifierName = Mage::getStoreConfig('pricecheck_config/pricecheck_group/product_identifier_name');
22
- $this->strCustomerIdentifierName = Mage::getStoreConfig('pricecheck_config/pricecheck_group/customer_identifier_name');
23
- $this->strHelperName = Mage::getStoreConfig('pricecheck_config/pricecheck_group/helper_name');
24
- $this->bolExtensionActive = Mage::getStoreConfig('pricecheck_config/pricecheck_group/disable_ext');
25
- }
26
-
27
- /**
28
- *
29
- * @param object $objProduct
30
- * @return float custom price or magento stored price
31
- */
32
- public function getPrice($objProduct) {
33
- if($this->bolExtensionActive == true) {
34
- $intCustomerGroupId = $this->_getCustomerGroupId($objProduct);
35
- if($intCustomerGroupId != 0) {
36
- $objCustomer = Mage::getSingleton('customer/session')->getCustomer();
37
- $intCustomerId = $objCustomer->getData($this->strCustomerIdentifierName);
38
-
39
- $fltCustomPrice = $this->_getPriceForGroup($intCustomerId, $intCustomerGroupId, $objProduct);
40
- if(!is_null($fltCustomPrice)) {
41
- return $fltCustomPrice;
42
- } else {
43
- parent::getPrice($objProduct);
44
- }
45
- } else {
46
- parent::getPrice($objProduct);
47
- }
48
- } else {
49
- parent::getPrice($objProduct);
50
- }
51
- }
52
-
53
- /**
54
- *
55
- * @param int $intQuantity
56
- * @param object $objProduct
57
- * @return array of tier price information
58
- */
59
- public function getTierPrice($intQuantity = null, $objProduct) {
60
- if($this->bolExtensionActive == true) {
61
- $intCustomerGroupId = $this->_getCustomerGroupId($objProduct);
62
- if($intCustomerGroupId != 0) {
63
- $objCustomer = Mage::getSingleton('customer/session')->getCustomer();
64
- $intCustomerId = $objCustomer->getData($this->strCustomerIdentifierName);
65
-
66
- $arrPrices = $this->_getPricesForGroup($intQuantity, $intCustomerId, $intCustomerGroupId, $objProduct);
67
- if(!is_null($arrPrices)) {
68
- return $arrPrices;
69
- } else {
70
- parent::getTierPrice($intQuantity, $objProduct);
71
- }
72
- } else {
73
- parent::getTierPrice($intQuantity, $objProduct);
74
- }
75
- } else {
76
- parent::getTierPrice($intQuantity, $objProduct);
77
- }
78
- }
79
-
80
- /**
81
- *
82
- * @param int $intCustomerId
83
- * @param int $intGroupId
84
- * @param object $objProduct
85
- * @return float find a price for a product from another source
86
- */
87
- protected function _getPriceForGroup($intCustomerId, $intGroupId, $objProduct) {
88
- if(method_exists(Mage::Helper($this->strHelperName), 'getPriceFromCustomer') == false) {
89
- Mage::throwException('StockCheck extension not correctly setup. Please create the function getPriceFromCustomer in the helper '.$this->strHelperName);
90
- } elseif(method_exists(Mage::Helper($this->strHelperName), 'getGroupCode') == false) {
91
- Mage::throwException('StockCheck extension not correctly setup. Please create the function getGroupCode in the helper '.$this->strHelperName);
92
- } else {
93
- $strProductIdentifierValue = $objProduct->getData($this->strProductIdentifierName);
94
-
95
- if(is_null($strProductIdentifierValue)) {
96
- $intProductId = $objProduct->getId();
97
- $objProduct = $objProduct->load($intProductId);
98
- $strProductIdentifierValue = $objProduct->getData($this->strProductIdentifierName);
99
- }
100
-
101
- /*
102
- * First check to see if customer has a custom price
103
- */
104
- $intCustomerPrice = Mage::Helper($this->strHelperName)->getPriceFromCustomer($strProductIdentifierValue, $intCustomerId);
105
- if (!is_null($intCustomerPrice)) {
106
- return $intCustomerPrice;
107
- }
108
-
109
- /*
110
- * If not check to see if customer group has a custom price
111
- */
112
- $strGroupCode = Mage::Helper($this->strHelperName)->getGroupCode($intGroupId);
113
-
114
- $intGroupPrice = Mage::Helper($this->strHelperName)->getPriceFromCustomer($strProductIdentifierValue, $strGroupCode);
115
- if (!is_null($intGroupPrice)) {
116
- return $intGroupPrice;
117
- }
118
- }
119
- }
120
-
121
- /**
122
- *
123
- * @param int $intQuantity
124
- * @param int $intCustomerId
125
- * @param int $intGroupId
126
- * @param object $objProduct
127
- * @return array of prices for a product from another source
128
- */
129
- protected function _getPricesForGroup($intQuantity, $intCustomerId, $intGroupId, $objProduct) {
130
- if(method_exists(Mage::Helper($this->strHelperName), 'getPriceFromCustomer') == false) {
131
- Mage::throwException('StockCheck extension not correctly setup. Please create the function getPriceFromCustomer in the helper '.$this->strHelperName);
132
- } elseif(method_exists(Mage::Helper($this->strHelperName), 'getBestPrice') == false) {
133
- Mage::throwException('StockCheck extension not correctly setup. Please create the function getBestPrice in the helper '.$this->strHelperName);
134
- } else {
135
- $fltProductPrice = $objProduct->getPrice();
136
- $strProductIdentifierValue = $objProduct->getData($this->strProductIdentifierName);
137
- if(is_null($strProductIdentifierValue)) {
138
- $intProductId = $objProduct->getId();
139
- $objProduct = $objProduct->load($intProductId);
140
- $strProductIdentifierValue = $objProduct->getData($this->strProductIdentifierName);
141
- }
142
-
143
- /*
144
- * First check to see if customer has a custom price
145
- */
146
- $arrPrices = Mage::Helper($this->strHelperName)->getPriceFromCustomer($strProductIdentifierValue, $intCustomerId, true);
147
- if(!is_null($arrPrices)) {
148
- if(!is_null($intQuantity)){
149
- return Mage::Helper($this->strHelperName)->getBestPrice($intQuantity, $arrPrices, $fltProductPrice);
150
- } else {
151
- return $arrPrices;
152
- }
153
- }
154
-
155
- /*
156
- * If not check to see if customer group has a custom price
157
- */
158
- $strGroupCode = Mage::Helper($this->strHelperName)->getGroupCode($intGroupId);
159
-
160
- $arrPrices = Mage::Helper($this->strHelperName)->getPriceFromCustomer($strProductIdentifierValue, $strGroupCode, true);
161
- if(!is_null($arrPrices)) {
162
- if(!is_null($intQuantity)){
163
- return Mage::Helper($this->strHelperName)->getBestPrice($intQuantity, $arrPrices, $fltProductPrice);
164
- } else {
165
- return $arrPrices;
166
- }
167
- }
168
- }
169
- }
170
-
171
- /**
172
- *
173
- * @param object $objProduct
174
- * @return array of packing unit information for a product based on customer id or group
175
- */
176
- public function getPackingUnitInfo($objProduct) {
177
- if($this->bolExtensionActive == true) {
178
- if(method_exists(Mage::Helper($this->strHelperName), 'getGroupCode') == false) {
179
- Mage::throwException('StockCheck extension not correctly setup. Please create the function getGroupCode in the helper '.$this->strHelperName);
180
- } elseif(method_exists(Mage::Helper($this->strHelperName), 'getPackingInfo') == false) {
181
- Mage::throwException('StockCheck extension not correctly setup. Please create the function getPackingInfo in the helper '.$this->strHelperName);
182
- } else {
183
- $strProductIdentifierValue = $objProduct->getData($this->strProductIdentifierName);
184
-
185
- $objCustomer = Mage::getSingleton('customer/session')->getCustomer();
186
- $intCustomerId = $objCustomer->getData($this->strCustomerIdentifierName);
187
- $intCustomerGroupId = $objCustomer->getGroupId();
188
-
189
- /*
190
- * First check to see if customer has a custom price
191
- */
192
- $arrPackingInfo = Mage::Helper($this->strHelperName)->getPackingInfo($strProductIdentifierValue, $intCustomerId);
193
- if(!is_null($arrPackingInfo)) {
194
- return $arrPackingInfo;
195
- }
196
-
197
- /*
198
- * If not check to see if customer group has a custom price
199
- */
200
- $strGroupCode = Mage::Helper($this->strHelperName)->getGroupCode($intCustomerGroupId);
201
-
202
- $arrPackingInfo = Mage::Helper($this->strHelperName)->getPackingInfo($strProductIdentifierValue, $strGroupCode);
203
- if(!is_null($arrPackingInfo)) {
204
- return $arrPackingInfo;
205
- }
206
- }
207
- }
208
- }
209
-
210
- /**
211
- *
212
- * @param object $objProduct
213
- * @return array of pricing debug information for a product based on customer id or group
214
- */
215
- public function getDebugInfo($objProduct) {
216
- if($this->bolExtensionActive == true) {
217
- if(method_exists(Mage::Helper($this->strHelperName), 'getGroupCode') == false) {
218
- Mage::throwException('StockCheck extension not correctly setup. Please create the function getGroupCode in the helper '.$this->strHelperName);
219
- } elseif(method_exists(Mage::Helper($this->strHelperName), 'getPackingInfo') == false) {
220
- Mage::throwException('StockCheck extension not correctly setup. Please create the function getPackingInfo in the helper '.$this->strHelperName);
221
- } else {
222
- $strProductIdentifierValue = $objProduct->getData($this->strProductIdentifierName);
223
-
224
- $objCustomer = Mage::getSingleton('customer/session')->getCustomer();
225
- $intCustomerId = $objCustomer->getData($this->strCustomerIdentifierName);
226
- $intCustomerGroupId = $objCustomer->getGroupId();
227
-
228
- /*
229
- * First check to see if customer has a custom price
230
- */
231
- $arrPackingInfo = Mage::Helper($this->strHelperName)->getPackingInfo($strProductIdentifierValue, $intCustomerId, true);
232
- if(!is_null($arrPackingInfo)) {
233
- return $arrPackingInfo;
234
- }
235
-
236
- /*
237
- * If not check to see if customer group has a custom price
238
- */
239
- $strGroupCode = Mage::Helper($this->strHelperName)->getGroupCode($intCustomerGroupId);
240
-
241
- $arrPackingInfo = Mage::Helper($this->strHelperName)->getPackingInfo($strProductIdentifierValue, $strGroupCode, true);
242
- if(!is_null($arrPackingInfo)) {
243
- return $arrPackingInfo;
244
- }
245
- }
246
- }
247
- }
248
  }
1
+ <?php
2
+ /**
3
+ *
4
+ * @category Mage
5
+ * @package Sitewards_PriceCheck
6
+ * @copyright Copyright (c) 2011 Sitewards GmbH. (http://www.sitewards.com)
7
+ * @license OSL
8
+ * @version 1.0.0
9
+ * @author David Manners <david.manners@sitewards.com>
10
+ *
11
+ * This class is used to disable Magento´s default Pricing calculations
12
+ */
13
+ class Sitewards_PriceCheck_Model_Price extends Mage_Catalog_Model_Product_Type_Price
14
+ {
15
+ protected $strProductIdentifierName;
16
+ protected $strCustomerIdentifierName;
17
+ protected $strHelperName;
18
+ protected $bolExtensionActive;
19
+
20
+ public function __construct() {
21
+ $this->strProductIdentifierName = Mage::getStoreConfig('pricecheck_config/pricecheck_group/product_identifier_name');
22
+ $this->strCustomerIdentifierName = Mage::getStoreConfig('pricecheck_config/pricecheck_group/customer_identifier_name');
23
+ $this->strHelperName = Mage::getStoreConfig('pricecheck_config/pricecheck_group/helper_name');
24
+ $this->bolExtensionActive = Mage::getStoreConfig('pricecheck_config/pricecheck_group/disable_ext');
25
+ }
26
+
27
+ /**
28
+ *
29
+ * @param object $objProduct
30
+ * @return float custom price or magento stored price
31
+ */
32
+ public function getPrice($objProduct) {
33
+ if($this->bolExtensionActive == true) {
34
+ $intCustomerGroupId = $this->_getCustomerGroupId($objProduct);
35
+ if($intCustomerGroupId != 0) {
36
+ $objCustomer = Mage::getSingleton('customer/session')->getCustomer();
37
+ $intCustomerId = $objCustomer->getData($this->strCustomerIdentifierName);
38
+
39
+ $fltCustomPrice = $this->_getPriceForGroup($intCustomerId, $intCustomerGroupId, $objProduct);
40
+ if(!is_null($fltCustomPrice)) {
41
+ return $fltCustomPrice;
42
+ } else {
43
+ return parent::getPrice($objProduct);
44
+ }
45
+ } else {
46
+ return parent::getPrice($objProduct);
47
+ }
48
+ } else {
49
+ return parent::getPrice($objProduct);
50
+ }
51
+ }
52
+
53
+ /**
54
+ *
55
+ * @param int $intQuantity
56
+ * @param object $objProduct
57
+ * @return array of tier price information
58
+ */
59
+ public function getTierPrice($intQuantity = null, $objProduct) {
60
+ if($this->bolExtensionActive == true) {
61
+ $intCustomerGroupId = $this->_getCustomerGroupId($objProduct);
62
+ if($intCustomerGroupId != 0) {
63
+ $objCustomer = Mage::getSingleton('customer/session')->getCustomer();
64
+ $intCustomerId = $objCustomer->getData($this->strCustomerIdentifierName);
65
+
66
+ $arrPrices = $this->_getPricesForGroup($intQuantity, $intCustomerId, $intCustomerGroupId, $objProduct);
67
+ if(!is_null($arrPrices)) {
68
+ return $arrPrices;
69
+ } else {
70
+ return parent::getTierPrice($intQuantity, $objProduct);
71
+ }
72
+ } else {
73
+ return parent::getTierPrice($intQuantity, $objProduct);
74
+ }
75
+ } else {
76
+ return parent::getTierPrice($intQuantity, $objProduct);
77
+ }
78
+ }
79
+
80
+ /**
81
+ *
82
+ * @param int $intCustomerId
83
+ * @param int $intGroupId
84
+ * @param object $objProduct
85
+ * @return float find a price for a product from another source
86
+ */
87
+ protected function _getPriceForGroup($intCustomerId, $intGroupId, $objProduct) {
88
+ if(method_exists(Mage::helper($this->strHelperName), 'getPriceFromCustomer') == false) {
89
+ Mage::throwException('StockCheck extension not correctly setup. Please create the function getPriceFromCustomer in the helper '.$this->strHelperName);
90
+ } elseif(method_exists(Mage::helper($this->strHelperName), 'getGroupCode') == false) {
91
+ Mage::throwException('StockCheck extension not correctly setup. Please create the function getGroupCode in the helper '.$this->strHelperName);
92
+ } else {
93
+ $strProductIdentifierValue = $objProduct->getData($this->strProductIdentifierName);
94
+
95
+ if(is_null($strProductIdentifierValue)) {
96
+ $intProductId = $objProduct->getId();
97
+ $objProduct = $objProduct->load($intProductId);
98
+ $strProductIdentifierValue = $objProduct->getData($this->strProductIdentifierName);
99
+ }
100
+
101
+ /*
102
+ * First check to see if customer has a custom price
103
+ */
104
+ $intCustomerPrice = Mage::helper($this->strHelperName)->getPriceFromCustomer($strProductIdentifierValue, $intCustomerId);
105
+ if (!is_null($intCustomerPrice)) {
106
+ return $intCustomerPrice;
107
+ }
108
+
109
+ /*
110
+ * If not check to see if customer group has a custom price
111
+ */
112
+ $strGroupCode = Mage::helper($this->strHelperName)->getGroupCode($intGroupId);
113
+
114
+ $intGroupPrice = Mage::helper($this->strHelperName)->getPriceFromCustomer($strProductIdentifierValue, $strGroupCode);
115
+ if (!is_null($intGroupPrice)) {
116
+ return $intGroupPrice;
117
+ }
118
+ }
119
+ }
120
+
121
+ /**
122
+ *
123
+ * @param int $intQuantity
124
+ * @param int $intCustomerId
125
+ * @param int $intGroupId
126
+ * @param object $objProduct
127
+ * @return array of prices for a product from another source
128
+ */
129
+ protected function _getPricesForGroup($intQuantity, $intCustomerId, $intGroupId, $objProduct) {
130
+ if(method_exists(Mage::helper($this->strHelperName), 'getPriceFromCustomer') == false) {
131
+ Mage::throwException('StockCheck extension not correctly setup. Please create the function getPriceFromCustomer in the helper '.$this->strHelperName);
132
+ } elseif(method_exists(Mage::helper($this->strHelperName), 'getBestPrice') == false) {
133
+ Mage::throwException('StockCheck extension not correctly setup. Please create the function getBestPrice in the helper '.$this->strHelperName);
134
+ } else {
135
+ $fltProductPrice = $objProduct->getPrice();
136
+ $strProductIdentifierValue = $objProduct->getData($this->strProductIdentifierName);
137
+ if(is_null($strProductIdentifierValue)) {
138
+ $intProductId = $objProduct->getId();
139
+ $objProduct = $objProduct->load($intProductId);
140
+ $strProductIdentifierValue = $objProduct->getData($this->strProductIdentifierName);
141
+ }
142
+
143
+ /*
144
+ * First check to see if customer has a custom price
145
+ */
146
+ $arrPrices = Mage::helper($this->strHelperName)->getPriceFromCustomer($strProductIdentifierValue, $intCustomerId, true);
147
+ if(!is_null($arrPrices)) {
148
+ if(!is_null($intQuantity)){
149
+ return Mage::helper($this->strHelperName)->getBestPrice($intQuantity, $arrPrices, $fltProductPrice);
150
+ } else {
151
+ return $arrPrices;
152
+ }
153
+ }
154
+
155
+ /*
156
+ * If not check to see if customer group has a custom price
157
+ */
158
+ $strGroupCode = Mage::helper($this->strHelperName)->getGroupCode($intGroupId);
159
+
160
+ $arrPrices = Mage::helper($this->strHelperName)->getPriceFromCustomer($strProductIdentifierValue, $strGroupCode, true);
161
+ if(!is_null($arrPrices)) {
162
+ if(!is_null($intQuantity)){
163
+ return Mage::helper($this->strHelperName)->getBestPrice($intQuantity, $arrPrices, $fltProductPrice);
164
+ } else {
165
+ return $arrPrices;
166
+ }
167
+ }
168
+ }
169
+ }
170
+
171
+ /**
172
+ *
173
+ * @param object $objProduct
174
+ * @return array of packing unit information for a product based on customer id or group
175
+ */
176
+ public function getPackingUnitInfo($objProduct) {
177
+ if($this->bolExtensionActive == true) {
178
+ if(method_exists(Mage::helper($this->strHelperName), 'getGroupCode') == false) {
179
+ Mage::throwException('StockCheck extension not correctly setup. Please create the function getGroupCode in the helper '.$this->strHelperName);
180
+ } elseif(method_exists(Mage::helper($this->strHelperName), 'getPackingInfo') == false) {
181
+ Mage::throwException('StockCheck extension not correctly setup. Please create the function getPackingInfo in the helper '.$this->strHelperName);
182
+ } else {
183
+ $strProductIdentifierValue = $objProduct->getData($this->strProductIdentifierName);
184
+
185
+ $objCustomer = Mage::getSingleton('customer/session')->getCustomer();
186
+ $intCustomerId = $objCustomer->getData($this->strCustomerIdentifierName);
187
+ $intCustomerGroupId = $objCustomer->getGroupId();
188
+
189
+ /*
190
+ * First check to see if customer has a custom price
191
+ */
192
+ $arrPackingInfo = Mage::helper($this->strHelperName)->getPackingInfo($strProductIdentifierValue, $intCustomerId);
193
+ if(!is_null($arrPackingInfo)) {
194
+ return $arrPackingInfo;
195
+ }
196
+
197
+ /*
198
+ * If not check to see if customer group has a custom price
199
+ */
200
+ $strGroupCode = Mage::helper($this->strHelperName)->getGroupCode($intCustomerGroupId);
201
+
202
+ $arrPackingInfo = Mage::helper($this->strHelperName)->getPackingInfo($strProductIdentifierValue, $strGroupCode);
203
+ if(!is_null($arrPackingInfo)) {
204
+ return $arrPackingInfo;
205
+ }
206
+ }
207
+ }
208
+ }
209
+
210
+ /**
211
+ *
212
+ * @param object $objProduct
213
+ * @return array of pricing debug information for a product based on customer id or group
214
+ */
215
+ public function getDebugInfo($objProduct) {
216
+ if($this->bolExtensionActive == true) {
217
+ if(method_exists(Mage::helper($this->strHelperName), 'getGroupCode') == false) {
218
+ Mage::throwException('StockCheck extension not correctly setup. Please create the function getGroupCode in the helper '.$this->strHelperName);
219
+ } elseif(method_exists(Mage::helper($this->strHelperName), 'getPackingInfo') == false) {
220
+ Mage::throwException('StockCheck extension not correctly setup. Please create the function getPackingInfo in the helper '.$this->strHelperName);
221
+ } else {
222
+ $strProductIdentifierValue = $objProduct->getData($this->strProductIdentifierName);
223
+
224
+ $objCustomer = Mage::getSingleton('customer/session')->getCustomer();
225
+ $intCustomerId = $objCustomer->getData($this->strCustomerIdentifierName);
226
+ $intCustomerGroupId = $objCustomer->getGroupId();
227
+
228
+ /*
229
+ * First check to see if customer has a custom price
230
+ */
231
+ $arrPackingInfo = Mage::helper($this->strHelperName)->getPackingInfo($strProductIdentifierValue, $intCustomerId, true);
232
+ if(!is_null($arrPackingInfo)) {
233
+ return $arrPackingInfo;
234
+ }
235
+
236
+ /*
237
+ * If not check to see if customer group has a custom price
238
+ */
239
+ $strGroupCode = Mage::helper($this->strHelperName)->getGroupCode($intCustomerGroupId);
240
+
241
+ $arrPackingInfo = Mage::helper($this->strHelperName)->getPackingInfo($strProductIdentifierValue, $strGroupCode, true);
242
+ if(!is_null($arrPackingInfo)) {
243
+ return $arrPackingInfo;
244
+ }
245
+ }
246
+ }
247
+ }
248
  }
app/code/{local → community}/Sitewards/PriceCheck/etc/config.xml RENAMED
@@ -1,79 +1,79 @@
1
- <?xml version="1.0" encoding="UTF-8"?>
2
- <config>
3
- <modules>
4
- <Sitewards_PriceCheck>
5
- <version>1.0.0</version>
6
- </Sitewards_PriceCheck>
7
- </modules>
8
-
9
- <default>
10
- <pricecheck_config>
11
- <pricecheck_group>
12
- <product_identifier_name>entity_id</product_identifier_name>
13
- <customer_identifier_name>entity_id</customer_identifier_name>
14
- <disable_ext>0</disable_ext>
15
- <helper_name>pricecheck</helper_name>
16
- </pricecheck_group>
17
- </pricecheck_config>
18
- </default>
19
-
20
- <global>
21
- <models>
22
- <catalog>
23
- <rewrite>
24
- <product_type_price>Sitewards_PriceCheck_Model_Price</product_type_price>
25
- </rewrite>
26
- </catalog>
27
- </models>
28
- <helpers>
29
- <pricecheck>
30
- <class>Sitewards_PriceCheck_Helper</class>
31
- </pricecheck>
32
- </helpers>
33
- </global>
34
-
35
- <adminhtml>
36
- <acl>
37
- <resources>
38
- <admin>
39
- <children>
40
- <catalog>
41
- <children>
42
- <pricecheck_adminform>
43
- <title>Configuration</title>
44
- </pricecheck_adminform>
45
- </children>
46
- </catalog>
47
- </children>
48
- </admin>
49
- </resources>
50
- </acl>
51
- <acl>
52
- <resources>
53
- <admin>
54
- <children>
55
- <system>
56
- <children>
57
- <config>
58
- <children>
59
- <pricecheck_config>
60
- <title>Sitewards Price Check</title>
61
- </pricecheck_config>
62
- </children>
63
- </config>
64
- </children>
65
- </system>
66
- <catalog>
67
- <children>
68
- <pricecheck_config translate="title">
69
- <title>Sitewards Price Check</title>
70
- <sort_order>45</sort_order>
71
- </pricecheck_config>
72
- </children>
73
- </catalog>
74
- </children>
75
- </admin>
76
- </resources>
77
- </acl>
78
- </adminhtml>
79
- </config>
1
+ <?xml version="1.0" encoding="UTF-8"?>
2
+ <config>
3
+ <modules>
4
+ <Sitewards_PriceCheck>
5
+ <version>1.0.1</version>
6
+ </Sitewards_PriceCheck>
7
+ </modules>
8
+
9
+ <default>
10
+ <pricecheck_config>
11
+ <pricecheck_group>
12
+ <product_identifier_name>entity_id</product_identifier_name>
13
+ <customer_identifier_name>entity_id</customer_identifier_name>
14
+ <disable_ext>0</disable_ext>
15
+ <helper_name>pricecheck</helper_name>
16
+ </pricecheck_group>
17
+ </pricecheck_config>
18
+ </default>
19
+
20
+ <global>
21
+ <models>
22
+ <catalog>
23
+ <rewrite>
24
+ <product_type_price>Sitewards_PriceCheck_Model_Price</product_type_price>
25
+ </rewrite>
26
+ </catalog>
27
+ </models>
28
+ <helpers>
29
+ <pricecheck>
30
+ <class>Sitewards_PriceCheck_Helper</class>
31
+ </pricecheck>
32
+ </helpers>
33
+ </global>
34
+
35
+ <adminhtml>
36
+ <acl>
37
+ <resources>
38
+ <admin>
39
+ <children>
40
+ <catalog>
41
+ <children>
42
+ <pricecheck_adminform>
43
+ <title>Configuration</title>
44
+ </pricecheck_adminform>
45
+ </children>
46
+ </catalog>
47
+ </children>
48
+ </admin>
49
+ </resources>
50
+ </acl>
51
+ <acl>
52
+ <resources>
53
+ <admin>
54
+ <children>
55
+ <system>
56
+ <children>
57
+ <config>
58
+ <children>
59
+ <pricecheck_config>
60
+ <title>Sitewards Price Check</title>
61
+ </pricecheck_config>
62
+ </children>
63
+ </config>
64
+ </children>
65
+ </system>
66
+ <catalog>
67
+ <children>
68
+ <pricecheck_config translate="title">
69
+ <title>Sitewards Price Check</title>
70
+ <sort_order>45</sort_order>
71
+ </pricecheck_config>
72
+ </children>
73
+ </catalog>
74
+ </children>
75
+ </admin>
76
+ </resources>
77
+ </acl>
78
+ </adminhtml>
79
+ </config>
app/code/{local → community}/Sitewards/PriceCheck/etc/system.xml RENAMED
@@ -1,61 +1,61 @@
1
- <?xml version="1.0" encoding="UTF-8"?>
2
- <config>
3
- <sections>
4
- <pricecheck_config translate="label comment" module="pricecheck">
5
- <tab>catalog</tab>
6
- <label>Sitewards Price Check</label>
7
- <frontend_type>text</frontend_type>
8
- <sort_order>202</sort_order>
9
- <show_in_default>1</show_in_default>
10
- <show_in_website>1</show_in_website>
11
- <show_in_store>1</show_in_store>
12
- <groups>
13
- <pricecheck_group translate="label" module="pricecheck">
14
- <label>Sitewards Price Check</label>
15
- <sort_order>768</sort_order>
16
- <show_in_default>1</show_in_default>
17
- <show_in_website>1</show_in_website>
18
- <show_in_store>1</show_in_store>
19
- <fields>
20
- <disable_ext translate="label" module="pricecheck">
21
- <label>Enable Sitewards Price Check</label>
22
- <frontend_type>select</frontend_type>
23
- <source_model>adminhtml/system_config_source_yesno</source_model>
24
- <sort_order>1</sort_order>
25
- <show_in_default>1</show_in_default>
26
- <show_in_website>1</show_in_website>
27
- <show_in_store>1</show_in_store>
28
- </disable_ext>
29
- <product_identifier_name translate="label" module="pricecheck">
30
- <label>Product Identifier</label>
31
- <frontend_type>text</frontend_type>
32
- <sort_order>2</sort_order>
33
- <show_in_default>1</show_in_default>
34
- <show_in_website>1</show_in_website>
35
- <show_in_store>1</show_in_store>
36
- <comment><![CDATA[Attribute on which to identify your products]]></comment>
37
- </product_identifier_name>
38
- <customer_identifier_name translate="label" module="pricecheck">
39
- <label>Customer Identifier</label>
40
- <frontend_type>text</frontend_type>
41
- <sort_order>3</sort_order>
42
- <show_in_default>1</show_in_default>
43
- <show_in_website>1</show_in_website>
44
- <show_in_store>1</show_in_store>
45
- <comment><![CDATA[Attribute on which to identify your customers]]></comment>
46
- </customer_identifier_name>
47
- <helper_name translate="label" module="pricecheck">
48
- <label>Helper Name</label>
49
- <frontend_type>text</frontend_type>
50
- <sort_order>4</sort_order>
51
- <show_in_default>1</show_in_default>
52
- <show_in_website>1</show_in_website>
53
- <show_in_store>1</show_in_store>
54
- <comment><![CDATA[Allows you to specify a custom helper class outside of the pricecheck extension]]></comment>
55
- </helper_name>
56
- </fields>
57
- </pricecheck_group>
58
- </groups>
59
- </pricecheck_config>
60
- </sections>
61
  </config>
1
+ <?xml version="1.0" encoding="UTF-8"?>
2
+ <config>
3
+ <sections>
4
+ <pricecheck_config translate="label comment" module="pricecheck">
5
+ <tab>catalog</tab>
6
+ <label>Sitewards Price Check</label>
7
+ <frontend_type>text</frontend_type>
8
+ <sort_order>202</sort_order>
9
+ <show_in_default>1</show_in_default>
10
+ <show_in_website>1</show_in_website>
11
+ <show_in_store>1</show_in_store>
12
+ <groups>
13
+ <pricecheck_group translate="label" module="pricecheck">
14
+ <label>Sitewards Price Check</label>
15
+ <sort_order>768</sort_order>
16
+ <show_in_default>1</show_in_default>
17
+ <show_in_website>1</show_in_website>
18
+ <show_in_store>1</show_in_store>
19
+ <fields>
20
+ <disable_ext translate="label" module="pricecheck">
21
+ <label>Enable Sitewards Price Check</label>
22
+ <frontend_type>select</frontend_type>
23
+ <source_model>adminhtml/system_config_source_yesno</source_model>
24
+ <sort_order>1</sort_order>
25
+ <show_in_default>1</show_in_default>
26
+ <show_in_website>1</show_in_website>
27
+ <show_in_store>1</show_in_store>
28
+ </disable_ext>
29
+ <product_identifier_name translate="label" module="pricecheck">
30
+ <label>Product Identifier</label>
31
+ <frontend_type>text</frontend_type>
32
+ <sort_order>2</sort_order>
33
+ <show_in_default>1</show_in_default>
34
+ <show_in_website>1</show_in_website>
35
+ <show_in_store>1</show_in_store>
36
+ <comment><![CDATA[Attribute on which to identify your products]]></comment>
37
+ </product_identifier_name>
38
+ <customer_identifier_name translate="label" module="pricecheck">
39
+ <label>Customer Identifier</label>
40
+ <frontend_type>text</frontend_type>
41
+ <sort_order>3</sort_order>
42
+ <show_in_default>1</show_in_default>
43
+ <show_in_website>1</show_in_website>
44
+ <show_in_store>1</show_in_store>
45
+ <comment><![CDATA[Attribute on which to identify your customers]]></comment>
46
+ </customer_identifier_name>
47
+ <helper_name translate="label" module="pricecheck">
48
+ <label>Helper Name</label>
49
+ <frontend_type>text</frontend_type>
50
+ <sort_order>4</sort_order>
51
+ <show_in_default>1</show_in_default>
52
+ <show_in_website>1</show_in_website>
53
+ <show_in_store>1</show_in_store>
54
+ <comment><![CDATA[Allows you to specify a custom helper class outside of the pricecheck extension]]></comment>
55
+ </helper_name>
56
+ </fields>
57
+ </pricecheck_group>
58
+ </groups>
59
+ </pricecheck_config>
60
+ </sections>
61
  </config>
app/etc/modules/Sitewards_PriceCheck.xml CHANGED
@@ -1,9 +1,12 @@
1
- <?xml version="1.0"?>
2
- <config>
3
- <modules>
4
- <Sitewards_PriceCheck>
5
- <active>true</active>
6
- <codePool>local</codePool>
7
- </Sitewards_PriceCheck>
8
- </modules>
 
 
 
9
  </config>
1
+ <?xml version="1.0"?>
2
+ <config>
3
+ <modules>
4
+ <Sitewards_PriceCheck>
5
+ <active>true</active>
6
+ <codePool>community</codePool>
7
+ <depends>
8
+ <Mage_Catalog />
9
+ </depends>
10
+ </Sitewards_PriceCheck>
11
+ </modules>
12
  </config>
package.xml CHANGED
@@ -1,19 +1,21 @@
1
  <?xml version="1.0"?>
2
  <package>
3
  <name>Sitewards_PriceCheck_Framework</name>
4
- <version>1.0.0</version>
5
  <stability>stable</stability>
6
- <license>OSL v3.0</license>
7
  <channel>community</channel>
8
  <extends/>
9
- <summary>This extension provides an easy to use framework for overriding the standard Magento Product price model. It is ideal for loading a realtime price from another datasoure.</summary>
10
  <description>This extension is aimed at developers who want to load the price of a product in realtime from another source.&#xD;
11
  Coding is required but can be provided at a cost.</description>
12
- <notes>This is the stable release of this framework. Feel free to contact us with any questions or suggestions.</notes>
13
- <authors><author><name>Sitewards GmbH</name><user>sitewards</user><email>mail@sitewards.com</email></author></authors>
14
- <date>2012-02-28</date>
15
- <time>14:29:57</time>
16
- <contents><target name="magelocal"><dir name="Sitewards"><dir name="PriceCheck"><dir name="Helper"><file name="Data.php" hash="30a615a4c0117e945444d6e2ab9ba28c"/></dir><dir name="Model"><file name="Price.php" hash="38ae698ed4b6215bfd069844757a3bfb"/></dir><dir name="etc"><file name="config.xml" hash="b87b12f0c395c8630a0acf9dc5995578"/><file name="system.xml" hash="67e4f14ce24364afe057cd43ad9576b9"/></dir></dir></dir></target><target name="mageetc"><dir name="modules"><file name="Sitewards_PriceCheck.xml" hash="19a77afa7bdea2f9232c4abc8f60c0ca"/></dir></target></contents>
 
 
17
  <compatible/>
18
  <dependencies><required><php><min>5.2.0</min><max>6.0.0</max></php></required></dependencies>
19
  </package>
1
  <?xml version="1.0"?>
2
  <package>
3
  <name>Sitewards_PriceCheck_Framework</name>
4
+ <version>1.0.1</version>
5
  <stability>stable</stability>
6
+ <license uri="http://www.opensource.org/licenses/gpl-license.php">GPL</license>
7
  <channel>community</channel>
8
  <extends/>
9
+ <summary>This extension provides an easy to use framework for overriding the standard Magento Product price model.</summary>
10
  <description>This extension is aimed at developers who want to load the price of a product in realtime from another source.&#xD;
11
  Coding is required but can be provided at a cost.</description>
12
+ <notes>Moved code to community pool.&#xD;
13
+ Fixed issue with zero price when extension is disabled.&#xD;
14
+ </notes>
15
+ <authors><author><name>Sitewards Magento Team</name><user>sitewards</user><email>magento@sitewards.com</email></author></authors>
16
+ <date>2013-10-10</date>
17
+ <time>14:17:24</time>
18
+ <contents><target name="magecommunity"><dir name="Sitewards"><dir name="PriceCheck"><dir name="Helper"><file name="Data.php" hash="29a965587da9aee7a73dd61c35f925b2"/></dir><dir name="Model"><file name="Price.php" hash="462d9ec4a7c09cd346f250d066b66c5b"/></dir><dir name="etc"><file name="config.xml" hash="aaac92fa5ca4b0595f2fb58a361e9cfb"/><file name="system.xml" hash="8a756b93aa7ccfe9769d6cb1f3a567f5"/></dir></dir></dir></target><target name="mageetc"><dir name="modules"><file name="Sitewards_PriceCheck.xml" hash="bc09b03f9ea2eab9f797b7deb8c1b256"/></dir></target></contents>
19
  <compatible/>
20
  <dependencies><required><php><min>5.2.0</min><max>6.0.0</max></php></required></dependencies>
21
  </package>