DataFeedWatch_Connector - Version 0.2.7

Version Notes

DataFeedWatch Release version 0.2.7

Download this release

Release Info

Developer DataFeedWatch
Extension DataFeedWatch_Connector
Version 0.2.7
Comparing to
See all releases


Code changes from version 0.2.6 to 0.2.7

app/code/{local → community}/DataFeedWatch/Connector/Block/Adminhtml/Connectorbackend.php RENAMED
File without changes
app/code/{local → community}/DataFeedWatch/Connector/Helper/Data.php RENAMED
File without changes
app/code/{local → community}/DataFeedWatch/Connector/Model/Datafeedwatch/Api.php RENAMED
@@ -10,28 +10,58 @@ class DataFeedWatch_Connector_Model_Datafeedwatch_Api extends Mage_Catalog_Model
10
  const CATEGORY_NAME_FIELD = 'name';
11
  const CATEGORY_SEPARATOR = ' > ';
12
  public $categories = array();
13
-
 
 
 
 
 
 
 
 
 
 
 
 
 
14
  public function __construct() {
15
  $this->productCategories = array();
16
  ini_set('memory_limit', '1024M');
17
  }
18
 
19
  public function version() {
20
- return "0.2.6"; // this needs to be updated in etc/config.xml as well
21
  }
22
 
23
  public function product_count($options = array()) {
24
  $collection = Mage::getModel(self::CATALOG_PRODUCT_MODEL)
25
- ->getCollection();
26
 
27
  if (array_key_exists('store', $options)) {
28
- $collection->addStoreFilter($this->_getStoreId($options['store']));
 
 
 
 
 
 
 
 
 
 
 
 
29
  }
30
 
31
  $apiHelper = Mage::helper('api');
32
  $filters = $apiHelper->parseFilters($options, $this->_filtersMap);
 
33
  try {
34
  foreach ($filters as $field => $value) {
 
 
 
 
35
  $collection->addFieldToFilter($field, $value);
36
  }
37
  } catch (Mage_Core_Exception $e) {
@@ -48,6 +78,9 @@ class DataFeedWatch_Connector_Model_Datafeedwatch_Api extends Mage_Catalog_Model
48
 
49
  public function products($options = array()) {
50
 
 
 
 
51
  if (!array_key_exists('page', $options)) {
52
  $options['page'] = 1;
53
  }
@@ -56,13 +89,40 @@ class DataFeedWatch_Connector_Model_Datafeedwatch_Api extends Mage_Catalog_Model
56
  $options['per_page'] = 100;
57
  }
58
 
59
- $collection = Mage::getModel(self::CATALOG_PRODUCT_MODEL)
60
- ->getCollection()
61
- ->addAttributeToSelect('*')
62
- ->setPage($options['page'], $options['per_page']);
63
 
64
  if (array_key_exists('store', $options)) {
65
- $collection->addStoreFilter($this->_getStoreId($options['store']));
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
66
  }
67
 
68
  // clear options that are not filters
@@ -80,6 +140,10 @@ class DataFeedWatch_Connector_Model_Datafeedwatch_Api extends Mage_Catalog_Model
80
  $filters = $apiHelper->parseFilters($options, $this->_filtersMap);
81
  try {
82
  foreach ($filters as $field => $value) {
 
 
 
 
83
  $collection->addFieldToFilter($field, $value);
84
  }
85
  } catch (Mage_Core_Exception $e) {
@@ -91,7 +155,11 @@ class DataFeedWatch_Connector_Model_Datafeedwatch_Api extends Mage_Catalog_Model
91
  $price_keys = array('price', 'special_price');
92
 
93
  foreach ($collection as $product) {
94
-
 
 
 
 
95
  $parent_id = '0';
96
  $configrable = false;
97
 
@@ -112,7 +180,7 @@ class DataFeedWatch_Connector_Model_Datafeedwatch_Api extends Mage_Catalog_Model
112
  $parent_id = $parent_product->getId();
113
  }
114
  }
115
-
116
  $product_result = array(// Basic product data
117
  'product_id' => $product->getId(),
118
  'sku' => $product->getSku()
@@ -121,6 +189,7 @@ class DataFeedWatch_Connector_Model_Datafeedwatch_Api extends Mage_Catalog_Model
121
  $product_result['parent_id'] = $parent_id;
122
 
123
  foreach ($product->getAttributes() as $attribute) {
 
124
  if (!array_key_exists($attribute->getAttributeCode(), $this->_notNeededFields())) {
125
  $value = $product->getData($attribute->getAttributeCode());
126
  if (!empty($value)) {
@@ -134,14 +203,14 @@ class DataFeedWatch_Connector_Model_Datafeedwatch_Api extends Mage_Catalog_Model
134
  }
135
  }
136
 
137
- $product = Mage::getModel('catalog/product')->load($product->getId());
138
  // $imageUrl = $product->getImage();
139
  // if(empty($imageUrl)) {
140
  // $product = Mage::getModel('catalog/product')->load($product->getId());
141
  // $imageUrl = $product->getImage();
142
  // }
143
  //
144
- // if(empty($imageUrl) || $imageUrl == '') {
145
  // $imageUrl = $product->getMediaConfig()->getMediaUrl($product->getData('image'));
146
  // if(empty($imageUrl) || $imageUrl == '') {
147
  // $imageUrl = Mage::helper('catalog/image')->init($product, 'image');
@@ -156,18 +225,44 @@ class DataFeedWatch_Connector_Model_Datafeedwatch_Api extends Mage_Catalog_Model
156
  $imageUrl = (string) Mage::helper('catalog/image')->init($product, 'image');
157
  }
158
 
159
- $product_result['product_url'] = $baseUrl . $product->getUrlPath();
 
 
 
 
 
160
  $product_result['image_url'] = $imageUrl;
161
 
162
  $tmpPrices = array();
163
  if ($parent_id && $configrable && $product->getVisibility() == 1) {
164
  $tmpPrices = $this->getDisplayPrice($parent_id);
165
  } else {
166
- $tmpPrices = $this->getDisplayPrice($product->getId());
167
  }
 
168
  if (count($tmpPrices)) {
169
  foreach ($tmpPrices as $key => $value) {
170
- $product_result[$key] = $value;
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
171
  }
172
  }
173
 
@@ -177,11 +272,13 @@ class DataFeedWatch_Connector_Model_Datafeedwatch_Api extends Mage_Catalog_Model
177
  $product_result['is_in_stock'] = $inventoryStatus->getIsInStock() == '1' ? 1 : 0;
178
  }
179
  $result[] = $product_result;
 
180
  }
181
  return $result;
182
  }
183
 
184
  private function _loadCategories() {
 
185
  $parentId = 1;
186
 
187
  /* @var $tree Mage_Catalog_Model_Resource_Eav_Mysql4_Category_Tree */
@@ -193,9 +290,8 @@ class DataFeedWatch_Connector_Model_Datafeedwatch_Api extends Mage_Catalog_Model
193
  }
194
 
195
  $collection = Mage::getModel('catalog/category')->getCollection()
196
- ->setStoreId($this->_getStoreId(null))
197
- ->addAttributeToSelect('name')
198
- ->addAttributeToSelect('is_active');
199
 
200
  $tree->addCollectionData($collection, true);
201
 
@@ -286,14 +382,23 @@ class DataFeedWatch_Connector_Model_Datafeedwatch_Api extends Mage_Catalog_Model
286
  );
287
  }
288
 
289
- private function getDisplayPrice($product_id = 0) {
290
 
291
- if ($product_id < 1) {
292
  return 0;
293
  }
 
294
  $prices = array();
295
 
296
- $product = Mage::getModel('catalog/product')->load($product_id);
 
 
 
 
 
 
 
 
297
  $store_code = Mage::app()->getStore()->getCode();
298
  $_taxHelper = Mage::helper('tax');
299
  // Get Currency Code
@@ -301,9 +406,9 @@ class DataFeedWatch_Connector_Model_Datafeedwatch_Api extends Mage_Catalog_Model
301
  $cur_curncy_code = Mage::app()->getStore($store_code)->getCurrentCurrencyCode();
302
 
303
  $allowedCurrencies = Mage::getModel('directory/currency')
304
- ->getConfigAllowCurrencies();
305
  $currencyRates = Mage::getModel('directory/currency')
306
- ->getCurrencyRates($bas_curncy_code, array_values($allowedCurrencies));
307
 
308
  $prices['price_with_tax'] = $_finalPriceInclTax = $_taxHelper->getPrice($product, $product->getPrice(), 2); //$product['price'];
309
  $prices['price'] = $_taxHelper->getPrice($product, $product->getPrice(), NULL);
@@ -316,7 +421,11 @@ class DataFeedWatch_Connector_Model_Datafeedwatch_Api extends Mage_Catalog_Model
316
  $prices['short_description'] = $product->getShortDescription();
317
 
318
  $baseUrl = Mage::getBaseUrl(Mage_Core_Model_Store::URL_TYPE_WEB);
319
- $prices['product_url'] = $baseUrl . $product->getUrlPath();
 
 
 
 
320
  //Setting image
321
  $imageUrl = (string) $product->getMediaConfig()->getMediaUrl($product->getData('image'));
322
  $imageTmpArr = explode('.', $imageUrl);
@@ -325,7 +434,7 @@ class DataFeedWatch_Connector_Model_Datafeedwatch_Api extends Mage_Catalog_Model
325
  $imageUrl = (string) Mage::helper('catalog/image')->init($product, 'image');
326
  }
327
  $prices['image_url'] = $imageUrl;
328
-
329
  $additional_images = $product->getMediaGalleryImages();
330
  if (count($additional_images) > 0) {
331
  $i = 1;
@@ -334,7 +443,7 @@ class DataFeedWatch_Connector_Model_Datafeedwatch_Api extends Mage_Catalog_Model
334
  $prices['additional_image_url'.$i++] = $images->getUrl();
335
  }
336
  }
337
-
338
  $specialTmpPrice = $product->getSpecialPrice();
339
 
340
  if ($specialTmpPrice && (strtotime(date('Y-m-d H:i:s')) < strtotime($product['special_to_date'])
@@ -347,8 +456,8 @@ class DataFeedWatch_Connector_Model_Datafeedwatch_Api extends Mage_Catalog_Model
347
  }
348
 
349
  if ($bas_curncy_code != $cur_curncy_code
350
- && array_key_exists($bas_curncy_code, $currencyRates)
351
- && array_key_exists($cur_curncy_code, $currencyRates)
352
  ) {
353
  if ($prices['special_price'] && (strtotime(date('Y-m-d H:i:s')) < strtotime($product['special_to_date'])
354
  || empty($product['special_to_date']))) {
@@ -359,7 +468,7 @@ class DataFeedWatch_Connector_Model_Datafeedwatch_Api extends Mage_Catalog_Model
359
  $prices['price_with_tax'] = Mage::helper('directory')->currencyConvert($_finalPriceInclTax, $bas_curncy_code, $cur_curncy_code);
360
  $prices['price'] = Mage::helper('directory')->currencyConvert($prices['price'], $bas_curncy_code, $cur_curncy_code);
361
  }
362
-
363
  // Getting Additional information
364
  $attributes = $product->getAttributes();
365
  //$attrs = $product->getTypeInstance(true)->getConfigurableAttributesAsArray($product);
@@ -388,17 +497,20 @@ class DataFeedWatch_Connector_Model_Datafeedwatch_Api extends Mage_Catalog_Model
388
  foreach ($category_id as $key => $cate) {
389
  // if(in_array($cate, $this->productCategories))
390
  // continue;
391
-
 
 
 
392
  $category = $this->categories[$cate];
393
  $prices['category_name'.$index] = $category['name'];
394
  $prices['category_parent_name'.$index] = $this->categories[$category['parent_id']]['name'];
395
  $prices['category_path'.$index] = implode(' > ', $this->_buildCategoryPath($category['category_id']));
396
  if($index == '')
397
  $index = 1;
398
- else
399
  $index = $index+1;
400
  }
401
-
402
  // $category = $this->categories[$category_id[0]];
403
  // $prices['category_name'] = $category['name'];
404
  // $prices['category_parent_name'] = $this->categories[$category['parent_id']]['name'];
@@ -407,5 +519,18 @@ class DataFeedWatch_Connector_Model_Datafeedwatch_Api extends Mage_Catalog_Model
407
 
408
  return $prices;
409
  }
410
-
 
 
 
 
 
 
 
 
 
 
 
 
 
411
  }
10
  const CATEGORY_NAME_FIELD = 'name';
11
  const CATEGORY_SEPARATOR = ' > ';
12
  public $categories = array();
13
+
14
+ public $storeId = 0;
15
+ public $storeRootCategoryId = 2;
16
+ public $storeCategories = array();
17
+
18
+ protected $_supportedEnterprise = array(
19
+ 'major' => '1',
20
+ 'minor' => '13',
21
+ 'revision' => '0',
22
+ 'patch' => '2',
23
+ 'stability' => '',
24
+ 'number' => '',
25
+ );
26
+
27
  public function __construct() {
28
  $this->productCategories = array();
29
  ini_set('memory_limit', '1024M');
30
  }
31
 
32
  public function version() {
33
+ return "0.2.7"; // this needs to be updated in etc/config.xml as well
34
  }
35
 
36
  public function product_count($options = array()) {
37
  $collection = Mage::getModel(self::CATALOG_PRODUCT_MODEL)
38
+ ->getCollection();
39
 
40
  if (array_key_exists('store', $options)) {
41
+ //convert store code to store id
42
+ if(!is_numeric($options['store'])){
43
+ $options['store'] = Mage::app()->getStore($options['store'])->getId();
44
+ }
45
+
46
+ if($options['store']){
47
+ $collection->addStoreFilter($options['store']);
48
+ } else {
49
+ //use default solution
50
+ $collection->addStoreFilter($this->_getStoreId($options['store']));
51
+ }
52
+
53
+ unset($options['store']);
54
  }
55
 
56
  $apiHelper = Mage::helper('api');
57
  $filters = $apiHelper->parseFilters($options, $this->_filtersMap);
58
+
59
  try {
60
  foreach ($filters as $field => $value) {
61
+ //ignore status when flat catalog is enabled
62
+ if($field == 'status' && Mage::getStoreConfig('catalog/frontend/flat_catalog_product')==1){
63
+ continue;
64
+ }
65
  $collection->addFieldToFilter($field, $value);
66
  }
67
  } catch (Mage_Core_Exception $e) {
78
 
79
  public function products($options = array()) {
80
 
81
+ $this->_versionInfo = Mage::getVersionInfo();
82
+
83
+
84
  if (!array_key_exists('page', $options)) {
85
  $options['page'] = 1;
86
  }
89
  $options['per_page'] = 100;
90
  }
91
 
92
+ $collection = Mage::getModel('catalog/product')->getCollection();
 
 
 
93
 
94
  if (array_key_exists('store', $options)) {
95
+ //convert store code to store id
96
+ if(!is_numeric($options['store'])){
97
+ $options['store'] = Mage::app()->getStore($options['store'])->getId();
98
+ }
99
+
100
+ if($options['store']){
101
+ $this->storeId = $options['store'];
102
+ Mage::app()->setCurrentStore($this->storeId);
103
+
104
+ //reinitialize collection because flat catalog settings may have changed
105
+ $collection = Mage::getModel('catalog/product')->getCollection();
106
+ $collection->addStoreFilter($this->storeId);
107
+ } else {
108
+ //use default solution
109
+ $collection->addStoreFilter($this->_getStoreId($options['store']));
110
+ }
111
+
112
+ }
113
+
114
+ $collection->addAttributeToSelect('*')
115
+ ->setPage($options['page'], $options['per_page']);
116
+
117
+ /* set current store manually so we get specific store url returned in getBaseUrl */
118
+ $this->storeRootCategoryId = Mage::app()->getStore()->getRootCategoryId();
119
+ $storeCategoriesCollection = Mage::getModel('catalog/category')->getCollection()
120
+ ->addAttributeToSelect('name')
121
+ ->addAttributeToSelect('is_active')
122
+ ->addPathsFilter('%/'.$this->storeRootCategoryId);
123
+
124
+ foreach($storeCategoriesCollection as $storeCategory){
125
+ $this->storeCategories[] = $storeCategory->getId();
126
  }
127
 
128
  // clear options that are not filters
140
  $filters = $apiHelper->parseFilters($options, $this->_filtersMap);
141
  try {
142
  foreach ($filters as $field => $value) {
143
+ //ignore status when flat catalog is enabled
144
+ if($field == 'status' && Mage::getStoreConfig('catalog/frontend/flat_catalog_product')==1){
145
+ continue;
146
+ }
147
  $collection->addFieldToFilter($field, $value);
148
  }
149
  } catch (Mage_Core_Exception $e) {
155
  $price_keys = array('price', 'special_price');
156
 
157
  foreach ($collection as $product) {
158
+ if($this->storeId){
159
+ $product = Mage::getModel('catalog/product')->setStoreId($this->storeId)->load($product->getId());
160
+ } else {
161
+ $product = Mage::getModel('catalog/product')->load($product->getId());
162
+ }
163
  $parent_id = '0';
164
  $configrable = false;
165
 
180
  $parent_id = $parent_product->getId();
181
  }
182
  }
183
+
184
  $product_result = array(// Basic product data
185
  'product_id' => $product->getId(),
186
  'sku' => $product->getSku()
189
  $product_result['parent_id'] = $parent_id;
190
 
191
  foreach ($product->getAttributes() as $attribute) {
192
+
193
  if (!array_key_exists($attribute->getAttributeCode(), $this->_notNeededFields())) {
194
  $value = $product->getData($attribute->getAttributeCode());
195
  if (!empty($value)) {
203
  }
204
  }
205
 
206
+
207
  // $imageUrl = $product->getImage();
208
  // if(empty($imageUrl)) {
209
  // $product = Mage::getModel('catalog/product')->load($product->getId());
210
  // $imageUrl = $product->getImage();
211
  // }
212
  //
213
+ // if(empty($imageUrl) || $imageUrl == '') {
214
  // $imageUrl = $product->getMediaConfig()->getMediaUrl($product->getData('image'));
215
  // if(empty($imageUrl) || $imageUrl == '') {
216
  // $imageUrl = Mage::helper('catalog/image')->init($product, 'image');
225
  $imageUrl = (string) Mage::helper('catalog/image')->init($product, 'image');
226
  }
227
 
228
+
229
+ if(Mage::getEdition() == Mage::EDITION_ENTERPRISE && Mage::getVersionInfo() >= $this->_supportedEnterprise){
230
+ $product_result['product_url'] = $product->getProductUrl();
231
+ } else {
232
+ $product_result['product_url'] = $baseUrl . $product->getUrlPath();
233
+ }
234
  $product_result['image_url'] = $imageUrl;
235
 
236
  $tmpPrices = array();
237
  if ($parent_id && $configrable && $product->getVisibility() == 1) {
238
  $tmpPrices = $this->getDisplayPrice($parent_id);
239
  } else {
240
+ $tmpPrices = $this->getDisplayPrice($product);
241
  }
242
+
243
  if (count($tmpPrices)) {
244
  foreach ($tmpPrices as $key => $value) {
245
+ /*
246
+ use child values,
247
+ except description, short_description, product_url
248
+ and except when value (doesn't exist||is empty) in child
249
+ also, use parent image_url if it's empty in child
250
+ */
251
+ if(!array_key_exists($key,$product_result) || !$product_result[$key] || in_array($key,array('description','short_description','product_url','image_url'))){
252
+ if($key=='image_url'
253
+ && !stristr($product_result[$key],'.jpg')
254
+ && !stristr($product_result[$key],'.png')
255
+ && !stristr($product_result[$key],'.jpeg')
256
+ && !stristr($product_result[$key],'.gif')
257
+ && !stristr($product_result[$key],'.bmp')
258
+ ){
259
+ //overwrite record image_url with parent's value when child doesn't have correct image url
260
+ $product_result[$key] = $value;
261
+ } elseif($key!='image_url'){
262
+ //overwrite description,short_description and product_url
263
+ $product_result[$key] = $value;
264
+ }
265
+ }
266
  }
267
  }
268
 
272
  $product_result['is_in_stock'] = $inventoryStatus->getIsInStock() == '1' ? 1 : 0;
273
  }
274
  $result[] = $product_result;
275
+
276
  }
277
  return $result;
278
  }
279
 
280
  private function _loadCategories() {
281
+
282
  $parentId = 1;
283
 
284
  /* @var $tree Mage_Catalog_Model_Resource_Eav_Mysql4_Category_Tree */
290
  }
291
 
292
  $collection = Mage::getModel('catalog/category')->getCollection()
293
+ ->addAttributeToSelect('name')
294
+ ->addAttributeToSelect('is_active');
 
295
 
296
  $tree->addCollectionData($collection, true);
297
 
382
  );
383
  }
384
 
385
+ private function getDisplayPrice($product_id) {
386
 
387
+ if (!$product_id) {
388
  return 0;
389
  }
390
+
391
  $prices = array();
392
 
393
+ if($product_id instanceof Mage_Catalog_Model_Product){
394
+ $product = $product_id;
395
+ } else {
396
+ if ($product_id < 1) {
397
+ return 0;
398
+ }
399
+ $product = Mage::getModel('catalog/product')->setStoreId($this->storeId)->load($product_id);
400
+ }
401
+
402
  $store_code = Mage::app()->getStore()->getCode();
403
  $_taxHelper = Mage::helper('tax');
404
  // Get Currency Code
406
  $cur_curncy_code = Mage::app()->getStore($store_code)->getCurrentCurrencyCode();
407
 
408
  $allowedCurrencies = Mage::getModel('directory/currency')
409
+ ->getConfigAllowCurrencies();
410
  $currencyRates = Mage::getModel('directory/currency')
411
+ ->getCurrencyRates($bas_curncy_code, array_values($allowedCurrencies));
412
 
413
  $prices['price_with_tax'] = $_finalPriceInclTax = $_taxHelper->getPrice($product, $product->getPrice(), 2); //$product['price'];
414
  $prices['price'] = $_taxHelper->getPrice($product, $product->getPrice(), NULL);
421
  $prices['short_description'] = $product->getShortDescription();
422
 
423
  $baseUrl = Mage::getBaseUrl(Mage_Core_Model_Store::URL_TYPE_WEB);
424
+ if(Mage::getEdition() == Mage::EDITION_ENTERPRISE && Mage::getVersionInfo() >= $this->_supportedEnterprise){
425
+ $product_result['product_url'] = $product->getProductUrl();
426
+ } else {
427
+ $product_result['product_url'] = $baseUrl . $product->getUrlPath();
428
+ }
429
  //Setting image
430
  $imageUrl = (string) $product->getMediaConfig()->getMediaUrl($product->getData('image'));
431
  $imageTmpArr = explode('.', $imageUrl);
434
  $imageUrl = (string) Mage::helper('catalog/image')->init($product, 'image');
435
  }
436
  $prices['image_url'] = $imageUrl;
437
+
438
  $additional_images = $product->getMediaGalleryImages();
439
  if (count($additional_images) > 0) {
440
  $i = 1;
443
  $prices['additional_image_url'.$i++] = $images->getUrl();
444
  }
445
  }
446
+
447
  $specialTmpPrice = $product->getSpecialPrice();
448
 
449
  if ($specialTmpPrice && (strtotime(date('Y-m-d H:i:s')) < strtotime($product['special_to_date'])
456
  }
457
 
458
  if ($bas_curncy_code != $cur_curncy_code
459
+ && array_key_exists($bas_curncy_code, $currencyRates)
460
+ && array_key_exists($cur_curncy_code, $currencyRates)
461
  ) {
462
  if ($prices['special_price'] && (strtotime(date('Y-m-d H:i:s')) < strtotime($product['special_to_date'])
463
  || empty($product['special_to_date']))) {
468
  $prices['price_with_tax'] = Mage::helper('directory')->currencyConvert($_finalPriceInclTax, $bas_curncy_code, $cur_curncy_code);
469
  $prices['price'] = Mage::helper('directory')->currencyConvert($prices['price'], $bas_curncy_code, $cur_curncy_code);
470
  }
471
+
472
  // Getting Additional information
473
  $attributes = $product->getAttributes();
474
  //$attrs = $product->getTypeInstance(true)->getConfigurableAttributesAsArray($product);
497
  foreach ($category_id as $key => $cate) {
498
  // if(in_array($cate, $this->productCategories))
499
  // continue;
500
+
501
+ if(!in_array($cate, $this->storeCategories))
502
+ continue;
503
+
504
  $category = $this->categories[$cate];
505
  $prices['category_name'.$index] = $category['name'];
506
  $prices['category_parent_name'.$index] = $this->categories[$category['parent_id']]['name'];
507
  $prices['category_path'.$index] = implode(' > ', $this->_buildCategoryPath($category['category_id']));
508
  if($index == '')
509
  $index = 1;
510
+ else
511
  $index = $index+1;
512
  }
513
+
514
  // $category = $this->categories[$category_id[0]];
515
  // $prices['category_name'] = $category['name'];
516
  // $prices['category_parent_name'] = $this->categories[$category['parent_id']]['name'];
519
 
520
  return $prices;
521
  }
522
+
523
+ public function stores(){
524
+ foreach (Mage::app()->getWebsites() as $website) {
525
+ foreach ($website->getGroups() as $group) {
526
+ $stores = $group->getStores();
527
+ foreach ($stores as $store) {
528
+ $returned[$store->getCode()] = $store->getName();
529
+ }
530
+ }
531
+ }
532
+ return $returned;
533
+ }
534
+
535
+
536
  }
app/code/{local → community}/DataFeedWatch/Connector/controllers/Adminhtml/ConnectorbackendController.php RENAMED
File without changes
app/code/{local → community}/DataFeedWatch/Connector/etc/api.xml RENAMED
@@ -15,6 +15,9 @@
15
  <product_count translate="title" module="connector">
16
  <title>Retrieve product count</title>
17
  </product_count>
 
 
 
18
  </methods>
19
  </datafeedwatch>
20
  </resources>
15
  <product_count translate="title" module="connector">
16
  <title>Retrieve product count</title>
17
  </product_count>
18
+ <stores translate="title" module="connector">
19
+ <title>Retrieve stores</title>
20
+ </stores>
21
  </methods>
22
  </datafeedwatch>
23
  </resources>
app/code/community/DataFeedWatch/Connector/etc/config.xml ADDED
@@ -0,0 +1,89 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?xml version="1.0"?>
2
+ <config>
3
+ <modules>
4
+ <DataFeedWatch_Connector>
5
+ <version>0.2.7</version>
6
+ </DataFeedWatch_Connector>
7
+ </modules>
8
+ <frontend>
9
+ <routers>
10
+ <connector>
11
+ <use>standard</use>
12
+ <args>
13
+ <module>DataFeedWatch_Connector</module>
14
+ <frontName>connector</frontName>
15
+ </args>
16
+ </connector>
17
+ </routers>
18
+ </frontend>
19
+ <admin>
20
+ <routers>
21
+ <connector>
22
+ <use>admin</use>
23
+ <args>
24
+ <module>DataFeedWatch_Connector</module>
25
+ <frontName>connector</frontName>
26
+ </args>
27
+ </connector>
28
+ </routers>
29
+ </admin>
30
+ <adminhtml>
31
+ <menu>
32
+ <catalog translate="title" module="adminhtml">
33
+ <children>
34
+ <connectorbackend translate="title" module="connector">
35
+ <title>DataFeedWatch</title>
36
+ <action>connector/adminhtml_connectorbackend</action>
37
+ </connectorbackend>
38
+ </children>
39
+ </catalog>
40
+ </menu>
41
+ <acl>
42
+ <resources>
43
+ <admin>
44
+ <catalog>
45
+ <children>
46
+ <connectorbackend translate="title" module="connector">
47
+ <title>DataFeedWatch</title>
48
+ </connectorbackend>
49
+ </children>
50
+ </catalog>
51
+ </admin>
52
+ </resources>
53
+ </acl>
54
+ <layout>
55
+ <updates>
56
+ <connector>
57
+ <file>connector.xml</file>
58
+ </connector>
59
+ </updates>
60
+ </layout>
61
+ </adminhtml>
62
+ <global>
63
+ <models>
64
+ <connector>
65
+ <class>DataFeedWatch_Connector_Model</class>
66
+ </connector>
67
+ </models>
68
+ <helpers>
69
+ <connector>
70
+ <class>DataFeedWatch_Connector_Helper</class>
71
+ </connector>
72
+ </helpers>
73
+ <blocks>
74
+ <connector>
75
+ <class>DataFeedWatch_Connector_Block</class>
76
+ </connector>
77
+ </blocks>
78
+ <resources>
79
+ <datafeedwatch_connector_setup>
80
+ <setup>
81
+ <module>DataFeedWatch_Connector</module>
82
+ </setup>
83
+ <connection>
84
+ <use>core_setup</use>
85
+ </connection>
86
+ </datafeedwatch_connector_setup>
87
+ </resources>
88
+ </global>
89
+ </config>
app/code/{local → community}/DataFeedWatch/Connector/etc/system.xml RENAMED
File without changes
app/code/local/DataFeedWatch/Connector/controllers/TestController.php DELETED
@@ -1,34 +0,0 @@
1
- <?php
2
-
3
- class DataFeedWatch_Connector_TestController extends Mage_Core_Controller_Front_Action {
4
-
5
- public function indexAction() {
6
-
7
- $this->loadLayout();
8
- $this->_title($this->__("DataFeedWatch"));
9
- $this->renderLayout();
10
-
11
- $collection = Mage::getModel('catalog/product')
12
- ->getCollection()
13
- ->addAttributeToSelect('*')
14
- ->setPage(1, 20);
15
- $productsAtts = array();
16
- foreach ($collection as $product) {
17
- $attributes = $product->getAttributes();
18
- //$attrs = $product->getTypeInstance(true)->getConfigurableAttributesAsArray($product);
19
- foreach ($attributes as $attribute) {
20
- if ($attribute->getIsUserDefined()) { //&& $attribute->getIsUserDefined()
21
- $value = $product->getData($attribute->getAttributeCode());
22
- if (!empty($value)) {
23
- $value = trim($attribute->getFrontend()->getValue($product));
24
- }
25
- $productsAtts[$product->getId()][$attribute->getAttributeCode()] = $value;
26
- }
27
- }
28
- }
29
- echo '<pre>';
30
- print_r($productsAtts);
31
- die('nothing found');
32
- }
33
-
34
- }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
app/code/local/DataFeedWatch/Connector/etc/config.xml DELETED
@@ -1,93 +0,0 @@
1
- <?xml version="1.0"?>
2
- <config>
3
- <modules>
4
- <DataFeedWatch_Connector>
5
- <version>0.2.6</version>
6
- </DataFeedWatch_Connector>
7
- </modules>
8
-
9
- <frontend>
10
- <routers>
11
- <connector>
12
- <use>standard</use>
13
- <args>
14
- <module>DataFeedWatch_Connector</module>
15
- <frontName>connector</frontName>
16
- </args>
17
- </connector>
18
- </routers>
19
-
20
- </frontend>
21
-
22
-
23
- <admin>
24
- <routers>
25
- <connector>
26
- <use>admin</use>
27
- <args>
28
- <module>DataFeedWatch_Connector</module>
29
- <frontName>connector</frontName>
30
- </args>
31
- </connector>
32
- </routers>
33
- </admin>
34
- <adminhtml>
35
- <menu>
36
- <catalog translate="title" module="adminhtml">
37
- <children>
38
- <connectorbackend translate="title" module="connector">
39
- <title>DataFeedWatch</title>
40
- <action>connector/adminhtml_connectorbackend</action>
41
- </connectorbackend>
42
- </children>
43
- </catalog>
44
- </menu>
45
- <acl>
46
- <resources>
47
- <admin>
48
- <catalog>
49
- <children>
50
- <connectorbackend translate="title" module="connector">
51
- <title>DataFeedWatch</title>
52
- </connectorbackend>
53
- </children>
54
- </catalog>
55
- </admin>
56
- </resources>
57
- </acl>
58
- <layout>
59
- <updates>
60
- <connector>
61
- <file>connector.xml</file>
62
- </connector>
63
- </updates>
64
- </layout>
65
- </adminhtml>
66
- <global>
67
- <models>
68
- <connector>
69
- <class>DataFeedWatch_Connector_Model</class>
70
- </connector>
71
- </models>
72
- <helpers>
73
- <connector>
74
- <class>DataFeedWatch_Connector_Helper</class>
75
- </connector>
76
- </helpers>
77
- <blocks>
78
- <connector>
79
- <class>DataFeedWatch_Connector_Block</class>
80
- </connector>
81
- </blocks>
82
- <resources>
83
- <datafeedwatch_connector_setup>
84
- <setup>
85
- <module>DataFeedWatch_Connector</module>
86
- </setup>
87
- <connection>
88
- <use>core_setup</use>
89
- </connection>
90
- </datafeedwatch_connector_setup>
91
- </resources>
92
- </global>
93
- </config>
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
app/etc/modules/DataFeedWatch_Connector.xml CHANGED
@@ -3,7 +3,7 @@
3
  <modules>
4
  <DataFeedWatch_Connector>
5
  <active>true</active>
6
- <codePool>local</codePool>
7
  <depends>
8
  <Mage_Api />
9
  </depends>
3
  <modules>
4
  <DataFeedWatch_Connector>
5
  <active>true</active>
6
+ <codePool>community</codePool>
7
  <depends>
8
  <Mage_Api />
9
  </depends>
package.xml CHANGED
@@ -1,19 +1,19 @@
1
  <?xml version="1.0"?>
2
  <package>
3
  <name>DataFeedWatch_Connector</name>
4
- <version>0.2.6</version>
5
  <stability>stable</stability>
6
  <license uri="http://opensource.org/licenses/osl-3.0.php">OSL v3.0</license>
7
  <channel>community</channel>
8
  <extends/>
9
  <summary>DataFeedWatch extension for Magento</summary>
10
- <description>DataFeedWatch enables Magento shops to optimize their product data&#xD;
11
- feed for Google Shopping and other channels</description>
12
- <notes>DataFeedWatch Release version 0.2.5</notes>
13
  <authors><author><name>DataFeedWatch</name><user>Adeel</user><email>adeel.developer@gmail.com</email></author></authors>
14
- <date>2013-12-22</date>
15
- <time>18:29:16</time>
16
- <contents><target name="magelocal"><dir name="DataFeedWatch"><dir name="Connector"><dir name="Block"><dir name="Adminhtml"><file name="Connectorbackend.php" hash="afe5bd4888768229d5b668f466b770b5"/></dir></dir><dir name="Helper"><file name="Data.php" hash="983d7ad023616b365dce180680e4f9f0"/></dir><dir name="Model"><dir name="Datafeedwatch"><file name="Api.php" hash="58c839f37da441ced5a49c87f7c42d8e"/></dir></dir><dir name="controllers"><dir name="Adminhtml"><file name="ConnectorbackendController.php" hash="dfa561302ef7eebe656b229fe275a2eb"/></dir><file name="TestController.php" hash="c90345d01f53e2a6c84eb29083c4263c"/></dir><dir name="etc"><file name="api.xml" hash="84e8b97ba0dc25154ff62126640de989"/><file name="config.xml" hash="c4ceb8eef23ebf6aea1012a0c9267c5e"/><file name="system.xml" hash="ab5e8d56d032ba69c930ab7879484212"/></dir></dir></dir></target><target name="magedesign"><dir name="adminhtml"><dir name="default"><dir name="default"><dir name="layout"><file name="connector.xml" hash="14d59b8e9f66fba5d7c1f8d0f62dfc3c"/></dir><dir name="template"><dir name="connector"><file name="connectorbackend.phtml" hash="87fbcd16a96af52ce352bc45d9aeab4a"/></dir></dir></dir></dir></dir></target><target name="mageetc"><dir name="modules"><file name="DataFeedWatch_Connector.xml" hash="d4ef6cebcefd37d5f0546eca344941eb"/></dir></target></contents>
17
  <compatible/>
18
  <dependencies><required><php><min>5.1.0</min><max>6.0.0</max></php></required></dependencies>
19
  </package>
1
  <?xml version="1.0"?>
2
  <package>
3
  <name>DataFeedWatch_Connector</name>
4
+ <version>0.2.7</version>
5
  <stability>stable</stability>
6
  <license uri="http://opensource.org/licenses/osl-3.0.php">OSL v3.0</license>
7
  <channel>community</channel>
8
  <extends/>
9
  <summary>DataFeedWatch extension for Magento</summary>
10
+ <description>DataFeedWatch enables Magento shops to optimize their product datafeed for Google Shopping and other channels&#xD;
11
+ </description>
12
+ <notes>DataFeedWatch Release version 0.2.7</notes>
13
  <authors><author><name>DataFeedWatch</name><user>Adeel</user><email>adeel.developer@gmail.com</email></author></authors>
14
+ <date>2014-04-12</date>
15
+ <time>17:01:35</time>
16
+ <contents><target name="magecommunity"><dir name="DataFeedWatch"><dir name="Connector"><dir name="Block"><dir><dir name="Adminhtml"><file name="Connectorbackend.php" hash="afe5bd4888768229d5b668f466b770b5"/></dir></dir></dir><dir name="controllers"><dir name="Adminhtml"><file name="ConnectorbackendController.php" hash="dfa561302ef7eebe656b229fe275a2eb"/></dir></dir><dir name="etc"><file name="api.xml" hash="2ece4a0209f667be766d0dbabed6fae5"/><file name="config.xml" hash="d3563f722820976ece0261d4a113bf18"/><file name="system.xml" hash="ab5e8d56d032ba69c930ab7879484212"/></dir><dir name="Helper"><file name="Data.php" hash="983d7ad023616b365dce180680e4f9f0"/></dir><dir name="Model"><dir name="Datafeedwatch"><file name="Api.php" hash="553936db5a6226b8538226e6671d1562"/></dir></dir></dir></dir></target><target name="magedesign"><dir name="adminhtml"><dir name="default"><dir name="default"><dir name="layout"><file name="connector.xml" hash="14d59b8e9f66fba5d7c1f8d0f62dfc3c"/></dir><dir name="template"><dir name="connector"><file name="connectorbackend.phtml" hash="87fbcd16a96af52ce352bc45d9aeab4a"/></dir></dir></dir></dir></dir></target><target name="mageetc"><dir name="modules"><file name="DataFeedWatch_Connector.xml" hash="658a7b36ae7eb5915f40993a191aaa13"/></dir></target></contents>
17
  <compatible/>
18
  <dependencies><required><php><min>5.1.0</min><max>6.0.0</max></php></required></dependencies>
19
  </package>