DataFeedWatch_Connector - Version 0.2.11

Version Notes

DataFeedWatch Release version 0.2.11

Download this release

Release Info

Developer DataFeedWatch
Extension DataFeedWatch_Connector
Version 0.2.11
Comparing to
See all releases


Code changes from version 0.2.9 to 0.2.11

app/code/community/DataFeedWatch/Connector/Block/Adminhtml/Connectorbackend.php CHANGED
@@ -12,14 +12,10 @@ class DataFeedWatch_Connector_Block_Adminhtml_Connectorbackend extends Mage_Admi
12
  return $this->getUrl('*/*/createuser');
13
  }
14
 
15
- public function getUpdateTokenUrl() {
16
- return $this->getUrl('*/*/updatetoken');
17
- }
18
-
19
- public function getUser() {
20
- $model = Mage::getModel('api/user');
21
- return $model->load($this->email, 'email');
22
- }
23
 
24
  public function getRedirectUrl() {
25
  return $this->getUrl('*/*/redirect');
12
  return $this->getUrl('*/*/createuser');
13
  }
14
 
15
+ public function getUser() {
16
+ $model = Mage::getModel('api/user');
17
+ return $model->load($this->email, 'email');
18
+ }
 
 
 
 
19
 
20
  public function getRedirectUrl() {
21
  return $this->getUrl('*/*/redirect');
app/code/community/DataFeedWatch/Connector/Helper/Data.php CHANGED
@@ -1,5 +1,99 @@
1
  <?php
2
  class DataFeedWatch_Connector_Helper_Data extends Mage_Core_Helper_Abstract
3
  {
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
4
  }
5
-
1
  <?php
2
  class DataFeedWatch_Connector_Helper_Data extends Mage_Core_Helper_Abstract
3
  {
4
+ /**
5
+ * Parse filters and format them to be applicable for collection filtration
6
+ *
7
+ * @param null|object|array $filters
8
+ * @param array $fieldsMap Map of field names in format: array('field_name_in_filter' => 'field_name_in_db')
9
+ * @return array
10
+ */
11
+ public function parseFiltersReplacement($filters, $fieldsMap = null)
12
+ {
13
+ // if filters are used in SOAP they must be represented in array format to be used for collection filtration
14
+ if (is_object($filters)) {
15
+ $parsedFilters = array();
16
+ // parse simple filter
17
+ if (isset($filters->filter) && is_array($filters->filter)) {
18
+ foreach ($filters->filter as $field => $value) {
19
+ if (is_object($value) && isset($value->key) && isset($value->value)) {
20
+ $parsedFilters[$value->key] = $value->value;
21
+ } else {
22
+ $parsedFilters[$field] = $value;
23
+ }
24
+ }
25
+ }
26
+ // parse complex filter
27
+ if (isset($filters->complex_filter) && is_array($filters->complex_filter)) {
28
+ $parsedFilters += $this->_parseComplexFilterReplacement($filters->complex_filter);
29
+ }
30
+
31
+ $filters = $parsedFilters;
32
+ }
33
+ // make sure that method result is always array
34
+ if (!is_array($filters)) {
35
+ $filters = array();
36
+ }
37
+ // apply fields mapping
38
+ if (isset($fieldsMap) && is_array($fieldsMap)) {
39
+ foreach ($filters as $field => $value) {
40
+ if (isset($fieldsMap[$field])) {
41
+ unset($filters[$field]);
42
+ $field = $fieldsMap[$field];
43
+ $filters[$field] = $value;
44
+ }
45
+ }
46
+ }
47
+ return $filters;
48
+ }
49
+
50
+ /**
51
+ * Parses complex filter, which may contain several nodes, e.g. when user want to fetch orders which were updated
52
+ * between two dates.
53
+ *
54
+ * @param array $complexFilter
55
+ * @return array
56
+ */
57
+ protected function _parseComplexFilterReplacement($complexFilter)
58
+ {
59
+ $parsedFilters = array();
60
+
61
+ foreach ($complexFilter as $filter) {
62
+ if (!isset($filter->key) || !isset($filter->value)) {
63
+ continue;
64
+ }
65
+
66
+ list($fieldName, $condition) = array($filter->key, $filter->value);
67
+ $conditionName = $condition->key;
68
+ $conditionValue = $condition->value;
69
+ $this->formatFilterConditionValueReplacement($conditionName, $conditionValue);
70
+
71
+ if (array_key_exists($fieldName, $parsedFilters)) {
72
+ $parsedFilters[$fieldName] += array($conditionName => $conditionValue);
73
+ } else {
74
+ $parsedFilters[$fieldName] = array($conditionName => $conditionValue);
75
+ }
76
+ }
77
+
78
+ return $parsedFilters;
79
+ }
80
+
81
+ /**
82
+ * Convert condition value from the string into the array
83
+ * for the condition operators that require value to be an array.
84
+ * Condition value is changed by reference
85
+ *
86
+ * @param string $conditionOperator
87
+ * @param string $conditionValue
88
+ */
89
+ public function formatFilterConditionValueReplacement($conditionOperator, &$conditionValue)
90
+ {
91
+ if (is_string($conditionOperator) && in_array($conditionOperator, array('in', 'nin', 'finset'))
92
+ && is_string($conditionValue)
93
+ ) {
94
+ $delimiter = ',';
95
+ $conditionValue = explode($delimiter, $conditionValue);
96
+ }
97
+ }
98
  }
99
+
app/code/community/DataFeedWatch/Connector/Model/Api/User.php CHANGED
@@ -8,9 +8,14 @@
8
 
9
  class DataFeedWatch_Connector_Model_Api_User extends Mage_Api_Model_User {
10
 
 
 
 
 
11
  public function save()
12
  {
13
- $this->_beforeSave();
 
14
  $data = array(
15
  'firstname' => $this->getFirstname(),
16
  'lastname' => $this->getLastname(),
@@ -37,14 +42,16 @@ class DataFeedWatch_Connector_Model_Api_User extends Mage_Api_Model_User {
37
  if ( !is_null($this->getIsActive()) ) {
38
  $data['is_active'] = intval($this->getIsActive());
39
  }
40
- if ( $this->getDfwConnectHash() ) {
41
- $data['dfw_connect_hash'] = $this->getDfwConnectHash();
42
- }
 
43
 
44
 
45
  $this->setData($data);
46
  $this->_getResource()->save($this);
47
  $this->_afterSave();
48
  return $this;
 
49
  }
50
  }
8
 
9
  class DataFeedWatch_Connector_Model_Api_User extends Mage_Api_Model_User {
10
 
11
+ /**
12
+ * @deprecated since 0.2.9
13
+ * @return Mage_Api_Model_User|Mage_Core_Model_Abstract
14
+ */
15
  public function save()
16
  {
17
+ return parent::save();
18
+ /*$this->_beforeSave();
19
  $data = array(
20
  'firstname' => $this->getFirstname(),
21
  'lastname' => $this->getLastname(),
42
  if ( !is_null($this->getIsActive()) ) {
43
  $data['is_active'] = intval($this->getIsActive());
44
  }
45
+
46
+ //if ( $this->getDfwConnectHash() ) {
47
+ // $data['dfw_connect_hash'] = $this->getDfwConnectHash();
48
+ // }
49
 
50
 
51
  $this->setData($data);
52
  $this->_getResource()->save($this);
53
  $this->_afterSave();
54
  return $this;
55
+ */
56
  }
57
  }
app/code/community/DataFeedWatch/Connector/Model/Datafeedwatch/Api.php CHANGED
@@ -1,6 +1,7 @@
1
  <?php
2
 
3
- class DataFeedWatch_Connector_Model_Datafeedwatch_Api extends Mage_Catalog_Model_Product_Api {
 
4
 
5
  const STOCK_ITEM_MODEL = 'cataloginventory/stock_item';
6
  const CATALOG_PRODUCT_MODEL = 'catalog/product';
@@ -16,34 +17,37 @@ class DataFeedWatch_Connector_Model_Datafeedwatch_Api extends Mage_Catalog_Model
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.9"; // 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
@@ -54,12 +58,17 @@ class DataFeedWatch_Connector_Model_Datafeedwatch_Api extends Mage_Catalog_Model
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);
@@ -76,7 +85,8 @@ class DataFeedWatch_Connector_Model_Datafeedwatch_Api extends Mage_Catalog_Model
76
  return round($numberOfProducts);
77
  }
78
 
79
- public function products($options = array()) {
 
80
 
81
  $this->_versionInfo = Mage::getVersionInfo();
82
 
@@ -93,11 +103,11 @@ class DataFeedWatch_Connector_Model_Datafeedwatch_Api extends Mage_Catalog_Model
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
 
@@ -119,9 +129,9 @@ class DataFeedWatch_Connector_Model_Datafeedwatch_Api extends Mage_Catalog_Model
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
 
@@ -137,11 +147,18 @@ class DataFeedWatch_Connector_Model_Datafeedwatch_Api extends Mage_Catalog_Model
137
 
138
  /** @var $apiHelper Mage_Api_Helper_Data */
139
  $apiHelper = Mage::helper('api');
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);
@@ -155,12 +172,14 @@ class DataFeedWatch_Connector_Model_Datafeedwatch_Api extends Mage_Catalog_Model
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 = null;
 
 
164
  $configrable = false;
165
 
166
  if ($product->getTypeId() == "simple") {
@@ -173,20 +192,44 @@ class DataFeedWatch_Connector_Model_Datafeedwatch_Api extends Mage_Catalog_Model
173
  }
174
  if (isset($parentIds[0])) {
175
  //$parent_id = Mage::getModel('catalog/product')->load($parentIds[0])->getId();
 
176
  $parent_product = Mage::getModel('catalog/product')->load($parentIds[0]);
177
- if($parent_product->getStatus() == 2 && $product->getVisibility() == 1) {
 
 
 
 
 
 
 
 
 
 
 
 
178
  continue;
179
  }
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()
187
  );
188
 
189
  $product_result['parent_id'] = $parent_id;
 
 
190
 
191
  foreach ($product->getAttributes() as $attribute) {
192
 
@@ -203,38 +246,24 @@ class DataFeedWatch_Connector_Model_Datafeedwatch_Api extends Mage_Catalog_Model
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');
217
- // }
218
- // } else {
219
- // $imageUrl = $imageBaseURL . $imageUrl;
220
- // }
221
- $imageUrl = (string) $product->getMediaConfig()->getMediaUrl($product->getData('image'));
222
  $imageTmpArr = explode('.', $imageUrl);
223
  $countImgArr = count($imageTmpArr);
224
  if (empty($imageUrl) || $imageUrl == '' || !isset($imageUrl) || $countImgArr < 2) {
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);
@@ -248,17 +277,17 @@ class DataFeedWatch_Connector_Model_Datafeedwatch_Api extends Mage_Catalog_Model
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
  }
@@ -268,7 +297,7 @@ class DataFeedWatch_Connector_Model_Datafeedwatch_Api extends Mage_Catalog_Model
268
 
269
  $inventoryStatus = Mage::getModel(self::STOCK_ITEM_MODEL)->loadByProduct($product);
270
  if (!empty($inventoryStatus)) {
271
- $product_result['quantity'] = (int) $inventoryStatus->getQty();
272
  $product_result['is_in_stock'] = $inventoryStatus->getIsInStock() == '1' ? 1 : 0;
273
  }
274
  $result[] = $product_result;
@@ -277,7 +306,8 @@ class DataFeedWatch_Connector_Model_Datafeedwatch_Api extends Mage_Catalog_Model
277
  return $result;
278
  }
279
 
280
- private function _loadCategories() {
 
281
 
282
  $parentId = 1;
283
 
@@ -304,7 +334,8 @@ class DataFeedWatch_Connector_Model_Datafeedwatch_Api extends Mage_Catalog_Model
304
  * @param Varien_Data_Tree_Node $node
305
  * @return array
306
  */
307
- private function _nodeToArray(Varien_Data_Tree_Node $node) {
 
308
  $children = $node->getChildren();
309
  if (!empty($children)) {
310
  foreach ($children as $child) {
@@ -320,7 +351,8 @@ class DataFeedWatch_Connector_Model_Datafeedwatch_Api extends Mage_Catalog_Model
320
  );
321
  }
322
 
323
- private function _buildCategoryPath($category_id, &$path = array()) {
 
324
  $this->productCategories[] = $category_id;
325
  $category = $this->categories[$category_id];
326
 
@@ -335,7 +367,8 @@ class DataFeedWatch_Connector_Model_Datafeedwatch_Api extends Mage_Catalog_Model
335
  return $path;
336
  }
337
 
338
- private function _notNeededFields() {
 
339
  return array(
340
  'type' => 0,
341
  'type_id' => 0,
@@ -382,7 +415,8 @@ class DataFeedWatch_Connector_Model_Datafeedwatch_Api extends Mage_Catalog_Model
382
  );
383
  }
384
 
385
- private function getDisplayPrice($product_id) {
 
386
 
387
  if (!$product_id) {
388
  return 0;
@@ -390,7 +424,7 @@ class DataFeedWatch_Connector_Model_Datafeedwatch_Api extends Mage_Catalog_Model
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) {
@@ -419,19 +453,22 @@ class DataFeedWatch_Connector_Model_Datafeedwatch_Api extends Mage_Catalog_Model
419
 
420
  $prices['description'] = $product->getDescription();
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);
432
  $countImgArr = count($imageTmpArr);
433
  if (empty($imageUrl) || $imageUrl == '' || !isset($imageUrl) || $countImgArr < 2) {
434
- $imageUrl = (string) Mage::helper('catalog/image')->init($product, 'image');
435
  }
436
  $prices['image_url'] = $imageUrl;
437
 
@@ -439,15 +476,16 @@ class DataFeedWatch_Connector_Model_Datafeedwatch_Api extends Mage_Catalog_Model
439
  if (count($additional_images) > 0) {
440
  $i = 1;
441
  foreach ($additional_images as $images) {
442
- if($images->getUrl() != $prices['image_url'])
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'])
450
- || empty($product['special_to_date']))) {
 
451
  $prices['special_price'] = $_taxHelper->getPrice($product, $product->getSpecialPrice(), NULL);
452
  $prices['special_price_with_tax'] = $_taxHelper->getPrice($product, $product->getSpecialPrice(), 2);
453
  $prices['special_from_date'] = $product['special_from_date'];
@@ -460,7 +498,8 @@ class DataFeedWatch_Connector_Model_Datafeedwatch_Api extends Mage_Catalog_Model
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']))) {
 
464
  $prices['special_price_with_tax'] = Mage::helper('directory')->currencyConvert($prices['special_price_with_tax'], $bas_curncy_code, $cur_curncy_code);
465
  $prices['special_price'] = Mage::helper('directory')->currencyConvert($prices['special_price'], $bas_curncy_code, $cur_curncy_code);
466
  }
@@ -473,7 +512,7 @@ class DataFeedWatch_Connector_Model_Datafeedwatch_Api extends Mage_Catalog_Model
473
  $attributes = $product->getAttributes();
474
  //$attrs = $product->getTypeInstance(true)->getConfigurableAttributesAsArray($product);
475
  foreach ($attributes as $attribute) {
476
- if ($attribute->getIsUserDefined()) { //&& $attribute->getIsVisibleOnFront()
477
  if (!array_key_exists($attribute->getAttributeCode(), $this->_notNeededFields())) {
478
  $value = $product->getData($attribute->getAttributeCode());
479
  if (!empty($value)) {
@@ -487,9 +526,9 @@ class DataFeedWatch_Connector_Model_Datafeedwatch_Api extends Mage_Catalog_Model
487
  // categories
488
  $category_id = $product->getCategoryIds();
489
  if (empty($category_id)) {
490
- $prices['category_name'] = '';
491
  $prices['category_parent_name'] = '';
492
- $prices['category_path'] = '';
493
  } else {
494
  rsort($category_id);
495
  $this->productCategories = array();
@@ -498,29 +537,25 @@ class DataFeedWatch_Connector_Model_Datafeedwatch_Api extends Mage_Catalog_Model
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'];
517
- // $prices['category_path'] = implode(' > ', $this->_buildCategoryPath($category['category_id']));
518
  }
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();
1
  <?php
2
 
3
+ class DataFeedWatch_Connector_Model_Datafeedwatch_Api extends Mage_Catalog_Model_Product_Api
4
+ {
5
 
6
  const STOCK_ITEM_MODEL = 'cataloginventory/stock_item';
7
  const CATALOG_PRODUCT_MODEL = 'catalog/product';
17
  public $storeCategories = array();
18
 
19
  protected $_supportedEnterprise = array(
20
+ 'major' => '1',
21
+ 'minor' => '13',
22
+ 'revision' => '0',
23
+ 'patch' => '2',
24
  'stability' => '',
25
+ 'number' => '',
26
  );
27
 
28
+ public function __construct()
29
+ {
30
  $this->productCategories = array();
31
  ini_set('memory_limit', '1024M');
32
  }
33
 
34
+ public function version()
35
+ {
36
+ return Mage::getConfig()->getNode('modules/DataFeedWatch_Connector')->version;
37
  }
38
 
39
+ public function product_count($options = array())
40
+ {
41
  $collection = Mage::getModel(self::CATALOG_PRODUCT_MODEL)
42
  ->getCollection();
43
 
44
  if (array_key_exists('store', $options)) {
45
  //convert store code to store id
46
+ if (!is_numeric($options['store'])) {
47
  $options['store'] = Mage::app()->getStore($options['store'])->getId();
48
  }
49
 
50
+ if ($options['store']) {
51
  $collection->addStoreFilter($options['store']);
52
  } else {
53
  //use default solution
58
  }
59
 
60
  $apiHelper = Mage::helper('api');
61
+ if (method_exists($apiHelper, 'parseFilters')) {
62
+ $filters = $apiHelper->parseFilters($options, $this->_filtersMap);
63
+ } else {
64
+ $dataFeedWatchHelper = Mage::helper('connector');
65
+ $filters = $dataFeedWatchHelper->parseFiltersReplacement($options, $this->_filtersMap);
66
+ }
67
 
68
  try {
69
  foreach ($filters as $field => $value) {
70
  //ignore status when flat catalog is enabled
71
+ if ($field == 'status' && Mage::getStoreConfig('catalog/frontend/flat_catalog_product') == 1) {
72
  continue;
73
  }
74
  $collection->addFieldToFilter($field, $value);
85
  return round($numberOfProducts);
86
  }
87
 
88
+ public function products($options = array())
89
+ {
90
 
91
  $this->_versionInfo = Mage::getVersionInfo();
92
 
103
 
104
  if (array_key_exists('store', $options)) {
105
  //convert store code to store id
106
+ if (!is_numeric($options['store'])) {
107
  $options['store'] = Mage::app()->getStore($options['store'])->getId();
108
  }
109
 
110
+ if ($options['store']) {
111
  $this->storeId = $options['store'];
112
  Mage::app()->setCurrentStore($this->storeId);
113
 
129
  $storeCategoriesCollection = Mage::getModel('catalog/category')->getCollection()
130
  ->addAttributeToSelect('name')
131
  ->addAttributeToSelect('is_active')
132
+ ->addPathsFilter('%/' . $this->storeRootCategoryId);
133
 
134
+ foreach ($storeCategoriesCollection as $storeCategory) {
135
  $this->storeCategories[] = $storeCategory->getId();
136
  }
137
 
147
 
148
  /** @var $apiHelper Mage_Api_Helper_Data */
149
  $apiHelper = Mage::helper('api');
150
+ if (method_exists($apiHelper, 'parseFilters')) {
151
+ $filters = $apiHelper->parseFilters($options, $this->_filtersMap);
152
+ } else {
153
+ $dataFeedWatchHelper = Mage::helper('connector');
154
+ $filters = $dataFeedWatchHelper->parseFiltersReplacement($options, $this->_filtersMap);
155
+ }
156
+
157
+
158
  try {
159
  foreach ($filters as $field => $value) {
160
  //ignore status when flat catalog is enabled
161
+ if ($field == 'status' && Mage::getStoreConfig('catalog/frontend/flat_catalog_product') == 1) {
162
  continue;
163
  }
164
  $collection->addFieldToFilter($field, $value);
172
  $price_keys = array('price', 'special_price');
173
 
174
  foreach ($collection as $product) {
175
+ if ($this->storeId) {
176
  $product = Mage::getModel('catalog/product')->setStoreId($this->storeId)->load($product->getId());
177
  } else {
178
  $product = Mage::getModel('catalog/product')->load($product->getId());
179
  }
180
  $parent_id = null;
181
+ $parent_sku = null;
182
+ $parent_url = null;
183
  $configrable = false;
184
 
185
  if ($product->getTypeId() == "simple") {
192
  }
193
  if (isset($parentIds[0])) {
194
  //$parent_id = Mage::getModel('catalog/product')->load($parentIds[0])->getId();
195
+
196
  $parent_product = Mage::getModel('catalog/product')->load($parentIds[0]);
197
+ while (!$parent_product->getId()) {
198
+ if (count($parentIds) > 1) {
199
+ //parent nt found, remove and rty wth next one
200
+ array_shift($parentIds);
201
+ $parent_product = Mage::getModel('catalog/product')->load($parentIds[0]);
202
+ } else {
203
+ break;
204
+ }
205
+ }
206
+
207
+ if ($parent_product->getStatus() == Mage_Catalog_Model_Product_Status::STATUS_DISABLED
208
+ && $product->getVisibility() == Mage_Catalog_Model_Product_Visibility::VISIBILITY_NOT_VISIBLE
209
+ ) {
210
  continue;
211
  }
212
  $parent_id = $parent_product->getId();
213
+ $parent_sku = $parent_product->getSku();
214
+
215
+ //parent_url
216
+ if (method_exists(Mage, 'getEdition') && Mage::getEdition() == Mage::EDITION_ENTERPRISE && Mage::getVersionInfo() >= $this->_supportedEnterprise) {
217
+ $parent_url = $parent_product->getProductUrl();
218
+ } else {
219
+ $parent_url = $baseUrl . $parent_product->getUrlPath();
220
+ }
221
+
222
  }
223
  }
224
 
225
+ $product_result = array( // Basic product data
226
  'product_id' => $product->getId(),
227
  'sku' => $product->getSku()
228
  );
229
 
230
  $product_result['parent_id'] = $parent_id;
231
+ $product_result['parent_sku'] = $parent_sku;
232
+ $product_result['parent_url'] = $parent_url;
233
 
234
  foreach ($product->getAttributes() as $attribute) {
235
 
246
  }
247
  }
248
 
249
+ $imageUrl = (string)$product->getMediaConfig()->getMediaUrl($product->getData('image'));
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
250
  $imageTmpArr = explode('.', $imageUrl);
251
  $countImgArr = count($imageTmpArr);
252
  if (empty($imageUrl) || $imageUrl == '' || !isset($imageUrl) || $countImgArr < 2) {
253
+ $imageUrl = (string)Mage::helper('catalog/image')->init($product, 'image');
254
  }
255
 
256
 
257
+ if (method_exists(Mage, 'getEdition') && Mage::getEdition() == Mage::EDITION_ENTERPRISE && Mage::getVersionInfo() >= $this->_supportedEnterprise) {
258
  $product_result['product_url'] = $product->getProductUrl();
259
  } else {
260
  $product_result['product_url'] = $baseUrl . $product->getUrlPath();
261
  }
262
+
263
  $product_result['image_url'] = $imageUrl;
264
 
265
  $tmpPrices = array();
266
+ if ($parent_id && $configrable && $product->getVisibility() == Mage_Catalog_Model_Product_Visibility::VISIBILITY_NOT_VISIBLE) {
267
  $tmpPrices = $this->getDisplayPrice($parent_id);
268
  } else {
269
  $tmpPrices = $this->getDisplayPrice($product);
277
  and except when value (doesn't exist||is empty) in child
278
  also, use parent image_url if it's empty in child
279
  */
280
+ if (!array_key_exists($key, $product_result) || !$product_result[$key] || in_array($key, array('description', 'short_description', 'product_url', 'image_url'))) {
281
+ if ($key == 'image_url'
282
+ && !stristr($product_result[$key], '.jpg')
283
+ && !stristr($product_result[$key], '.png')
284
+ && !stristr($product_result[$key], '.jpeg')
285
+ && !stristr($product_result[$key], '.gif')
286
+ && !stristr($product_result[$key], '.bmp')
287
+ ) {
288
  //overwrite record image_url with parent's value when child doesn't have correct image url
289
  $product_result[$key] = $value;
290
+ } elseif ($key != 'image_url') {
291
  //overwrite description,short_description and product_url
292
  $product_result[$key] = $value;
293
  }
297
 
298
  $inventoryStatus = Mage::getModel(self::STOCK_ITEM_MODEL)->loadByProduct($product);
299
  if (!empty($inventoryStatus)) {
300
+ $product_result['quantity'] = (int)$inventoryStatus->getQty();
301
  $product_result['is_in_stock'] = $inventoryStatus->getIsInStock() == '1' ? 1 : 0;
302
  }
303
  $result[] = $product_result;
306
  return $result;
307
  }
308
 
309
+ private function _loadCategories()
310
+ {
311
 
312
  $parentId = 1;
313
 
334
  * @param Varien_Data_Tree_Node $node
335
  * @return array
336
  */
337
+ private function _nodeToArray(Varien_Data_Tree_Node $node)
338
+ {
339
  $children = $node->getChildren();
340
  if (!empty($children)) {
341
  foreach ($children as $child) {
351
  );
352
  }
353
 
354
+ private function _buildCategoryPath($category_id, &$path = array())
355
+ {
356
  $this->productCategories[] = $category_id;
357
  $category = $this->categories[$category_id];
358
 
367
  return $path;
368
  }
369
 
370
+ private function _notNeededFields()
371
+ {
372
  return array(
373
  'type' => 0,
374
  'type_id' => 0,
415
  );
416
  }
417
 
418
+ private function getDisplayPrice($product_id)
419
+ {
420
 
421
  if (!$product_id) {
422
  return 0;
424
 
425
  $prices = array();
426
 
427
+ if ($product_id instanceof Mage_Catalog_Model_Product) {
428
  $product = $product_id;
429
  } else {
430
  if ($product_id < 1) {
453
 
454
  $prices['description'] = $product->getDescription();
455
  $prices['short_description'] = $product->getShortDescription();
456
+ $prices['short_description'] = $product->getShortDescription();
457
 
458
  $baseUrl = Mage::getBaseUrl(Mage_Core_Model_Store::URL_TYPE_WEB);
459
+
460
+ if (method_exists(Mage, 'getEdition') && Mage::getEdition() == Mage::EDITION_ENTERPRISE && Mage::getVersionInfo() >= $this->_supportedEnterprise) {
461
  $product_result['product_url'] = $product->getProductUrl();
462
  } else {
463
  $product_result['product_url'] = $baseUrl . $product->getUrlPath();
464
  }
465
+
466
  //Setting image
467
+ $imageUrl = (string)$product->getMediaConfig()->getMediaUrl($product->getData('image'));
468
  $imageTmpArr = explode('.', $imageUrl);
469
  $countImgArr = count($imageTmpArr);
470
  if (empty($imageUrl) || $imageUrl == '' || !isset($imageUrl) || $countImgArr < 2) {
471
+ $imageUrl = (string)Mage::helper('catalog/image')->init($product, 'image');
472
  }
473
  $prices['image_url'] = $imageUrl;
474
 
476
  if (count($additional_images) > 0) {
477
  $i = 1;
478
  foreach ($additional_images as $images) {
479
+ if ($images->getUrl() != $prices['image_url'])
480
+ $prices['additional_image_url' . $i++] = $images->getUrl();
481
  }
482
  }
483
 
484
  $specialTmpPrice = $product->getSpecialPrice();
485
 
486
  if ($specialTmpPrice && (strtotime(date('Y-m-d H:i:s')) < strtotime($product['special_to_date'])
487
+ || empty($product['special_to_date']))
488
+ ) {
489
  $prices['special_price'] = $_taxHelper->getPrice($product, $product->getSpecialPrice(), NULL);
490
  $prices['special_price_with_tax'] = $_taxHelper->getPrice($product, $product->getSpecialPrice(), 2);
491
  $prices['special_from_date'] = $product['special_from_date'];
498
  && array_key_exists($cur_curncy_code, $currencyRates)
499
  ) {
500
  if ($prices['special_price'] && (strtotime(date('Y-m-d H:i:s')) < strtotime($product['special_to_date'])
501
+ || empty($product['special_to_date']))
502
+ ) {
503
  $prices['special_price_with_tax'] = Mage::helper('directory')->currencyConvert($prices['special_price_with_tax'], $bas_curncy_code, $cur_curncy_code);
504
  $prices['special_price'] = Mage::helper('directory')->currencyConvert($prices['special_price'], $bas_curncy_code, $cur_curncy_code);
505
  }
512
  $attributes = $product->getAttributes();
513
  //$attrs = $product->getTypeInstance(true)->getConfigurableAttributesAsArray($product);
514
  foreach ($attributes as $attribute) {
515
+ if ($attribute->getIsUserDefined()) { //&& $attribute->getIsVisibleOnFront()
516
  if (!array_key_exists($attribute->getAttributeCode(), $this->_notNeededFields())) {
517
  $value = $product->getData($attribute->getAttributeCode());
518
  if (!empty($value)) {
526
  // categories
527
  $category_id = $product->getCategoryIds();
528
  if (empty($category_id)) {
529
+ $prices['category_name'] = '';
530
  $prices['category_parent_name'] = '';
531
+ $prices['category_path'] = '';
532
  } else {
533
  rsort($category_id);
534
  $this->productCategories = array();
537
  // if(in_array($cate, $this->productCategories))
538
  // continue;
539
 
540
+ if (!in_array($cate, $this->storeCategories))
541
  continue;
542
 
543
  $category = $this->categories[$cate];
544
+ $prices['category_name' . $index] = $category['name'];
545
+ $prices['category_parent_name' . $index] = $this->categories[$category['parent_id']]['name'];
546
+ $prices['category_path' . $index] = implode(' > ', $this->_buildCategoryPath($category['category_id']));
547
+ if ($index == '')
548
  $index = 1;
549
  else
550
+ $index = $index + 1;
551
  }
 
 
 
 
 
552
  }
553
 
554
  return $prices;
555
  }
556
 
557
+ public function stores()
558
+ {
559
  foreach (Mage::app()->getWebsites() as $website) {
560
  foreach ($website->getGroups() as $group) {
561
  $stores = $group->getStores();
app/code/community/DataFeedWatch/Connector/controllers/Adminhtml/ConnectorbackendController.php CHANGED
@@ -5,6 +5,11 @@ class DataFeedWatch_Connector_Adminhtml_ConnectorbackendController extends Mage_
5
  protected $lastname = 'DataFeedWatch';
6
  protected $email = 'magento@datafeedwatch.com';
7
  protected $register_url = 'https://my.datafeedwatch.com/platforms/magento/sessions/finalize';
 
 
 
 
 
8
  protected $redirect_url = 'https://my.datafeedwatch.com/';
9
 
10
  public function indexAction() {
@@ -14,51 +19,25 @@ class DataFeedWatch_Connector_Adminhtml_ConnectorbackendController extends Mage_
14
  }
15
 
16
  public function createuserAction() {
17
- $api_key = $this->_generateApiKey();
18
-
19
- $data = array(
20
- 'username' => $this->username,
21
- 'firstname' => $this->firstname,
22
- 'lastname' => $this->lastname,
23
- 'email' => $this->email,
24
- 'api_key' => '',
25
- 'api_key_confirmation' => '',
26
- 'is_active' => 1
27
- );
28
-
29
- $role = Mage::getModel('api/roles')->load($this->lastname, 'role_name');
30
 
31
- if ($role->isObjectNew()) {
32
- $role = $role
33
- ->setName($this->lastname)
34
- ->setPid(false)
35
- ->setRoleType('G')
36
- ->save();
37
 
38
- $resource = array("all");
 
39
 
40
- Mage::getModel("api/rules")
41
- ->setRoleId($role->getId())
42
- ->setResources($resource)
43
- ->saveRel();
44
- }
45
 
 
 
46
 
47
- $user = Mage::getModel('api/user');
48
- $user->setData($data);
49
- $user->save();
50
-
51
- $user->setRoleId($role->getId())->setUserId($user->getId());
52
  $user->add();
53
 
54
- //add new hash
55
- $user = Mage::getModel('api/user')->load($user->getUserId());
56
- $hash = md5($user->getEmail().$user->getCreated());
57
- $user->setDfwConnectHash($hash);
58
- $user->save();
59
- Mage::log($user->getData());
60
-
61
- $this->getResponse()->setRedirect($this->_registerUrl($api_key,$user->getData('dfw_connect_hash')));
62
  return;
63
  }
64
 
@@ -67,29 +46,6 @@ class DataFeedWatch_Connector_Adminhtml_ConnectorbackendController extends Mage_
67
  return;
68
  }
69
 
70
- public function updatetokenAction() {
71
- $api_key = $this->_generateApiKey();
72
- $model = $this->getUser();
73
-
74
- $hash = $model->getDfwConnectHash();
75
-
76
- $data = array(
77
- 'user_id' => $model->getId(),
78
- 'username' => $this->username,
79
- 'firstname' => $this->firstname,
80
- 'lastname' => $this->lastname,
81
- 'email' => $this->email,
82
- 'api_key' => '',
83
- 'api_key_confirmation' => ''
84
- );
85
-
86
- $model->setData($data);
87
- $model->save();
88
-
89
- $this->getResponse()->setRedirect($this->_registerUrl($api_key,$hash));
90
- return;
91
- }
92
-
93
  public function getUser() {
94
  $model = Mage::getModel('api/user');
95
  return $model->load($this->email, 'email');
@@ -99,8 +55,43 @@ class DataFeedWatch_Connector_Adminhtml_ConnectorbackendController extends Mage_
99
  return sha1(time()+substr(str_shuffle("0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ"), 0, 32));
100
  }
101
 
102
- private function _registerUrl($api_key,$hash) {
103
-
104
- return $this->register_url.'?shop='.Mage::getBaseUrl(Mage_Core_Model_Store::URL_TYPE_WEB).'&token='.$api_key.'&hash='.$hash;
105
  }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
106
  }
5
  protected $lastname = 'DataFeedWatch';
6
  protected $email = 'magento@datafeedwatch.com';
7
  protected $register_url = 'https://my.datafeedwatch.com/platforms/magento/sessions/finalize';
8
+
9
+ /**
10
+ * currently the same as $register_url
11
+ * @var string
12
+ */
13
  protected $redirect_url = 'https://my.datafeedwatch.com/';
14
 
15
  public function indexAction() {
19
  }
20
 
21
  public function createuserAction() {
 
 
 
 
 
 
 
 
 
 
 
 
 
22
 
23
+ //Create Api Role for datafeedwatch user
24
+ $role = $this->_createApiRole();
 
 
 
 
25
 
26
+ //Prepare Api Key
27
+ $api_key = $this->_generateApiKey();
28
 
29
+ //send the api key to DFW
30
+ file_get_contents($this->_registerUrl($api_key));
 
 
 
31
 
32
+ //Create Api User
33
+ $user = $this->_createApiUser($api_key);
34
 
35
+ //Assign Api User to the Api Role
36
+ $user->setRoleId($role->getId())->setUserId($user->getId());
 
 
 
37
  $user->add();
38
 
39
+ //redirect to register token url in DFW
40
+ $this->getResponse()->setRedirect($this->_registerUrl($api_key));
 
 
 
 
 
 
41
  return;
42
  }
43
 
46
  return;
47
  }
48
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
49
  public function getUser() {
50
  $model = Mage::getModel('api/user');
51
  return $model->load($this->email, 'email');
55
  return sha1(time()+substr(str_shuffle("0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ"), 0, 32));
56
  }
57
 
58
+ private function _registerUrl($api_key) {
59
+ return $this->register_url.'?shop='.Mage::getBaseUrl().'&token='.$api_key;
 
60
  }
61
+
62
+ private function _createApiRole(){
63
+ $role = Mage::getModel('api/roles')->load($this->lastname, 'role_name');
64
+ if ($role->isObjectNew()) {
65
+ $role = $role
66
+ ->setName($this->lastname)
67
+ ->setPid(false)
68
+ ->setRoleType('G')
69
+ ->save();
70
+
71
+ $resource = array("all");
72
+
73
+ Mage::getModel("api/rules")
74
+ ->setRoleId($role->getId())
75
+ ->setResources($resource)
76
+ ->saveRel();
77
+ }
78
+ return $role;
79
+ }
80
+
81
+ private function _createApiUser($api_key){
82
+ $data = array(
83
+ 'username' => $this->username,
84
+ 'firstname' => $this->firstname,
85
+ 'lastname' => $this->lastname,
86
+ 'email' => $this->email,
87
+ 'is_active' => 1,
88
+ 'api_key' => $api_key,
89
+ 'api_key_confirmation' => $api_key,
90
+ );
91
+
92
+ $user = Mage::getModel('api/user');
93
+ $user->setData($data);
94
+ $user->save();
95
+ return $user;
96
+ }
97
  }
app/code/community/DataFeedWatch/Connector/controllers/TokenController.php CHANGED
@@ -2,12 +2,14 @@
2
  class DataFeedWatch_Connector_TokenController extends Mage_Core_Controller_Front_Action {
3
 
4
  /**
5
- *reachable by
 
6
  * http://magentostore.com/datafeedwatch/token/confirm/hash/b271ecf10045d888245202b3268a72fb/new_api_key/yournewkey
7
  */
8
  public function confirmAction()
9
  {
10
- $request = $this->getRequest();
 
11
  if(!$request->isPost()){
12
  Mage::log(__METHOD__.' - not sent through POST');
13
  } else {
@@ -23,6 +25,6 @@ class DataFeedWatch_Connector_TokenController extends Mage_Core_Controller_Front
23
  } else {
24
  Mage::log(__METHOD__.' - params are missing');
25
  }
26
- }
27
  }
28
  }
2
  class DataFeedWatch_Connector_TokenController extends Mage_Core_Controller_Front_Action {
3
 
4
  /**
5
+ * @deprecated - turned out to prevent problems, to remove with next revision
6
+ * reachable by
7
  * http://magentostore.com/datafeedwatch/token/confirm/hash/b271ecf10045d888245202b3268a72fb/new_api_key/yournewkey
8
  */
9
  public function confirmAction()
10
  {
11
+ return true;
12
+ /*$request = $this->getRequest();
13
  if(!$request->isPost()){
14
  Mage::log(__METHOD__.' - not sent through POST');
15
  } else {
25
  } else {
26
  Mage::log(__METHOD__.' - params are missing');
27
  }
28
+ }*/
29
  }
30
  }
app/code/community/DataFeedWatch/Connector/etc/api.xml CHANGED
@@ -21,9 +21,5 @@
21
  </methods>
22
  </datafeedwatch>
23
  </resources>
24
-
25
- <!--<resources_alias>-->
26
- <!--<product>catalog_product</product>-->
27
- <!--</resources_alias>-->
28
  </api>
29
  </config>
21
  </methods>
22
  </datafeedwatch>
23
  </resources>
 
 
 
 
24
  </api>
25
  </config>
app/code/community/DataFeedWatch/Connector/etc/config.xml CHANGED
@@ -2,20 +2,9 @@
2
  <config>
3
  <modules>
4
  <DataFeedWatch_Connector>
5
- <version>0.2.9</version>
6
  </DataFeedWatch_Connector>
7
  </modules>
8
- <frontend>
9
- <routers>
10
- <token>
11
- <use>standard</use>
12
- <args>
13
- <module>DataFeedWatch_Connector</module>
14
- <frontName>datafeedwatch</frontName>
15
- </args>
16
- </token>
17
- </routers>
18
- </frontend>
19
  <admin>
20
  <routers>
21
  <connector>
@@ -64,11 +53,6 @@
64
  <connector>
65
  <class>DataFeedWatch_Connector_Model</class>
66
  </connector>
67
- <api>
68
- <rewrite>
69
- <user>DataFeedWatch_Connector_Model_Api_User</user>
70
- </rewrite>
71
- </api>
72
  </models>
73
  <helpers>
74
  <connector>
2
  <config>
3
  <modules>
4
  <DataFeedWatch_Connector>
5
+ <version>0.2.11</version>
6
  </DataFeedWatch_Connector>
7
  </modules>
 
 
 
 
 
 
 
 
 
 
 
8
  <admin>
9
  <routers>
10
  <connector>
53
  <connector>
54
  <class>DataFeedWatch_Connector_Model</class>
55
  </connector>
 
 
 
 
 
56
  </models>
57
  <helpers>
58
  <connector>
app/code/community/DataFeedWatch/Connector/sql/datafeedwatch_connector_setup/upgrade-0.2.10-0.2.11.php ADDED
@@ -0,0 +1,9 @@
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /* @var $installer Mage_Core_Model_Resource_Setup */
3
+ $installer = $this;
4
+ $installer->startSetup();
5
+
6
+ // Add custom_hash for finding users
7
+ $installer->getConnection()->dropColumn($installer->getTable('api/user'), 'dfw_connect_hash');
8
+
9
+ $installer->endSetup();
app/code/community/DataFeedWatch/Connector/sql/datafeedwatch_connector_setup/upgrade-0.2.9-0.2.10.php ADDED
@@ -0,0 +1,6 @@
 
 
 
 
 
 
1
+ <?php
2
+ /* @var $installer Mage_Core_Model_Resource_Setup */
3
+ $installer = $this;
4
+ $installer->startSetup();
5
+
6
+ $installer->endSetup();
app/design/adminhtml/default/default/template/connector/connectorbackend.phtml CHANGED
@@ -1,15 +1,11 @@
1
  <h1>DataFeedWatch</h1>
2
  <br/>
3
  <br/>
4
- <?php
5
- if ($user->isObjectNew()) {
6
- ?>
7
- <button onclick="setLocation('<?php echo $this->getCreateUserUrl()?>')" type="button" class="scalable">Create my DataFeedWatch Token </button>
8
- <?php
9
  } else {
10
- ?>
11
- <button onclick="setLocation('<?php echo $this->getUpdateTokenUrl()?>')" type="button" class="scalable">Regenerate my DataFeedWatch Access Token</button>
12
- <?php
13
- }
14
- ?>
15
- <button onclick="setLocation('<?php echo $this->getRedirectUrl()?>')" type="button" class="scalable">Go to my DataFeedWatch</button>
1
  <h1>DataFeedWatch</h1>
2
  <br/>
3
  <br/>
4
+ <?php if ($user->isObjectNew()) {
5
+ $linkUrl = $this->getCreateUserUrl();
 
 
 
6
  } else {
7
+ $linkUrl = $this->getRedirectUrl();
8
+ } ?>
9
+
10
+ <button onclick="setLocation('<?php echo $linkUrl; ?>')" type="button" class="scalable">Go to my DataFeedWatch</button>
11
+
 
package.xml CHANGED
@@ -1,7 +1,7 @@
1
  <?xml version="1.0"?>
2
  <package>
3
  <name>DataFeedWatch_Connector</name>
4
- <version>0.2.9</version>
5
  <stability>stable</stability>
6
  <license uri="http://opensource.org/licenses/osl-3.0.php">OSL v3.0</license>
7
  <channel>community</channel>
@@ -9,11 +9,11 @@
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.9</notes>
13
  <authors><author><name>DataFeedWatch</name><user>Adeel</user><email>adeel.developer@gmail.com</email></author></authors>
14
- <date>2014-05-20</date>
15
- <time>15:54:06</time>
16
- <contents><target name="magecommunity"><dir name="DataFeedWatch"><dir name="Connector"><dir name="Block"><dir name="Adminhtml"><file name="Connectorbackend.php" hash="a5d0e6e40805181efa2f3b36b7c8d7e5"/></dir></dir><dir name="controllers"><dir name="Adminhtml"><file name="ConnectorbackendController.php" hash="09313d4b3d59712a01d98b9da8c70e73"/></dir><dir><dir name="Adminhtml"><file name="ConnectorbackendController.php" hash="09313d4b3d59712a01d98b9da8c70e73"/></dir></dir><file name="TokenController.php" hash="bf462203d013237e10d463e7b6292212"/></dir><dir name="etc"><file name="api.xml" hash="2ece4a0209f667be766d0dbabed6fae5"/><file name="config.xml" hash="6d06591f79a1d69417022139d74f8b75"/><file name="system.xml" hash="ab5e8d56d032ba69c930ab7879484212"/></dir><dir name="Helper"><file name="Data.php" hash="983d7ad023616b365dce180680e4f9f0"/></dir><dir name="Model"><dir name="Api"><file name="User.php" hash="de27f5eccf323fa37502dbf59e9ec20a"/></dir><dir name="Datafeedwatch"><file name="Api.php" hash="7022b8cf3083573311ac1ac60a88eeae"/></dir></dir><dir name="sql"><dir><dir name="datafeedwatch_connector_setup"><file name="install-0.2.9.php" hash="326a2968b7af5a987604f880ed7c4a3c"/></dir></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="bf983f35062ee9f2669a18cf22174bf4"/></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>
1
  <?xml version="1.0"?>
2
  <package>
3
  <name>DataFeedWatch_Connector</name>
4
+ <version>0.2.11</version>
5
  <stability>stable</stability>
6
  <license uri="http://opensource.org/licenses/osl-3.0.php">OSL v3.0</license>
7
  <channel>community</channel>
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.11</notes>
13
  <authors><author><name>DataFeedWatch</name><user>Adeel</user><email>adeel.developer@gmail.com</email></author></authors>
14
+ <date>2014-07-08</date>
15
+ <time>17:41:26</time>
16
+ <contents><target name="magecommunity"><dir name="DataFeedWatch"><dir name="Connector"><dir name="Block"><dir name="Adminhtml"><file name="Connectorbackend.php" hash="7d6af1cb6dd7df3799928fe073f5576b"/></dir></dir><dir name="controllers"><dir name="Adminhtml"><file name="ConnectorbackendController.php" hash="2da89bd06938584f9eafeac98e4a99ef"/></dir><dir><dir name="Adminhtml"><file name="ConnectorbackendController.php" hash="2da89bd06938584f9eafeac98e4a99ef"/></dir></dir><file name="TokenController.php" hash="573ca81b110e79bc3893ac298b2aa02b"/></dir><dir name="etc"><file name="api.xml" hash="eb6eecef3f0922b809f2701aed29325d"/><file name="config.xml" hash="b0ef68502ddcdf726375d74edd199311"/><file name="system.xml" hash="ab5e8d56d032ba69c930ab7879484212"/></dir><dir name="Helper"><file name="Data.php" hash="85269d06206056aeff2fb2c25938ff9c"/></dir><dir name="Model"><dir name="Api"><file name="User.php" hash="734f274e07ca62ecf04dbefecd316330"/></dir><dir name="Datafeedwatch"><file name="Api.php" hash="d1c89b7352d52b07350b6cfbc0903043"/></dir></dir><dir name="sql"><dir><dir name="datafeedwatch_connector_setup"><file name="install-0.2.9.php" hash="326a2968b7af5a987604f880ed7c4a3c"/><file name="upgrade-0.2.10-0.2.11.php" hash="9dcefa5cafd7efd8f192af4d9c1f0c2e"/><file name="upgrade-0.2.9-0.2.10.php" hash="c9e575e9925df8440eca5aa817c1d5e4"/></dir></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="43e0e0c8ee28090aa098b7d7c7a979ad"/></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>