Beecoder_Beeshopy - Version 2.4.8

Version Notes

Cleaning code

Download this release

Release Info

Developer Magento Core Team
Extension Beecoder_Beeshopy
Version 2.4.8
Comparing to
See all releases


Code changes from version 2.4.7 to 2.4.8

app/code/community/Beecoder/Beeshopy/Block/Track.php CHANGED
@@ -1,39 +1,49 @@
1
  <?php
2
- class Beecoder_Beeshopy_Block_Track extends Mage_Core_Block_Template {
 
 
 
 
 
 
 
 
 
 
 
3
 
4
  public function getOrder()
5
  {
6
- if ($this->_order === null) {
7
- $orderId = Mage::getSingleton('checkout/session')->getLastOrderId();
8
- if ($orderId) {
9
- $order = Mage::getModel('sales/order')->load($orderId);
10
- if ($order->getId()) {
11
- $this->_order = $order;
12
- }
13
- }
14
  }
15
- return $this->_order;
 
16
  }
17
 
18
- public function trackingCode(){
19
- $beetailer_ref = Mage::getModel('core/cookie')->get("beetailer_ref");
20
- $beetailer_ref_date = Mage::getModel('core/cookie')->get("beetailer_ref_date");
 
21
 
22
- if($order = $this->getOrder()){
23
  $res = '<script type="text/javascript" src=\'//www.beetailer.com/s.js'.
24
- '?p[order_number]='.$order->getIncrementId().
25
- '&p[amount]='.urlencode(sprintf("%.2f", $order->getSubtotal())).
26
- '&p[order_date]='.urlencode($order->getCreatedAt()).
27
- '&p[email]='.urlencode($order->getCustomerEmail()).
28
- '&p[beetailer_ref]='.urlencode($beetailer_ref).
29
- '&p[beetailer_ref_date]='.urlencode($beetailer_ref_date).
30
- '&p[shop_domain]='.urlencode(Mage::getBaseURL()).
31
- '\'></script>';
32
 
33
- Mage::getModel('core/cookie')->delete("beetailer_ref");
34
  }
35
  return $res;
36
  }
37
-
38
  }
39
- ?>
1
  <?php
2
+ /**
3
+ * Beetailer checkout tracking code
4
+ *
5
+ * @category Beetailer
6
+ * @package Beecoder_Beeshopy
7
+ */
8
+
9
+
10
+ class Beecoder_Beeshopy_Block_Track extends Mage_Core_Block_Template
11
+ {
12
+
13
+ private $_order = null;
14
 
15
  public function getOrder()
16
  {
17
+ if ($this->_order === null) {
18
+ $orderId = Mage::getSingleton('checkout/session')->getLastOrderId();
19
+ if ($orderId) {
20
+ $order = Mage::getModel('sales/order')->load($orderId);
21
+ if ($order->getId()) {
22
+ $this->_order = $order;
23
+ }
 
24
  }
25
+ }
26
+ return $this->_order;
27
  }
28
 
29
+ public function trackingCode()
30
+ {
31
+ $beetailerRef = Mage::getModel('core/cookie')->get('beetailer_ref');
32
+ $beetailerRefDate = Mage::getModel('core/cookie')->get('beetailer_ref_date');
33
 
34
+ if ($order = $this->getOrder()) {
35
  $res = '<script type="text/javascript" src=\'//www.beetailer.com/s.js'.
36
+ '?p[order_number]='.$order->getIncrementId().
37
+ '&p[amount]='.urlencode(sprintf("%.2f", $order->getSubtotal())).
38
+ '&p[order_date]='.urlencode($order->getCreatedAt()).
39
+ '&p[email]='.urlencode($order->getCustomerEmail()).
40
+ '&p[beetailer_ref]='.urlencode($beetailerRef).
41
+ '&p[beetailer_ref_date]='.urlencode($beetailerRefDate).
42
+ '&p[shop_domain]='.urlencode(Mage::getBaseURL()).
43
+ '\'></script>';
44
 
45
+ Mage::getModel('core/cookie')->delete('beetailer_ref');
46
  }
47
  return $res;
48
  }
 
49
  }
 
app/code/community/Beecoder/Beeshopy/Helper/Data.php CHANGED
@@ -1,4 +1,12 @@
1
  <?php
 
 
 
 
 
 
 
 
2
  class Beecoder_Beeshopy_Helper_Data extends Mage_Core_Helper_Abstract
3
  {
4
 
1
  <?php
2
+ /**
3
+ * Beetailer Data helper
4
+ *
5
+ * @category Beetailer
6
+ * @package Beecoder_Beeshopy
7
+ */
8
+
9
+
10
  class Beecoder_Beeshopy_Helper_Data extends Mage_Core_Helper_Abstract
11
  {
12
 
app/code/community/Beecoder/Beeshopy/Model/.Api.php.swp DELETED
Binary file
app/code/community/Beecoder/Beeshopy/Model/Api.php CHANGED
@@ -1,232 +1,245 @@
1
  <?php
2
- class Beecoder_Beeshopy_Model_Api extends Mage_Catalog_Model_Api_Resource
 
 
 
 
 
 
3
 
 
4
  {
5
- /* Get beeshopy needed product information*/
6
- public function productInfo($productId, $store = null, $identifierType = null){
7
- /* Load Product */
8
- $product = $this->_getProduct($productId, $store, $identifierType);
9
-
10
- if (!$product->getId()) {
11
- $this->_fault('not_exists');
12
- }
 
 
 
 
 
13
 
14
- $result = $this->getProductInfo($product, $store);
15
- /* Children and related products*/
16
- $result += $this->children($product, $store);
17
 
18
- return $result;
 
 
 
 
 
19
  }
20
 
21
- public function categoryTree($parentId, $store = null){
22
- if (is_null($parentId) && !is_null($store)) {
23
- $parentId = Mage::app()->getStore($this->_getStoreId($store))->getRootCategoryId();
24
- } elseif (is_null($parentId)) {
25
- $parentId = 1;
26
- }
27
 
28
- $tree = Mage::getResourceSingleton('catalog/category_tree')
29
- ->load();
30
 
31
- $root = $tree->getNodeById($parentId);
 
 
32
 
33
- if($root && $root->getId() == 1) {
34
- $root->setName(Mage::helper('catalog')->__('Root'));
35
- }
 
 
36
 
37
- $collection = Mage::getModel('catalog/category')->getCollection()
38
- ->setStoreId($this->_getStoreId($store))
39
- ->addAttributeToSelect('name')
40
- ->setLoadProductCount(true)
41
- ->addAttributeToSelect('is_active');
42
 
43
- $tree->addCollectionData($collection, true);
 
44
 
45
- return $this->_nodeToArray($root);
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
46
  }
47
 
48
- public function assignedProducts($categoryId, $store = null)
49
- {
50
- $category = Mage::getModel('catalog/category')->load($categoryId);
51
-
52
- $collection = $category->setStoreId($this->_getStoreId($store))
53
- ->getProductCollection()
54
- ->addAttributeToSelect('name')
55
- ->addAttributeToSelect('visibility')
56
- ->setOrder(Mage::getStoreConfig('catalog/frontend/default_sort_by'), 'asc');
57
-
58
- $result = array();
59
-
60
- foreach ($collection as $product) {
61
- $result[] = array(
62
- 'product_id' => $product->getId(),
63
- 'visibility' => $product->getVisibility(),
64
- 'type' => $product->getTypeId(),
65
- 'sku' => $product->getSku(),
66
- 'title' => $product->getName()
67
- );
68
- }
69
-
70
- return $result;
71
- }
72
 
73
- /* Get system info such as currency, rates, ... */
74
- public function systemInfo(){
75
- $currencyModel = Mage::getModel('Mage_Directory_Model_Currency');
76
- $store_views = array();
77
- $default_store_view = Mage::app()->getDefaultStoreView()->getId();
78
- /* Store views */
79
- foreach(Mage::app()->getStores() as $sview){
80
- if($sview->getIsActive() == 1 || $sview->getId() == $default_store_view){
81
- $includes_taxes = Mage::helper('tax')->priceIncludesTax($sview);
82
- $store_views[$sview->getId()] = array('id' => $sview->getId(), 'name' => $sview->getName(), 'code' => $sview->getCode(), 'root_category_id' => $sview->getRootCategoryId(), 'taxes_included' => $includes_taxes);
83
- /* Currencies */
84
- $store_views[$sview->getId()]['currencies'] = array();
85
- $base = $sview->getBaseCurrency()->getCode();
86
-
87
- foreach($sview->getAvailableCurrencyCodes() as $code){
88
- $default = $sview->getDefaultCurrencyCode() == $code ? true : false;
89
- $currency = $currencyModel->load($code);
90
- /* No ratio defined */
91
- $ratios = $currencyModel->getCurrencyRates($base, $code);
92
- if($ratios == NULL){$ratios = array($code => 1);}
93
- /* EO No ratio*/
94
- array_push($store_views[$sview->getId()]['currencies'],
95
- array("default" => $default, 'ratio' => $ratios, 'format' => $currency->getOutputFormat()));
96
- }
97
  }
98
  }
99
- return array('store_views' => $store_views, 'include_url_code' => Mage::getStoreConfig('web/url/use_store'));
100
  }
 
 
101
 
102
- /* Used to know if module is installed*/
103
- public function checkModule(){
104
- return array("api_version" => '2.4.7', "magento_version" => Mage::getVersion());
 
 
105
 
106
- }
107
- /*Auxiliar functions*/
108
 
109
- /* Get configurable/grouped and related children information */
110
- private function children($parent, $store = null, $identifierType = null)
 
 
111
  {
112
- try
113
- {
114
- $res['children'] = array();
115
- $res['related'] = array();
116
-
117
- /* Related products */
118
- foreach($parent->getRelatedProductIds() as $product_id){
119
- $product = $this->_getProduct($product_id, $store, $identifierType);
120
 
121
- if($product->isSalable() != false){
122
- array_push($res['related'], $this->getProductInfo($product, $store));
123
- }
124
- }
125
 
126
- switch($parent->getTypeId()){
127
- case("configurable"):
128
- $res["children"] = $this->configurableProducts($parent, $store, $identifierType);
129
- break;
130
- case("grouped"):
131
- $res["children"] = $this->groupedProducts($parent, $store, $identifierType);
132
- break;
133
  }
134
-
135
- return $res;
136
  }
137
- catch (Mage_Core_Exception $e)
138
- {
139
- $this->_fault('store_not_exists');
 
 
 
 
 
140
  }
 
 
 
 
 
 
141
  }
 
142
 
143
- private function getProductInfo($product, $store = null, $extra_params = array()){
144
- /* Images */
145
- $image_class = Mage::getModel('Mage_Catalog_Model_Product_Attribute_Media_Api');
146
- $images = $image_class->items($product->getId(), $store);
147
-
148
- /* Custom Options */
149
- $options = $this->getCustomOptions($product);
150
- $links = $this->getDownloadableLinks($product);
151
-
152
- /* Prepare results */
153
- $result = array(
154
- 'idx' => $product->getId(),
155
- 'sku' => $product->getSku(),
156
- 'product_type' => $product->getTypeId(),
157
- 'body' => $product->getInDepth(),
158
- 'description' => $product->getDescription(),
159
- 'short_description' => $product->getShortDescription(),
160
- 'title' => $product->getName(),
161
- 'in_stock' => $product->getStockItem()->getIsInStock(),
162
- 'qty' => $product->getStockItem()->getQty(),
163
- 'price' => $product->getPrice(),
164
- 'permalink' => $product->getUrlPath(),
165
- 'url_in_store' => $product->getProductUrl(),
166
- 'images' => $images,
167
- 'visibility' => $product->getVisibility(),
168
- 'special_price' => $product->getSpecialPrice(),
169
- 'special_from_date' => $product->getSpecialFromDate(),
170
- 'special_to_date' => $product->getSpecialToDate(),
171
- 'custom_options' => $options,
172
- 'status' => $product->getStatus(),
173
- 'links' => $links
174
- );
 
 
 
 
 
175
 
176
- // Optional extra parameters
177
- return $result + $extra_params;
178
- }
 
 
 
 
 
 
 
179
 
180
- /* Get configurable products */
181
- private function configurableProducts($parent, $store = null, $identifierType = null){
182
- $res = array();
183
-
184
- /* Check if using magento-configurable-simple module */
185
- $modules = Mage::getConfig()->getNode('modules')->children();
186
- $modulesArray = (array)$modules;
187
- $use_simple_configurable = (isset($modulesArray['OrganicInternet_SimpleConfigurableProducts']) && $modulesArray['OrganicInternet_SimpleConfigurableProducts']->is('active')) ? true : false;
188
- /* EO Check */
189
-
190
- /* Get configurable attributes */
191
- $attrs_codes = $parent->getTypeInstance()->getConfigurableAttributesAsArray();
192
- /* Get all children */
193
- $children = $parent->getTypeInstance()->getChildrenIds($parent->getId());
194
-
195
- foreach ($children[0] as $i => $value) {
196
- $product = $this->_getProduct($value, $store, $identifierType);
197
- /* Initial Price */
198
-
199
- $price = $use_simple_configurable ? $product->getFinalPrice() : $parent->getFinalPrice();
200
- /* Price Difference */
201
- $difference = 0;
202
- //Generate caption_name
203
- $caption = "";
204
- $configurable_options = array();
205
- foreach($attrs_codes as $code){
206
- $caption .= $product->getResource()->getAttribute($code['attribute_code'])->getFrontend()->getValue($product) . " - ";
207
- $attr_value = $product->getData($code['attribute_code']);
208
- /* Calculate price */
209
- foreach($code['values'] as $value){
210
- if($value['value_index'] == $attr_value) {
211
- $configurable_options[$code['attribute_id']] = $attr_value;
212
- if($value["is_percent"] == 1){
213
- $difference += ($price * $value['pricing_value']) / 100;
214
- }else{
215
- $difference += $value['pricing_value'];
216
- }
217
  }
218
  }
219
  }
220
-
221
- if($product->isSalable() != false){
222
- array_push($res, $this->getProductInfo($product, $store, array('caption_name' => $caption,
223
- 'configurable_price' => $price + $difference, 'configurable_options' => $configurable_options)));
224
  }
225
- }
226
- return $res;
 
 
 
227
  }
 
 
228
 
229
- private function groupedProducts($parent, $store = null, $identifierType = null){
 
230
  $res = array();
231
  $children = $parent->getTypeInstance()->getChildrenIds($parent->getId());
232
  foreach ($children[3] as $i => $value) {
@@ -238,7 +251,8 @@ class Beecoder_Beeshopy_Model_Api extends Mage_Catalog_Model_Api_Resource
238
  return $res;
239
  }
240
 
241
- private function getCustomOptions($product){
 
242
  $options = array();
243
  $customOptions = $product->getOptions();
244
  foreach ($customOptions as $customOption) {
@@ -280,23 +294,22 @@ class Beecoder_Beeshopy_Model_Api extends Mage_Catalog_Model_Api_Resource
280
  }
281
  return $links_res;
282
  }
 
283
  protected function _nodeToArray(Varien_Data_Tree_Node $node)
284
- {
285
- $result = array();
286
- $result['category_id'] = $node->getId();
287
- $result['parent_id'] = $node->getParentId();
288
- $result['name'] = $node->getName();
289
- $result['is_active'] = $node->getIsActive();
290
- $result['position'] = $node->getPosition();
291
- $result['level'] = $node->getLevel();
292
- $result['product_count'] = $node->getProductCount();
293
- $result['children'] = array();
294
-
295
- foreach ($node->getChildren() as $child) {
296
- $result['children'][] = $this->_nodeToArray($child);
297
- }
298
- return $result;
299
  }
 
 
300
  }
301
-
302
- ?>
1
  <?php
2
+ /**
3
+ * Beetailer Custom API
4
+ *
5
+ * @category Beetailer
6
+ * @package Beecoder_Beeshopy
7
+ */
8
+
9
 
10
+ class Beecoder_Beeshopy_Model_Api extends Mage_Catalog_Model_Api_Resource
11
  {
12
+ /** Get beeshopy needed product information */
13
+ public function productInfo($productId, $store = null, $identifierType = null)
14
+ {
15
+ /* Load Product */
16
+ $product = $this->_getProduct($productId, $store, $identifierType);
17
+
18
+ if (!$product->getId()) {
19
+ $this->_fault('not_exists');
20
+ }
21
+
22
+ $result = $this->getProductInfo($product, $store);
23
+ /* Children and related products*/
24
+ $result += $this->children($product, $store);
25
 
26
+ return $result;
27
+ }
 
28
 
29
+ public function categoryTree($parentId, $store = null)
30
+ {
31
+ if (is_null($parentId) && !is_null($store)) {
32
+ $parentId = Mage::app()->getStore($this->_getStoreId($store))->getRootCategoryId();
33
+ } elseif (is_null($parentId)) {
34
+ $parentId = 1;
35
  }
36
 
37
+ $tree = Mage::getResourceSingleton('catalog/category_tree')->load();
 
 
 
 
 
38
 
39
+ $root = $tree->getNodeById($parentId);
 
40
 
41
+ if ($root && $root->getId() == 1) {
42
+ $root->setName(Mage::helper('catalog')->__('Root'));
43
+ }
44
 
45
+ $collection = Mage::getModel('catalog/category')->getCollection()
46
+ ->setStoreId($this->_getStoreId($store))
47
+ ->addAttributeToSelect('name')
48
+ ->setLoadProductCount(true)
49
+ ->addAttributeToSelect('is_active');
50
 
51
+ $tree->addCollectionData($collection, true);
 
 
 
 
52
 
53
+ return $this->_nodeToArray($root);
54
+ }
55
 
56
+ public function assignedProducts($categoryId, $store = null)
57
+ {
58
+ $category = Mage::getModel('catalog/category')->load($categoryId);
59
+
60
+ $collection = $category->setStoreId($this->_getStoreId($store))
61
+ ->getProductCollection()
62
+ ->addAttributeToSelect('name')
63
+ ->addAttributeToSelect('visibility')
64
+ ->setOrder(Mage::getStoreConfig('catalog/frontend/default_sort_by'), 'asc');
65
+
66
+ $result = array();
67
+
68
+ foreach ($collection as $product) {
69
+ $result[] = array(
70
+ 'product_id' => $product->getId(),
71
+ 'visibility' => $product->getVisibility(),
72
+ 'type' => $product->getTypeId(),
73
+ 'sku' => $product->getSku(),
74
+ 'title' => $product->getName()
75
+ );
76
  }
77
 
78
+ return $result;
79
+ }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
80
 
81
+ /** Get system info such as currency, rates, ... */
82
+ public function systemInfo()
83
+ {
84
+ $currencyModel = Mage::getModel('directory/currency');
85
+ $store_views = array();
86
+ $default_store_view = Mage::app()->getDefaultStoreView()->getId();
87
+ /* Store views */
88
+ foreach(Mage::app()->getStores() as $sview){
89
+ if($sview->getIsActive() == 1 || $sview->getId() == $default_store_view){
90
+ $includes_taxes = Mage::helper('tax')->priceIncludesTax($sview);
91
+ $store_views[$sview->getId()] = array('id' => $sview->getId(), 'name' => $sview->getName(), 'code' => $sview->getCode(), 'root_category_id' => $sview->getRootCategoryId(), 'taxes_included' => $includes_taxes);
92
+ /* Currencies */
93
+ $store_views[$sview->getId()]['currencies'] = array();
94
+ $base = $sview->getBaseCurrency()->getCode();
95
+
96
+ foreach($sview->getAvailableCurrencyCodes() as $code){
97
+ $default = $sview->getDefaultCurrencyCode() == $code ? true : false;
98
+ $currency = $currencyModel->load($code);
99
+ /* No ratio defined */
100
+ $ratios = $currencyModel->getCurrencyRates($base, $code);
101
+ if($ratios == NULL){$ratios = array($code => 1);}
102
+ /* EO No ratio*/
103
+ array_push($store_views[$sview->getId()]['currencies'],
104
+ array("default" => $default, 'ratio' => $ratios, 'format' => $currency->getOutputFormat()));
105
  }
106
  }
 
107
  }
108
+ return array('store_views' => $store_views, 'include_url_code' => Mage::getStoreConfig('web/url/use_store'));
109
+ }
110
 
111
+ /* Used to know if module is installed*/
112
+ public function checkModule()
113
+ {
114
+ return array("api_version" => '2.4.8', "magento_version" => Mage::getVersion());
115
+ }
116
 
117
+ /*Auxiliar functions*/
 
118
 
119
+ /** Get configurable/grouped and related children information */
120
+ private function children($parent, $store = null, $identifierType = null)
121
+ {
122
+ try
123
  {
124
+ $res['children'] = array();
125
+ $res['related'] = array();
 
 
 
 
 
 
126
 
127
+ /* Related products */
128
+ foreach($parent->getRelatedProductIds() as $product_id){
129
+ $product = $this->_getProduct($product_id, $store, $identifierType);
 
130
 
131
+ if($product->isSalable() != false){
132
+ array_push($res['related'], $this->getProductInfo($product, $store));
 
 
 
 
 
133
  }
 
 
134
  }
135
+
136
+ switch($parent->getTypeId()){
137
+ case("configurable"):
138
+ $res["children"] = $this->configurableProducts($parent, $store, $identifierType);
139
+ break;
140
+ case("grouped"):
141
+ $res["children"] = $this->groupedProducts($parent, $store, $identifierType);
142
+ break;
143
  }
144
+
145
+ return $res;
146
+ }
147
+ catch (Mage_Core_Exception $e)
148
+ {
149
+ $this->_fault('store_not_exists');
150
  }
151
+ }
152
 
153
+ private function getProductInfo($product, $store = null, $extra_params = array())
154
+ {
155
+ /* Images */
156
+ $image_class = Mage::getModel('catalog/product_attribute_media_api');
157
+ $images = $image_class->items($product->getId(), $store);
158
+
159
+ /* Custom Options */
160
+ $options = $this->getCustomOptions($product);
161
+ $links = $this->getDownloadableLinks($product);
162
+
163
+ /* Prepare results */
164
+ $result = array(
165
+ 'idx' => $product->getId(),
166
+ 'sku' => $product->getSku(),
167
+ 'product_type' => $product->getTypeId(),
168
+ 'body' => $product->getInDepth(),
169
+ 'description' => $product->getDescription(),
170
+ 'short_description' => $product->getShortDescription(),
171
+ 'title' => $product->getName(),
172
+ 'in_stock' => $product->getStockItem()->getIsInStock(),
173
+ 'qty' => $product->getStockItem()->getQty(),
174
+ 'price' => $product->getPrice(),
175
+ 'permalink' => $product->getUrlPath(),
176
+ 'url_in_store' => $product->getProductUrl(),
177
+ 'images' => $images,
178
+ 'visibility' => $product->getVisibility(),
179
+ 'special_price' => $product->getSpecialPrice(),
180
+ 'special_from_date' => $product->getSpecialFromDate(),
181
+ 'special_to_date' => $product->getSpecialToDate(),
182
+ 'custom_options' => $options,
183
+ 'status' => $product->getStatus(),
184
+ 'links' => $links
185
+ );
186
+
187
+ // Optional extra parameters
188
+ return $result + $extra_params;
189
+ }
190
 
191
+ /** Get configurable products */
192
+ private function configurableProducts($parent, $store = null, $identifierType = null)
193
+ {
194
+ $res = array();
195
+
196
+ /* Check if using magento-configurable-simple module */
197
+ $modules = Mage::getConfig()->getNode('modules')->children();
198
+ $modulesArray = (array)$modules;
199
+ $use_simple_configurable = (isset($modulesArray['OrganicInternet_SimpleConfigurableProducts']) && $modulesArray['OrganicInternet_SimpleConfigurableProducts']->is('active')) ? true : false;
200
+ /* EO Check */
201
 
202
+ /* Get configurable attributes */
203
+ $attrs_codes = $parent->getTypeInstance()->getConfigurableAttributesAsArray();
204
+ /* Get all children */
205
+ $children = $parent->getTypeInstance()->getChildrenIds($parent->getId());
206
+
207
+ foreach ($children[0] as $i => $value) {
208
+ $product = $this->_getProduct($value, $store, $identifierType);
209
+ /* Initial Price */
210
+
211
+ $price = $use_simple_configurable ? $product->getFinalPrice() : $parent->getFinalPrice();
212
+ /* Price Difference */
213
+ $difference = 0;
214
+ //Generate caption_name
215
+ $caption = "";
216
+ $configurable_options = array();
217
+ foreach($attrs_codes as $code){
218
+ $caption .= $product->getResource()->getAttribute($code['attribute_code'])->getFrontend()->getValue($product) . " - ";
219
+ $attr_value = $product->getData($code['attribute_code']);
220
+ /* Calculate price */
221
+ foreach($code['values'] as $value){
222
+ if($value['value_index'] == $attr_value) {
223
+ $configurable_options[$code['attribute_id']] = $attr_value;
224
+ if($value["is_percent"] == 1){
225
+ $difference += ($price * $value['pricing_value']) / 100;
226
+ }else{
227
+ $difference += $value['pricing_value'];
 
 
 
 
 
 
 
 
 
 
 
228
  }
229
  }
230
  }
 
 
 
 
231
  }
232
+
233
+ if($product->isSalable() != false){
234
+ array_push($res, $this->getProductInfo($product, $store, array('caption_name' => $caption,
235
+ 'configurable_price' => $price + $difference, 'configurable_options' => $configurable_options)));
236
+ }
237
  }
238
+ return $res;
239
+ }
240
 
241
+ private function groupedProducts($parent, $store = null, $identifierType = null)
242
+ {
243
  $res = array();
244
  $children = $parent->getTypeInstance()->getChildrenIds($parent->getId());
245
  foreach ($children[3] as $i => $value) {
251
  return $res;
252
  }
253
 
254
+ private function getCustomOptions($product)
255
+ {
256
  $options = array();
257
  $customOptions = $product->getOptions();
258
  foreach ($customOptions as $customOption) {
294
  }
295
  return $links_res;
296
  }
297
+
298
  protected function _nodeToArray(Varien_Data_Tree_Node $node)
299
+ {
300
+ $result = array();
301
+ $result['category_id'] = $node->getId();
302
+ $result['parent_id'] = $node->getParentId();
303
+ $result['name'] = $node->getName();
304
+ $result['is_active'] = $node->getIsActive();
305
+ $result['position'] = $node->getPosition();
306
+ $result['level'] = $node->getLevel();
307
+ $result['product_count'] = $node->getProductCount();
308
+ $result['children'] = array();
309
+
310
+ foreach ($node->getChildren() as $child) {
311
+ $result['children'][] = $this->_nodeToArray($child);
 
 
312
  }
313
+ return $result;
314
+ }
315
  }
 
 
app/code/community/Beecoder/Beeshopy/controllers/AdminController.php CHANGED
@@ -1,16 +1,29 @@
1
  <?php
2
- class Beecoder_Beeshopy_AdminController extends Mage_Adminhtml_Controller_Action
 
 
 
 
 
 
 
 
 
 
3
  {
4
- public function indexAction(){
5
- $this->loadLayout();
6
- $this->_setActiveMenu('menu1');
7
 
8
- $block = $this->getLayout()
9
- ->createBlock('core/text', 'beetailer-admin')
10
- ->setText("<iframe src='https://www.beetailer.com?from=iframe' width=1124 height='2350' frameborder='0' scrolling='no' style='margin:0px auto;display:block;'></iframe>");
11
 
12
- $this->_addContent($block);
13
- $this->renderLayout();
14
- }
 
 
 
 
15
  }
16
- ?>
1
  <?php
2
+ /**
3
+ * Admin menu
4
+ *
5
+ * @category Beetailer
6
+ * @package Beecoder_Beeshopy
7
+ */
8
+
9
+
10
+ class Beecoder_Beeshopy_AdminController extends Mage_Adminhtml_Controller_Action
11
+ {
12
+ public function indexAction()
13
  {
14
+ $this->loadLayout();
15
+ $this->_setActiveMenu('facebook-store');
 
16
 
17
+ $block = $this->getLayout()
18
+ ->createBlock('core/text', 'beetailer-admin')
19
+ ->setText("<iframe src='https://www.beetailer.com?from=iframe' width=1124 height='2350' frameborder='0' scrolling='no' style='margin:0px auto;display:block;'></iframe>");
20
 
21
+ $this->_addContent($block);
22
+ $this->renderLayout();
23
+ }
24
+
25
+ protected function _isAllowed()
26
+ {
27
+ return Mage::getSingleton('admin/session')->isAllowed('facebook-store');
28
  }
29
+ }
app/code/community/Beecoder/Beeshopy/controllers/IndexController.php CHANGED
@@ -1,58 +1,66 @@
1
  <?php
2
- class Beecoder_Beeshopy_IndexController extends Mage_Core_Controller_Front_Action
 
 
 
 
 
 
 
 
 
 
3
  {
4
- public function indexAction()
5
- {
6
- if($this->getRequest()->getParams()){
7
- Mage::getModel('core/cookie')->set("beetailer_ref", $this->getRequest()->getParam('fb_ref'));
8
- Mage::getModel('core/cookie')->set("beetailer_ref_date", time());
9
-
10
- /* Fill shopping cart */
11
- $cart = Mage::getSingleton('checkout/cart');
12
- $products = $this->getRequest()->getParam('products');
13
- $sview = $this->getRequest()->getParam('store_view');
14
-
15
- foreach($products as $attrs){
16
- $product = Mage::getModel('catalog/product')
17
- ->setStoreId(Mage::app()->getStore($sview)->getId())
18
- ->load($attrs['idx']);
19
-
20
- $options = isset($attrs['options']) ? $attrs['options'] : array();
21
- $super_attributes = isset($attrs['super_attributes']) ? $attrs['super_attributes'] : array();
22
- $links = isset($attrs['links']) ? explode(",", $attrs['links'][0]) : array();
23
-
24
- try{
25
- $cart->addProduct($product, array(
26
- 'qty' => $attrs["qty"],
27
- 'super_attribute' => $super_attributes,
28
- 'options' => $options,
29
- 'links' => $links
30
- ));
31
- }catch (Mage_Core_Exception $e) { }
32
- }
33
- $cart->save();
34
- Mage::getSingleton('checkout/session')->setCartWasUpdated(true);
35
-
36
- $this->_redirect('checkout/cart', $this->gaParams());
37
- }else{
38
- $this->_redirect('/');
39
- }
40
- }
41
 
42
- /* Add Google analytics parameters */
43
- public function gaParams(){
44
- $redirect_params = array();
45
- foreach($this->getRequest()->getParams() as $k => $v){
46
- if(preg_match('/^utm_/', $k)){
47
- $redirect_params[$k] = $v;
48
- }
49
- }
50
-
51
- if(count($redirect_params)){
52
- $redirect_params = array('_query' => $redirect_params);
53
- }
 
54
 
55
- return $redirect_params;
 
 
 
 
 
 
 
56
  }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
57
  }
58
- ?>
1
  <?php
2
+ /**
3
+ * Beetailer Shopping cart class
4
+ *
5
+ * @category Beetailer
6
+ * @package Beecoder_Beeshopy
7
+ */
8
+
9
+
10
+ class Beecoder_Beeshopy_IndexController extends Mage_Core_Controller_Front_Action
11
+ {
12
+ public function indexAction()
13
  {
14
+ if ($this->getRequest()->getParams()) {
15
+ Mage::getModel('core/cookie')->set("beetailer_ref", $this->getRequest()->getParam('fb_ref'));
16
+ Mage::getModel('core/cookie')->set("beetailer_ref_date", time());
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
17
 
18
+ /* Fill shopping cart */
19
+ $cart = Mage::getSingleton('checkout/cart');
20
+ $products = $this->getRequest()->getParam('products');
21
+ $sview = $this->getRequest()->getParam('store_view');
22
+
23
+ foreach($products as $attrs){
24
+ $product = Mage::getModel('catalog/product')
25
+ ->setStoreId(Mage::app()->getStore($sview)->getId())
26
+ ->load($attrs['idx']);
27
+
28
+ $options = isset($attrs['options']) ? $attrs['options'] : array();
29
+ $super_attributes = isset($attrs['super_attributes']) ? $attrs['super_attributes'] : array();
30
+ $links = isset($attrs['links']) ? explode(",", $attrs['links'][0]) : array();
31
 
32
+ try{
33
+ $cart->addProduct($product, array(
34
+ 'qty' => $attrs["qty"],
35
+ 'super_attribute' => $super_attributes,
36
+ 'options' => $options,
37
+ 'links' => $links
38
+ ));
39
+ }catch (Mage_Core_Exception $e) { }
40
  }
41
+ $cart->save();
42
+ Mage::getSingleton('checkout/session')->setCartWasUpdated(true);
43
+
44
+ $this->_redirect('checkout/cart', $this->gaParams());
45
+ }else{
46
+ $this->_redirect('/');
47
+ }
48
+ }
49
+
50
+ /** Add Google analytics parameters */
51
+ public function gaParams()
52
+ {
53
+ $redirect_params = array();
54
+ foreach($this->getRequest()->getParams() as $k => $v){
55
+ if(preg_match('/^utm_/', $k)){
56
+ $redirect_params[$k] = $v;
57
+ }
58
+ }
59
+
60
+ if(count($redirect_params)){
61
+ $redirect_params = array('_query' => $redirect_params);
62
+ }
63
+
64
+ return $redirect_params;
65
  }
66
+ }
app/code/community/Beecoder/Beeshopy/etc/config.xml CHANGED
@@ -60,21 +60,21 @@
60
 
61
  <adminhtml>
62
  <menu>
63
- <menu1 translate="title" module="Beeshopy">
64
  <title>Facebook Store</title>
65
  <action>beetailer-installation/admin/index</action>
66
  <sort_order>100</sort_order>
67
- </menu1>
68
  </menu>
69
 
70
  <acl>
71
  <resources>
72
  <admin>
73
  <children>
74
- <menu1 translate="title" module="Beeshopy">
75
  <title>Facebook Store</title>
76
  <sort_order>100</sort_order>
77
- </menu1>
78
  </children>
79
  </admin>
80
  </resources>
60
 
61
  <adminhtml>
62
  <menu>
63
+ <facebook-store translate="title" module="Beeshopy">
64
  <title>Facebook Store</title>
65
  <action>beetailer-installation/admin/index</action>
66
  <sort_order>100</sort_order>
67
+ </facebook-store>
68
  </menu>
69
 
70
  <acl>
71
  <resources>
72
  <admin>
73
  <children>
74
+ <facebook-store translate="title" module="Beeshopy">
75
  <title>Facebook Store</title>
76
  <sort_order>100</sort_order>
77
+ </facebook-store>
78
  </children>
79
  </admin>
80
  </resources>
app/design/frontend/default/default/layout/beeshopy.xml DELETED
@@ -1,18 +0,0 @@
1
- <?xml version="1.0"?>
2
- <layout version="0.1.0">
3
- <checkout_onepage_success>
4
- <reference name="before_body_end">
5
- <block type="beecoder_beeshopy/track" name="beecoderbeeshopy_track" template='beeshopy/track.phtml'/>
6
- </reference>
7
- </checkout_onepage_success>
8
-
9
- <default>
10
- <reference name="head">
11
- <block type="core/text" name='beetailer'>
12
- <action method="setText">
13
- <text><![CDATA[ <script type='text/javascript' src='//www.beetailer.com/javascripts/beetailer.js'></script> ]]> </text>
14
- </action>
15
- </block>
16
- </reference>
17
- </default>
18
- </layout>
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
app/design/frontend/default/default/template/beeshopy/track.phtml DELETED
@@ -1,4 +0,0 @@
1
- <!-- Beetailer.com tracking code -->
2
- <?php
3
- echo($this->trackingCode());
4
- ?>
 
 
 
 
package.xml CHANGED
@@ -1,7 +1,7 @@
1
  <?xml version="1.0"?>
2
  <package>
3
  <name>Beecoder_Beeshopy</name>
4
- <version>2.4.7</version>
5
  <stability>stable</stability>
6
  <license>OSL v3.0</license>
7
  <channel>community</channel>
@@ -11,11 +11,11 @@ Beeshopy extension for Magento, it allows you to integrates your magento store w
11
  <description>Custom Module that allows you to connect with beeshopy service and integrates your magento store with Facebook. &#xD;
12
  &#xD;
13
  It contains a custom API and cart processing.</description>
14
- <notes>Adding sort order to assigned products</notes>
15
  <authors><author><name>Miguel &#xC1;ngel Mart&#xED;nez Trivi&#xF1;o</name><user>auto-converted</user><email>migmartri@gmail.com</email></author></authors>
16
- <date>2011-09-01</date>
17
- <time>16:48:06</time>
18
- <contents><target name="magecommunity"><dir name="Beecoder"><dir name="Beeshopy"><dir name="Block"><file name="Track.php" hash="3be941b7a22954c26d6f6adbe0ac2ae5"/></dir><dir name="Helper"><file name="Data.php" hash="64594c0c2a597f047b972fe6f3b022a9"/></dir><dir name="Model"><file name="Api.php" hash="4cf2e54d4dfbf255a75d528328589655"/><file name=".Api.php.swp" hash="b434166ad983bd2d4a2ea13bc5742535"/></dir><dir name="controllers"><file name="AdminController.php" hash="7e4bbc530fca18f4fc46412f681f47a0"/><file name="IndexController.php" hash="86932d24dc1e150480b54f0f61e7824e"/></dir><dir name="etc"><file name="api.xml" hash="507ae656ea724a77def33efd8429d674"/><file name="config.xml" hash="aa6a0a64368240aee927b985cecfbba4"/></dir></dir></dir></target><target name="mageetc"><dir name="modules"><file name="Beecoder_Beeshopy.xml" hash="55666ef45f08dab44b138e49532ca3b8"/></dir></target><target name="magedesign"><dir name="frontend"><dir name="default"><dir name="default"><dir name="layout"><file name="beeshopy.xml" hash="d307958edf914638aa5cd57f8d449c46"/></dir><dir name="template"><dir name="beeshopy"><file name="track.phtml" hash="47c95001bb55042c5ae7d8ee4b03cccf"/></dir></dir></dir></dir><dir name="base"><dir name="default"><dir name="layout"><file name="beeshopy.xml" hash="d307958edf914638aa5cd57f8d449c46"/></dir><dir name="template"><dir name="beeshopy"><file name="track.phtml" hash="47c95001bb55042c5ae7d8ee4b03cccf"/></dir></dir></dir></dir></dir></target></contents>
19
  <compatible/>
20
  <dependencies/>
21
  </package>
1
  <?xml version="1.0"?>
2
  <package>
3
  <name>Beecoder_Beeshopy</name>
4
+ <version>2.4.8</version>
5
  <stability>stable</stability>
6
  <license>OSL v3.0</license>
7
  <channel>community</channel>
11
  <description>Custom Module that allows you to connect with beeshopy service and integrates your magento store with Facebook. &#xD;
12
  &#xD;
13
  It contains a custom API and cart processing.</description>
14
+ <notes>Cleaning code</notes>
15
  <authors><author><name>Miguel &#xC1;ngel Mart&#xED;nez Trivi&#xF1;o</name><user>auto-converted</user><email>migmartri@gmail.com</email></author></authors>
16
+ <date>2011-09-13</date>
17
+ <time>14:59:52</time>
18
+ <contents><target name="magecommunity"><dir name="Beecoder"><dir name="Beeshopy"><dir name="Block"><file name="Track.php" hash="a40d400b02f73d5b4dea35c348ffee00"/></dir><dir name="Helper"><file name="Data.php" hash="ead88c0b629856526d39e7fb6f3a4ca5"/></dir><dir name="Model"><file name="Api.php" hash="8e02acad05b4494025b76a7a1504351c"/></dir><dir name="controllers"><file name="AdminController.php" hash="1b343fe1ef8ae5fafc5d355844e3f508"/><file name="IndexController.php" hash="bad3391bb742a55a2ee62895cb723e87"/></dir><dir name="etc"><file name="api.xml" hash="507ae656ea724a77def33efd8429d674"/><file name="config.xml" hash="2fcfaeccb838771505e12715c9618c3d"/></dir></dir></dir></target><target name="mageetc"><dir name="modules"><file name="Beecoder_Beeshopy.xml" hash="55666ef45f08dab44b138e49532ca3b8"/></dir></target><target name="magedesign"><dir name="frontend"><dir name="base"><dir name="default"><dir name="layout"><file name="beeshopy.xml" hash="d307958edf914638aa5cd57f8d449c46"/></dir><dir name="template"><dir name="beeshopy"><file name="track.phtml" hash="47c95001bb55042c5ae7d8ee4b03cccf"/></dir></dir></dir></dir></dir></target></contents>
19
  <compatible/>
20
  <dependencies/>
21
  </package>