Version Notes
DataFeedWatch Release version 0.2.18.12a with SUPEE-6788 admin fix
Download this release
Release Info
Developer | WordWatch |
Extension | DataFeedWatch_Connector |
Version | 0.2.18.12 |
Comparing to | |
See all releases |
Code changes from version 0.2.16 to 0.2.18.12
- app/code/community/DataFeedWatch/Connector/Block/Adminhtml/Settings/Edit/Form.php +20 -3
- app/code/community/DataFeedWatch/Connector/Helper/Data.php +606 -52
- app/code/community/DataFeedWatch/Connector/Model/Catalogrule/Info.php +8 -0
- app/code/community/DataFeedWatch/Connector/Model/Catalogrule/Info/Collection.php +8 -0
- app/code/community/DataFeedWatch/Connector/Model/Datafeedwatch/Api.php +325 -287
- app/code/community/DataFeedWatch/Connector/Model/Observer.php +51 -0
- app/code/community/DataFeedWatch/Connector/Model/Resource/Catalogrule/Info.php +8 -0
- app/code/community/DataFeedWatch/Connector/Model/Resource/Catalogrule/Info/Collection.php +8 -0
- app/code/community/DataFeedWatch/Connector/Model/Resource/Salesrule/Info.php +8 -0
- app/code/community/DataFeedWatch/Connector/Model/Resource/Salesrule/Info/Collection.php +7 -0
- app/code/community/DataFeedWatch/Connector/Model/Resource/Setup.php +5 -0
- app/code/community/DataFeedWatch/Connector/Model/Salesrule/Info.php +8 -0
- app/code/community/DataFeedWatch/Connector/Model/Salesrule/Info/Collection.php +7 -0
- app/code/community/DataFeedWatch/Connector/controllers/Adminhtml/ConnectorbackendController.php +0 -135
- app/code/community/DataFeedWatch/Connector/controllers/Adminhtml/{SettingsController.php → ConnectorsettingsController.php} +20 -5
- app/code/community/DataFeedWatch/Connector/etc/api.xml +6 -0
- app/code/community/DataFeedWatch/Connector/etc/config.xml +53 -11
- app/code/community/DataFeedWatch/Connector/sql/datafeedwatch_connector_setup/upgrade-0.2.10-0.2.11.ph +9 -0
- app/code/community/DataFeedWatch/Connector/sql/datafeedwatch_connector_setup/upgrade-0.2.18-0.2.18.6.ph +72 -0
- app/code/community/DataFeedWatch/Connector/sql/datafeedwatch_connector_setup/upgrade-0.2.18-0.2.18.6.php +72 -0
- app/code/community/DataFeedWatch/Connector/sql/datafeedwatch_connector_setup/upgrade-0.2.9-0.2.10.ph +6 -0
- app/design/adminhtml/default/default/layout/connector.xml +2 -2
- app/etc/modules/DataFeedWatch_Connector.xml +2 -0
- package.xml +9 -9
app/code/community/DataFeedWatch/Connector/Block/Adminhtml/Settings/Edit/Form.php
CHANGED
@@ -23,11 +23,30 @@ class DataFeedWatch_Connector_Block_Adminhtml_Settings_Edit_Form extends Mage_Ad
|
|
23 |
$required = Mage::helper('connector')->getRequiredAttributes();
|
24 |
$additional = array();
|
25 |
if(Mage::getStoreConfig('datafeedwatch/settings/attributes')){
|
26 |
-
$additional =
|
27 |
}
|
28 |
$data["required_attributes"] = array_keys($required);
|
29 |
$data["additional_attributes"] = $additional;
|
30 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
31 |
|
32 |
$fieldset->addField('required_attributes', 'checkboxes',array(
|
33 |
"label" => Mage::helper('connector')->__("Required Attributes"),
|
@@ -49,8 +68,6 @@ class DataFeedWatch_Connector_Block_Adminhtml_Settings_Edit_Form extends Mage_Ad
|
|
49 |
"name" => "additional_attributes[]"
|
50 |
));
|
51 |
|
52 |
-
|
53 |
-
|
54 |
$form->setValues($data);
|
55 |
|
56 |
return parent::_prepareForm();
|
23 |
$required = Mage::helper('connector')->getRequiredAttributes();
|
24 |
$additional = array();
|
25 |
if(Mage::getStoreConfig('datafeedwatch/settings/attributes')){
|
26 |
+
$additional = unserialize(Mage::getStoreConfig('datafeedwatch/settings/attributes'));
|
27 |
}
|
28 |
$data["required_attributes"] = array_keys($required);
|
29 |
$data["additional_attributes"] = $additional;
|
30 |
|
31 |
+
$collection = Mage::getModel('catalog/product')->getCollection();
|
32 |
+
if($collection){
|
33 |
+
$product = $collection->getFirstItem();
|
34 |
+
$product = Mage::getModel('catalog/product')->load($product->getId());
|
35 |
+
}
|
36 |
+
$baseUrl = Mage::getBaseUrl(Mage_Core_Model_Store::URL_TYPE_WEB);
|
37 |
+
$urlComment = '<br/><table>
|
38 |
+
<tr><td>Sample Product URL:</td><td>'.$baseUrl . $product->getUrlPath().'</td></tr>
|
39 |
+
<tr><td>Sample Full URL:</td><td>'.Mage::helper('connector')->getFullUrl($product).'</td></tr></table>';
|
40 |
+
|
41 |
+
$fieldset->addField('url_type','select', array(
|
42 |
+
'label' => Mage::helper('connector')->__('URL Type'),
|
43 |
+
'name' => 'url_type',
|
44 |
+
'values' => array(
|
45 |
+
'1' => 'Product URL',
|
46 |
+
'2' => 'Full URL'),
|
47 |
+
'after_element_html' => $urlComment
|
48 |
+
));
|
49 |
+
$data["url_type"] = Mage::getStoreConfig('datafeedwatch/settings/url_type');
|
50 |
|
51 |
$fieldset->addField('required_attributes', 'checkboxes',array(
|
52 |
"label" => Mage::helper('connector')->__("Required Attributes"),
|
68 |
"name" => "additional_attributes[]"
|
69 |
));
|
70 |
|
|
|
|
|
71 |
$form->setValues($data);
|
72 |
|
73 |
return parent::_prepareForm();
|
app/code/community/DataFeedWatch/Connector/Helper/Data.php
CHANGED
@@ -3,7 +3,7 @@ class DataFeedWatch_Connector_Helper_Data extends Mage_Core_Helper_Abstract
|
|
3 |
{
|
4 |
|
5 |
private $_categories;
|
6 |
-
private $
|
7 |
|
8 |
private $_required_attributes = array(
|
9 |
"product_id",
|
@@ -49,6 +49,8 @@ class DataFeedWatch_Connector_Helper_Data extends Mage_Core_Helper_Abstract
|
|
49 |
'minimal_price',
|
50 |
'msrp_display_actual_price_type',
|
51 |
'msrp',
|
|
|
|
|
52 |
);
|
53 |
|
54 |
private $_excluded_attributes = array(
|
@@ -67,7 +69,7 @@ class DataFeedWatch_Connector_Helper_Data extends Mage_Core_Helper_Abstract
|
|
67 |
'small_image_label' => 0,
|
68 |
'thumbnail_label' => 0,
|
69 |
'created_at' => 0,
|
70 |
-
'updated_at' => 0
|
71 |
'group_price' => 0,
|
72 |
'tier_price' => 0,
|
73 |
'enable_googlecheckout' => 0,
|
@@ -84,7 +86,6 @@ class DataFeedWatch_Connector_Helper_Data extends Mage_Core_Helper_Abstract
|
|
84 |
'url_path' => 0,
|
85 |
'image' => 0,
|
86 |
'small_image' => 0,
|
87 |
-
'thumbnail' => 0,
|
88 |
'media_gallery' => 0,
|
89 |
'gallery' => 0,
|
90 |
'entity_type_id' => 0,
|
@@ -92,12 +93,22 @@ class DataFeedWatch_Connector_Helper_Data extends Mage_Core_Helper_Abstract
|
|
92 |
'entity_id' => 0
|
93 |
);
|
94 |
|
|
|
95 |
/* currency fields - to prevent multiple calls */
|
96 |
private $_bas_curncy_code = null;
|
97 |
private $_cur_curncy_code = null;
|
98 |
private $_allowedCurrencies = null;
|
99 |
private $_currencyRates = null;
|
100 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
101 |
public function getRequiredAttributes(){
|
102 |
return $this->_required_attributes;
|
103 |
}
|
@@ -106,7 +117,7 @@ class DataFeedWatch_Connector_Helper_Data extends Mage_Core_Helper_Abstract
|
|
106 |
$attributesList = array();
|
107 |
$entityType = Mage::getModel('eav/config')->getEntityType(Mage_Catalog_Model_Product::ENTITY);
|
108 |
$attributesCollection = Mage::getModel('eav/entity_attribute')->getCollection()
|
109 |
-
|
110 |
foreach($attributesCollection as $attribute){
|
111 |
if(!in_array($attribute->getAttributeCode(),$this->_required_attributes)){
|
112 |
$attributesList[$attribute->getAttributeCode()] = $attribute->getAttributeCode();
|
@@ -212,22 +223,42 @@ class DataFeedWatch_Connector_Helper_Data extends Mage_Core_Helper_Abstract
|
|
212 |
|
213 |
public function buildCategoryPath($category_id, &$path = array())
|
214 |
{
|
215 |
-
|
216 |
-
|
217 |
-
|
218 |
-
if ($category['parent_id'] != '0') {
|
219 |
-
$this->buildCategoryPath($category['parent_id'], $path);
|
220 |
}
|
|
|
|
|
|
|
|
|
|
|
221 |
|
222 |
-
|
223 |
-
|
|
|
224 |
}
|
225 |
|
226 |
return $path;
|
227 |
}
|
228 |
|
229 |
-
|
|
|
|
|
|
|
|
|
|
|
230 |
{
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
231 |
$parentId = 1;
|
232 |
|
233 |
/* @var $tree Mage_Catalog_Model_Resource_Eav_Mysql4_Category_Tree */
|
@@ -255,26 +286,30 @@ class DataFeedWatch_Connector_Helper_Data extends Mage_Core_Helper_Abstract
|
|
255 |
*/
|
256 |
private function _nodeToArray(Varien_Data_Tree_Node $node)
|
257 |
{
|
258 |
-
|
259 |
-
if (!empty($children)) {
|
260 |
-
foreach ($children as $child) {
|
261 |
-
$this->_nodeToArray($child);
|
262 |
-
}
|
263 |
-
}
|
264 |
-
|
265 |
$this->_categories[$node->getId()] = array(
|
266 |
'category_id' => $node->getId(),
|
267 |
'parent_id' => $node->getParentId(),
|
268 |
'name' => $node->getName(),
|
269 |
'is_active' => $node->getIsActive()
|
270 |
);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
271 |
}
|
272 |
|
273 |
public function getCategories(){
|
274 |
return $this->_categories;
|
275 |
}
|
276 |
-
|
277 |
-
|
|
|
278 |
}
|
279 |
|
280 |
public function getExcludedAttributes(){
|
@@ -290,15 +325,15 @@ class DataFeedWatch_Connector_Helper_Data extends Mage_Core_Helper_Abstract
|
|
290 |
|
291 |
$baseUrl = Mage::getBaseUrl(Mage_Core_Model_Store::URL_TYPE_WEB);
|
292 |
|
293 |
-
|
|
|
294 |
$prices['product_url'] = $product->getProductUrl();
|
295 |
} else {
|
296 |
$prices['product_url_rewritten'] = $baseUrl . $this->getRewrittenProductUrl($product,null,$this->storeId);
|
297 |
$prices['product_url'] = $baseUrl . $product->getUrlPath();
|
298 |
}
|
299 |
|
300 |
-
|
301 |
-
$prices = $this->addPricesToResult($product,$prices);
|
302 |
|
303 |
// Getting Additional information
|
304 |
$attributes = $product->getAttributes();
|
@@ -310,7 +345,10 @@ class DataFeedWatch_Connector_Helper_Data extends Mage_Core_Helper_Abstract
|
|
310 |
|
311 |
//only fetch if value is not emtpy
|
312 |
if (!empty($value)) {
|
313 |
-
$value =
|
|
|
|
|
|
|
314 |
}
|
315 |
$prices[$attribute->getAttributeCode()] = $value;
|
316 |
}
|
@@ -325,46 +363,69 @@ class DataFeedWatch_Connector_Helper_Data extends Mage_Core_Helper_Abstract
|
|
325 |
* @param $parent_product Mage_Catalog_Model_Product
|
326 |
* @return array
|
327 |
*/
|
328 |
-
public function addProductDynamicAttributesToResult($product, $product_result, $parent_product = null
|
329 |
//categories
|
|
|
330 |
if ($parent_product != null) {
|
331 |
// inherit categories from parent
|
332 |
-
$product_result = $this->addProductCategoriesToResult($parent_product,$product_result
|
333 |
} else {
|
334 |
-
$product_result = $this->addProductCategoriesToResult($product,$product_result
|
335 |
}
|
336 |
|
337 |
//excluded images
|
338 |
$product_result = $this->addExcludedImagesToResult($product,$product_result);
|
339 |
|
340 |
//additional images
|
341 |
-
$product_result = $this->addAdditionalImagesToResult($product,$product_result);
|
342 |
|
343 |
return $product_result;
|
344 |
}
|
345 |
|
346 |
-
public function addProductCategoriesToResult($product,$product_result
|
|
|
|
|
|
|
|
|
|
|
347 |
|
348 |
-
$category_id = $product->getCategoryIds();
|
349 |
if (empty($category_id)) {
|
350 |
$product_result['category_name'] = '';
|
351 |
$product_result['category_parent_name'] = '';
|
352 |
$product_result['category_path'] = '';
|
353 |
} else {
|
354 |
rsort($category_id);
|
355 |
-
$this->productCategories = array();
|
356 |
$index = '';
|
357 |
foreach ($category_id as $key => $cate) {
|
358 |
-
|
|
|
|
|
359 |
continue;
|
360 |
}
|
361 |
|
362 |
-
$
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
363 |
$product_result['category_name' . $index] = $category['name'];
|
364 |
-
$product_result['category_parent_name' . $index] = $categoriesData['categories'][$category['parent_id']]['name'];
|
365 |
|
366 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
367 |
$product_result['category_path' . $index] = implode(' > ', $categoryPath);
|
|
|
368 |
if ($index == '') {
|
369 |
$index = 1;
|
370 |
} else {
|
@@ -377,8 +438,20 @@ class DataFeedWatch_Connector_Helper_Data extends Mage_Core_Helper_Abstract
|
|
377 |
|
378 |
}
|
379 |
|
380 |
-
public function addAdditionalImagesToResult($product
|
381 |
$additional_images = $product->getMediaGalleryImages();
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
382 |
if (count($additional_images) > 0) {
|
383 |
$i = 1;
|
384 |
foreach ($additional_images as $images) {
|
@@ -419,23 +492,28 @@ class DataFeedWatch_Connector_Helper_Data extends Mage_Core_Helper_Abstract
|
|
419 |
}
|
420 |
}
|
421 |
|
422 |
-
public function addPricesToResult($product,$prices){
|
423 |
|
424 |
$_taxHelper = Mage::helper('tax');
|
425 |
|
426 |
$this->prepareCurrencyRates();
|
427 |
|
428 |
-
$
|
429 |
-
|
430 |
-
$prices['
|
431 |
-
$prices['
|
|
|
|
|
|
|
432 |
$specialTmpPrice = $product->getSpecialPrice();
|
433 |
|
434 |
-
if ($specialTmpPrice
|
435 |
-
|
|
|
|
|
436 |
) {
|
437 |
-
$prices['special_price'] = $_taxHelper->getPrice($product, $
|
438 |
-
$prices['special_price_with_tax'] = $_taxHelper->getPrice($product, $
|
439 |
$prices['special_from_date'] = $product['special_from_date'];
|
440 |
$prices['special_to_date'] = $product['special_to_date'];
|
441 |
}
|
@@ -444,8 +522,10 @@ class DataFeedWatch_Connector_Helper_Data extends Mage_Core_Helper_Abstract
|
|
444 |
&& array_key_exists($this->_bas_curncy_code, $this->_currencyRates)
|
445 |
&& array_key_exists($this->_cur_curncy_code, $this->_currencyRates)
|
446 |
) {
|
447 |
-
if ($prices['special_price']
|
448 |
-
|
|
|
|
|
449 |
) {
|
450 |
$prices['special_price_with_tax'] = Mage::helper('directory')->currencyConvert($prices['special_price_with_tax'], $this->_bas_curncy_code, $this->_cur_curncy_code);
|
451 |
$prices['special_price'] = Mage::helper('directory')->currencyConvert($prices['special_price'], $this->_bas_curncy_code, $this->_cur_curncy_code);
|
@@ -454,27 +534,66 @@ class DataFeedWatch_Connector_Helper_Data extends Mage_Core_Helper_Abstract
|
|
454 |
$prices['price_with_tax'] = Mage::helper('directory')->currencyConvert($_finalPriceInclTax, $this->_bas_curncy_code, $this->_cur_curncy_code);
|
455 |
$prices['price'] = Mage::helper('directory')->currencyConvert($prices['price'], $this->_bas_curncy_code, $this->_cur_curncy_code);
|
456 |
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
457 |
return $prices;
|
458 |
}
|
459 |
|
460 |
-
public function addImageToResult($product,$
|
461 |
$imageUrl = (string)$product->getMediaConfig()->getMediaUrl($product->getData('image'));
|
462 |
$imageTmpArr = explode('.', $imageUrl);
|
463 |
$countImgArr = count($imageTmpArr);
|
464 |
if (empty($imageUrl) || $imageUrl == '' || !isset($imageUrl) || $countImgArr < 2) {
|
465 |
$imageUrl = (string)Mage::helper('catalog/image')->init($product, 'image');
|
466 |
}
|
467 |
-
$
|
468 |
|
469 |
-
return $
|
470 |
}
|
471 |
|
472 |
-
public function addStockInfoToResult($product,$product_result){
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
473 |
$inventoryStatus = Mage::getModel('cataloginventory/stock_item')->loadByProduct($product);
|
474 |
if (!empty($inventoryStatus)) {
|
475 |
$product_result['quantity'] = (int)$inventoryStatus->getQty();
|
476 |
$product_result['is_in_stock'] = $inventoryStatus->getIsInStock() == '1' ? 1 : 0;
|
477 |
}
|
|
|
|
|
|
|
|
|
|
|
|
|
478 |
return $product_result;
|
479 |
}
|
480 |
|
@@ -490,6 +609,441 @@ class DataFeedWatch_Connector_Helper_Data extends Mage_Core_Helper_Abstract
|
|
490 |
return $rewrite->getRequestPath();
|
491 |
}
|
492 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
493 |
|
494 |
}
|
495 |
|
3 |
{
|
4 |
|
5 |
private $_categories;
|
6 |
+
private $_storeCategories;
|
7 |
|
8 |
private $_required_attributes = array(
|
9 |
"product_id",
|
49 |
'minimal_price',
|
50 |
'msrp_display_actual_price_type',
|
51 |
'msrp',
|
52 |
+
'thumbnail',
|
53 |
+
'updated_at' /* aded to required so we can test updated_products */
|
54 |
);
|
55 |
|
56 |
private $_excluded_attributes = array(
|
69 |
'small_image_label' => 0,
|
70 |
'thumbnail_label' => 0,
|
71 |
'created_at' => 0,
|
72 |
+
/*'updated_at' => 0,*/
|
73 |
'group_price' => 0,
|
74 |
'tier_price' => 0,
|
75 |
'enable_googlecheckout' => 0,
|
86 |
'url_path' => 0,
|
87 |
'image' => 0,
|
88 |
'small_image' => 0,
|
|
|
89 |
'media_gallery' => 0,
|
90 |
'gallery' => 0,
|
91 |
'entity_type_id' => 0,
|
93 |
'entity_id' => 0
|
94 |
);
|
95 |
|
96 |
+
|
97 |
/* currency fields - to prevent multiple calls */
|
98 |
private $_bas_curncy_code = null;
|
99 |
private $_cur_curncy_code = null;
|
100 |
private $_allowedCurrencies = null;
|
101 |
private $_currencyRates = null;
|
102 |
|
103 |
+
private $_filtersMap = array();
|
104 |
+
|
105 |
+
public $storeId;
|
106 |
+
|
107 |
+
private $_attributeDefaultValues = array();
|
108 |
+
|
109 |
+
/*@TODO: rewrite this so this is not in both places, here and api class */
|
110 |
+
public $isSupportedEnterprise = false;
|
111 |
+
|
112 |
public function getRequiredAttributes(){
|
113 |
return $this->_required_attributes;
|
114 |
}
|
117 |
$attributesList = array();
|
118 |
$entityType = Mage::getModel('eav/config')->getEntityType(Mage_Catalog_Model_Product::ENTITY);
|
119 |
$attributesCollection = Mage::getModel('eav/entity_attribute')->getCollection()
|
120 |
+
->addFieldToFilter('entity_type_id', array('eq' => $entityType->getEntityTypeId()));
|
121 |
foreach($attributesCollection as $attribute){
|
122 |
if(!in_array($attribute->getAttributeCode(),$this->_required_attributes)){
|
123 |
$attributesList[$attribute->getAttributeCode()] = $attribute->getAttributeCode();
|
223 |
|
224 |
public function buildCategoryPath($category_id, &$path = array())
|
225 |
{
|
226 |
+
if(!$category_id){
|
227 |
+
return $path;
|
|
|
|
|
|
|
228 |
}
|
229 |
+
if(array_key_exists($category_id,$this->_categories)){
|
230 |
+
$category = $this->_categories[$category_id];
|
231 |
+
if ($category['parent_id'] != '0') {
|
232 |
+
$this->buildCategoryPath($category['parent_id'], $path);
|
233 |
+
}
|
234 |
|
235 |
+
if ($category['is_active'] == '1') {
|
236 |
+
$path[] = $category['name'];
|
237 |
+
}
|
238 |
}
|
239 |
|
240 |
return $path;
|
241 |
}
|
242 |
|
243 |
+
/**
|
244 |
+
* prepare _storeCategories and _categories
|
245 |
+
* @return array
|
246 |
+
* @throws Mage_Core_Exception
|
247 |
+
*/
|
248 |
+
public function loadCategories($storeRootCategoryId)
|
249 |
{
|
250 |
+
/* prepare _storeCategories */
|
251 |
+
$storeCategoriesCollection = Mage::getResourceModel('catalog/category_collection');
|
252 |
+
$storeCategoriesCollection->addAttributeToSelect('name')
|
253 |
+
->addAttributeToSelect('is_active')
|
254 |
+
->addPathsFilter('%/' . $storeRootCategoryId);
|
255 |
+
|
256 |
+
foreach ($storeCategoriesCollection as $storeCategory) {
|
257 |
+
/* @var $storeCategory Mage_Catalog_Model_Category */
|
258 |
+
$this->_storeCategories[] = $storeCategory->getId();
|
259 |
+
}
|
260 |
+
|
261 |
+
/* prepare _categories */
|
262 |
$parentId = 1;
|
263 |
|
264 |
/* @var $tree Mage_Catalog_Model_Resource_Eav_Mysql4_Category_Tree */
|
286 |
*/
|
287 |
private function _nodeToArray(Varien_Data_Tree_Node $node)
|
288 |
{
|
289 |
+
/* add this node to $this->_categories */
|
|
|
|
|
|
|
|
|
|
|
|
|
290 |
$this->_categories[$node->getId()] = array(
|
291 |
'category_id' => $node->getId(),
|
292 |
'parent_id' => $node->getParentId(),
|
293 |
'name' => $node->getName(),
|
294 |
'is_active' => $node->getIsActive()
|
295 |
);
|
296 |
+
|
297 |
+
/* parse children nodes */
|
298 |
+
$children = $node->getChildren();
|
299 |
+
/* @var $children Varien_Data_Tree_Node_Collection */
|
300 |
+
if (!empty($children)) {
|
301 |
+
foreach ($children->getNodes() as $child) {
|
302 |
+
$this->_nodeToArray($child);
|
303 |
+
}
|
304 |
+
}
|
305 |
}
|
306 |
|
307 |
public function getCategories(){
|
308 |
return $this->_categories;
|
309 |
}
|
310 |
+
|
311 |
+
public function getStoreCategories(){
|
312 |
+
return $this->_storeCategories;
|
313 |
}
|
314 |
|
315 |
public function getExcludedAttributes(){
|
325 |
|
326 |
$baseUrl = Mage::getBaseUrl(Mage_Core_Model_Store::URL_TYPE_WEB);
|
327 |
|
328 |
+
//$this->isSupportedEnterprise is set within api products call
|
329 |
+
if (method_exists($mageObject, 'getEdition') && Mage::getEdition() == Mage::EDITION_ENTERPRISE && $this->isSupportedEnterprise) {
|
330 |
$prices['product_url'] = $product->getProductUrl();
|
331 |
} else {
|
332 |
$prices['product_url_rewritten'] = $baseUrl . $this->getRewrittenProductUrl($product,null,$this->storeId);
|
333 |
$prices['product_url'] = $baseUrl . $product->getUrlPath();
|
334 |
}
|
335 |
|
336 |
+
|
|
|
337 |
|
338 |
// Getting Additional information
|
339 |
$attributes = $product->getAttributes();
|
345 |
|
346 |
//only fetch if value is not emtpy
|
347 |
if (!empty($value)) {
|
348 |
+
$value = $attribute->getFrontend()->getValue($product);
|
349 |
+
if(is_string($value)) {
|
350 |
+
$value = trim($value);
|
351 |
+
}
|
352 |
}
|
353 |
$prices[$attribute->getAttributeCode()] = $value;
|
354 |
}
|
363 |
* @param $parent_product Mage_Catalog_Model_Product
|
364 |
* @return array
|
365 |
*/
|
366 |
+
public function addProductDynamicAttributesToResult($product, $product_result, $parent_product = null){
|
367 |
//categories
|
368 |
+
|
369 |
if ($parent_product != null) {
|
370 |
// inherit categories from parent
|
371 |
+
$product_result = $this->addProductCategoriesToResult($parent_product,$product_result);
|
372 |
} else {
|
373 |
+
$product_result = $this->addProductCategoriesToResult($product,$product_result);
|
374 |
}
|
375 |
|
376 |
//excluded images
|
377 |
$product_result = $this->addExcludedImagesToResult($product,$product_result);
|
378 |
|
379 |
//additional images
|
380 |
+
$product_result = $this->addAdditionalImagesToResult($product,$product_result, $parent_product);
|
381 |
|
382 |
return $product_result;
|
383 |
}
|
384 |
|
385 |
+
public function addProductCategoriesToResult($product,$product_result){
|
386 |
+
|
387 |
+
$categoryCollection = $product->getCategoryCollection();
|
388 |
+
foreach($categoryCollection as $category){
|
389 |
+
$category_id[] = $category->getId();
|
390 |
+
}
|
391 |
|
|
|
392 |
if (empty($category_id)) {
|
393 |
$product_result['category_name'] = '';
|
394 |
$product_result['category_parent_name'] = '';
|
395 |
$product_result['category_path'] = '';
|
396 |
} else {
|
397 |
rsort($category_id);
|
|
|
398 |
$index = '';
|
399 |
foreach ($category_id as $key => $cate) {
|
400 |
+
|
401 |
+
/* $this $this->_storeCategories is created in loadCategories call on beginning of products() */
|
402 |
+
if (!in_array($cate, $this->_storeCategories)) {
|
403 |
continue;
|
404 |
}
|
405 |
|
406 |
+
/* $this $this->_storeCategories is created in loadCategories call on beginning of products(),
|
407 |
+
specifically nodeToArray function */
|
408 |
+
if (!array_key_exists($cate, $this->_categories)) {
|
409 |
+
continue;
|
410 |
+
}
|
411 |
+
|
412 |
+
$category = $this->_categories[$cate];
|
413 |
+
|
414 |
$product_result['category_name' . $index] = $category['name'];
|
|
|
415 |
|
416 |
+
/* @TODO: move these two to to property, doesn't make sense to read them everytime */
|
417 |
+
$storeRoot = Mage::app()->getStore($this->storeId)->getRootCategoryId();
|
418 |
+
$magentoRootCat = $this->_categories[$storeRoot]['parent_id'];
|
419 |
+
|
420 |
+
if(array_key_exists($category['parent_id'],$this->_categories)
|
421 |
+
&& $category['parent_id']!= $magentoRootCat
|
422 |
+
) {
|
423 |
+
$product_result['category_parent_name' . $index] = $this->_categories[$category['parent_id']]['name'];
|
424 |
+
}
|
425 |
+
|
426 |
+
$categoryPath = $this->buildCategoryPath($category['category_id']);
|
427 |
$product_result['category_path' . $index] = implode(' > ', $categoryPath);
|
428 |
+
|
429 |
if ($index == '') {
|
430 |
$index = 1;
|
431 |
} else {
|
438 |
|
439 |
}
|
440 |
|
441 |
+
public function addAdditionalImagesToResult($product, $product_result, $parent_product = null){
|
442 |
$additional_images = $product->getMediaGalleryImages();
|
443 |
+
if ($parent_product) {
|
444 |
+
$parent_additional_images = $parent_product->getMediaGalleryImages();
|
445 |
+
if (count($parent_additional_images) > 0) {
|
446 |
+
$i = 1;
|
447 |
+
foreach ($parent_additional_images as $images) {
|
448 |
+
if ($images->getUrl() != $product_result['image_url']) {
|
449 |
+
$product_result['additional_image_url' . $i++] = $images->getUrl();
|
450 |
+
}
|
451 |
+
}
|
452 |
+
}
|
453 |
+
}
|
454 |
+
|
455 |
if (count($additional_images) > 0) {
|
456 |
$i = 1;
|
457 |
foreach ($additional_images as $images) {
|
492 |
}
|
493 |
}
|
494 |
|
495 |
+
public function addPricesToResult($product,$prices,$parent_product){
|
496 |
|
497 |
$_taxHelper = Mage::helper('tax');
|
498 |
|
499 |
$this->prepareCurrencyRates();
|
500 |
|
501 |
+
$priceWithRules = $this->getPriceIncludingRules($product);
|
502 |
+
|
503 |
+
$prices['price'] = $_taxHelper->getPrice($product, $priceWithRules, NULL);
|
504 |
+
$prices['price_with_tax'] = $_finalPriceInclTax = $_taxHelper->getPrice($product, $priceWithRules, true);
|
505 |
+
|
506 |
+
$prices['special_price'] = null;
|
507 |
+
$prices['special_price_with_tax'] = null;
|
508 |
$specialTmpPrice = $product->getSpecialPrice();
|
509 |
|
510 |
+
if ($specialTmpPrice
|
511 |
+
/* @note: the special price range SHOULD NOT be checked when fetching special price */
|
512 |
+
/*&& (time() <= strtotime($product['special_to_date']) || empty($product['special_to_date']))
|
513 |
+
&& (time() >= strtotime($product['special_from_date']) || empty($product['special_from_date']))*/
|
514 |
) {
|
515 |
+
$prices['special_price'] = $_taxHelper->getPrice($product, $specialTmpPrice, NULL);
|
516 |
+
$prices['special_price_with_tax'] = $_taxHelper->getPrice($product, $prices['special_price'], true);
|
517 |
$prices['special_from_date'] = $product['special_from_date'];
|
518 |
$prices['special_to_date'] = $product['special_to_date'];
|
519 |
}
|
522 |
&& array_key_exists($this->_bas_curncy_code, $this->_currencyRates)
|
523 |
&& array_key_exists($this->_cur_curncy_code, $this->_currencyRates)
|
524 |
) {
|
525 |
+
if ($prices['special_price']
|
526 |
+
/* @note: the special price range SHOULD NOT be checked when fetching special price */
|
527 |
+
/*&& (time() <= strtotime($product['special_to_date']) || empty($product['special_to_date']))
|
528 |
+
&& (time() >= strtotime($product['special_from_date']) || empty($product['special_from_date']))*/
|
529 |
) {
|
530 |
$prices['special_price_with_tax'] = Mage::helper('directory')->currencyConvert($prices['special_price_with_tax'], $this->_bas_curncy_code, $this->_cur_curncy_code);
|
531 |
$prices['special_price'] = Mage::helper('directory')->currencyConvert($prices['special_price'], $this->_bas_curncy_code, $this->_cur_curncy_code);
|
534 |
$prices['price_with_tax'] = Mage::helper('directory')->currencyConvert($_finalPriceInclTax, $this->_bas_curncy_code, $this->_cur_curncy_code);
|
535 |
$prices['price'] = Mage::helper('directory')->currencyConvert($prices['price'], $this->_bas_curncy_code, $this->_cur_curncy_code);
|
536 |
}
|
537 |
+
|
538 |
+
// get simple product price with Super Attributes Prices Values
|
539 |
+
if ($product->getTypeId() == "simple") {
|
540 |
+
// which is child of some parent product
|
541 |
+
if (gettype($parent_product) == 'object' && $parent_product->getId()) {
|
542 |
+
if ($parent_product->getTypeInstance(true) instanceof Mage_Catalog_Model_Product_Type_Configurable) {
|
543 |
+
|
544 |
+
$parentPrice = $this->getPriceIncludingRules($parent_product);
|
545 |
+
$prices['parent_price'] = $_taxHelper->getPrice($parent_product,$parentPrice,null);
|
546 |
+
$prices['parent_price_with_tax'] = $_taxHelper->getPrice($parent_product, $parentPrice, true);
|
547 |
+
|
548 |
+
$prices['parent_special_price'] = $_taxHelper->getPrice($parent_product, $parent_product->getSpecialPrice(), null);
|
549 |
+
$prices['parent_special_price_with_tax'] = $_taxHelper->getPrice($parent_product, $parent_product->getSpecialPrice(), true);
|
550 |
+
|
551 |
+
$variantSpacPrice = $this->getVariantSpacPrice($product, $parent_product);
|
552 |
+
$prices['variant_spac_price'] = $_taxHelper->getPrice($parent_product, $variantSpacPrice, null);
|
553 |
+
$prices['variant_spac_price_with_tax'] = $_taxHelper->getPrice($parent_product, $variantSpacPrice, true);
|
554 |
+
|
555 |
+
} else {
|
556 |
+
// item has a parent because it extends Mage_Catalog_Model_Product_Type_Grouped
|
557 |
+
// it has no effect on price modifiers, however, so we ignore it
|
558 |
+
}
|
559 |
+
}
|
560 |
+
}
|
561 |
+
|
562 |
return $prices;
|
563 |
}
|
564 |
|
565 |
+
public function addImageToResult($product,$result){
|
566 |
$imageUrl = (string)$product->getMediaConfig()->getMediaUrl($product->getData('image'));
|
567 |
$imageTmpArr = explode('.', $imageUrl);
|
568 |
$countImgArr = count($imageTmpArr);
|
569 |
if (empty($imageUrl) || $imageUrl == '' || !isset($imageUrl) || $countImgArr < 2) {
|
570 |
$imageUrl = (string)Mage::helper('catalog/image')->init($product, 'image');
|
571 |
}
|
572 |
+
$result['image_url'] = $imageUrl;
|
573 |
|
574 |
+
return $result;
|
575 |
}
|
576 |
|
577 |
+
public function addStockInfoToResult($product,$product_result,$parent_product=null){
|
578 |
+
|
579 |
+
$parentInStock = null;
|
580 |
+
|
581 |
+
if($parent_product){
|
582 |
+
$parentInventoryStatus = Mage::getModel('cataloginventory/stock_item')->loadByProduct($parent_product);
|
583 |
+
$parentInStock = ($parentInventoryStatus->getIsInStock() == '1') ? 1 : 0;
|
584 |
+
}
|
585 |
+
|
586 |
$inventoryStatus = Mage::getModel('cataloginventory/stock_item')->loadByProduct($product);
|
587 |
if (!empty($inventoryStatus)) {
|
588 |
$product_result['quantity'] = (int)$inventoryStatus->getQty();
|
589 |
$product_result['is_in_stock'] = $inventoryStatus->getIsInStock() == '1' ? 1 : 0;
|
590 |
}
|
591 |
+
|
592 |
+
/*NVI variants should inherit is_in_stock ==0 from parent only when it is 0*/
|
593 |
+
if($parentInStock == 0 && $product->getVisibility() == Mage_Catalog_Model_Product_Visibility::VISIBILITY_NOT_VISIBLE) {
|
594 |
+
$product_result['is_in_stock'] = 0;
|
595 |
+
}
|
596 |
+
|
597 |
return $product_result;
|
598 |
}
|
599 |
|
609 |
return $rewrite->getRequestPath();
|
610 |
}
|
611 |
|
612 |
+
public function setStoreId($storeId){
|
613 |
+
$this->storeId = $storeId;
|
614 |
+
}
|
615 |
+
|
616 |
+
public function prepareCollection($options,$applyFilters = true){
|
617 |
+
|
618 |
+
unset($options['page']);
|
619 |
+
unset($options['per_page']);
|
620 |
+
|
621 |
+
/* determine store for collection */
|
622 |
+
if (array_key_exists('store', $options)) {
|
623 |
+
//convert store code to store id
|
624 |
+
if (!is_numeric($options['store'])) {
|
625 |
+
$options['store'] = Mage::app()->getStore($options['store'])->getId();
|
626 |
+
}
|
627 |
+
|
628 |
+
if ($options['store']) {
|
629 |
+
$this->storeId = $options['store'];
|
630 |
+
$this->setStoreId($this->storeId);
|
631 |
+
Mage::app()->setCurrentStore($this->storeId);
|
632 |
+
}
|
633 |
+
}
|
634 |
+
|
635 |
+
/* Check if the store has ignore_datafeedwatch_attribute and collection should apply it */
|
636 |
+
$attributeModel = Mage::getModel('eav/entity_attribute');
|
637 |
+
$attributeId = $attributeModel->getIdByCode('catalog_product', 'ignore_datafeedwatch');
|
638 |
+
|
639 |
+
if ($attributeId > 0) {
|
640 |
+
$collection = Mage::getModel('catalog/product')->getCollection()
|
641 |
+
->addAttributeToFilter(array(
|
642 |
+
array('attribute'=>'ignore_datafeedwatch', 'neq'=> 1),
|
643 |
+
array('attribute'=>'ignore_datafeedwatch', 'null'=> true),
|
644 |
+
),
|
645 |
+
'',
|
646 |
+
'left'
|
647 |
+
)
|
648 |
+
;
|
649 |
+
} else {
|
650 |
+
$collection = Mage::getModel('catalog/product')->getCollection();
|
651 |
+
}
|
652 |
+
|
653 |
+
$collection->addStoreFilter($this->storeId);
|
654 |
+
if(isset($options['type']) && $options['type']) {
|
655 |
+
$collection->addAttributeToFilter('type_id', array('in' => array($options['type'])));
|
656 |
+
unset($options['type']);
|
657 |
+
}
|
658 |
+
|
659 |
+
$apiHelper = Mage::helper('api');
|
660 |
+
|
661 |
+
if (method_exists($apiHelper, 'parseFilters')) {
|
662 |
+
$filters = $apiHelper->parseFilters($options, $this->_filtersMap);
|
663 |
+
} else {
|
664 |
+
/* added to support older releases without parseFilters */
|
665 |
+
$filters = $this->parseFiltersReplacement($options, $this->_filtersMap);
|
666 |
+
}
|
667 |
+
|
668 |
+
try {
|
669 |
+
//ignore status and store when flat catalog is enabled
|
670 |
+
if (Mage::helper('catalog/product_flat')->isEnabled()){
|
671 |
+
$fieldsToIgnore = array('store','status');
|
672 |
+
foreach($fieldsToIgnore as $field){
|
673 |
+
unset($filters[$field]);
|
674 |
+
}
|
675 |
+
}
|
676 |
+
|
677 |
+
foreach ($filters as $field => $value) {
|
678 |
+
if($field =='store') {
|
679 |
+
$collection->setStoreId($this->storeId);
|
680 |
+
} else {
|
681 |
+
$collection->addFieldToFilter($field, $value);
|
682 |
+
}
|
683 |
+
}
|
684 |
+
} catch (Mage_Core_Exception $e) {
|
685 |
+
throw new Exception('filters_invalid', $e->getCode(), $e);
|
686 |
+
}
|
687 |
+
|
688 |
+
return $collection;
|
689 |
+
}
|
690 |
+
|
691 |
+
/**
|
692 |
+
* Returns price key for given product
|
693 |
+
* @param $product Mage_Catalog_Model_Product
|
694 |
+
* @return float|null
|
695 |
+
*/
|
696 |
+
public function getPriceIncludingRules($product){
|
697 |
+
$finalPrice = Mage::getModel('catalogrule/rule')->calcProductPriceRule($product,$product->getPrice());
|
698 |
+
if($finalPrice){
|
699 |
+
return $finalPrice;
|
700 |
+
}
|
701 |
+
return $product->getPrice();
|
702 |
+
}
|
703 |
+
|
704 |
+
public function formatPrices($product,$product_result){
|
705 |
+
if ( $product->getTypeId() == "simple" ) {
|
706 |
+
$priceKeys = array(
|
707 |
+
'price',
|
708 |
+
'price_with_tax',
|
709 |
+
'special_price',
|
710 |
+
'special_price_with_tax',
|
711 |
+
'parent_price',
|
712 |
+
'parent_price_with_tax',
|
713 |
+
'parent_special_price',
|
714 |
+
'parent_special_price_with_tax',
|
715 |
+
'variant_spac_price',
|
716 |
+
'variant_spac_price_with_tax'
|
717 |
+
);
|
718 |
+
|
719 |
+
} else {
|
720 |
+
$priceKeys = array(
|
721 |
+
'price',
|
722 |
+
'price_with_tax',
|
723 |
+
'special_price',
|
724 |
+
'special_price_with_tax',
|
725 |
+
);
|
726 |
+
}
|
727 |
+
|
728 |
+
//format each price
|
729 |
+
foreach($priceKeys as $key){
|
730 |
+
if(array_key_exists($key,$product_result)) {
|
731 |
+
$value = $product_result[$key];
|
732 |
+
if(is_string($value)){
|
733 |
+
$value = trim($product_result[$key]);
|
734 |
+
}
|
735 |
+
$product_result[$key] = sprintf("%.2f", round($value, 2));
|
736 |
+
}
|
737 |
+
}
|
738 |
+
|
739 |
+
//nullify special prices if price == 0
|
740 |
+
if($product_result['special_price'] <= 0) {
|
741 |
+
$product_result['special_price'] = null;
|
742 |
+
$product_result['special_price_with_tax'] = null;
|
743 |
+
}
|
744 |
+
|
745 |
+
if(array_key_exists('parent_special_price',$product_result) && $product_result['parent_special_price'] <= 0) {
|
746 |
+
$product_result['parent_special_price'] = null;
|
747 |
+
$product_result['parent_special_price_with_tax'] = null;
|
748 |
+
}
|
749 |
+
|
750 |
+
//nullify tax prices if tax class is "None" for product,
|
751 |
+
//but do not touch parent price fields!
|
752 |
+
if($product->getTaxClassId()==0){
|
753 |
+
foreach($priceKeys as $key) {
|
754 |
+
if (!stristr($key,'variant_') && !stristr($key,'parent_') && array_key_exists($key, $product_result) && stristr($key, '_with_tax')) {
|
755 |
+
$product_result[$key] = $product_result[str_replace('_with_tax','',$key)];
|
756 |
+
}
|
757 |
+
}
|
758 |
+
}
|
759 |
+
return $product_result;
|
760 |
+
}
|
761 |
+
|
762 |
+
/**
|
763 |
+
* @param $product
|
764 |
+
* @param $parent_product
|
765 |
+
* @param $attributes
|
766 |
+
* @return mixed
|
767 |
+
*/
|
768 |
+
public function getVariantSpacPrice($product,$parent_product){
|
769 |
+
|
770 |
+
// get all configurable attributes
|
771 |
+
if ($parent_product) {
|
772 |
+
$attributes = $parent_product->getTypeInstance(true)->getConfigurableAttributes($parent_product);
|
773 |
+
}
|
774 |
+
|
775 |
+
// array to keep the price differences for each attribute value
|
776 |
+
$pricesByAttributeValues = array();
|
777 |
+
// base price of the configurable product
|
778 |
+
$basePrice = $parent_product->getFinalPrice();
|
779 |
+
// loop through the attributes and get the price adjustments specified in the configurable product admin page
|
780 |
+
foreach ($attributes as $attribute) {
|
781 |
+
$prices = $attribute->getPrices();
|
782 |
+
foreach ($prices as $price) {
|
783 |
+
if ($price['is_percent']) {
|
784 |
+
$pricesByAttributeValues[$price['value_index']] = (float)$price['pricing_value'] * $basePrice / 100;
|
785 |
+
} else {
|
786 |
+
$pricesByAttributeValues[$price['value_index']] = (float)$price['pricing_value'];
|
787 |
+
}
|
788 |
+
}
|
789 |
+
}
|
790 |
+
|
791 |
+
$totalPrice = $basePrice;
|
792 |
+
// loop through the configurable attributes
|
793 |
+
foreach ($attributes as $attribute) {
|
794 |
+
// get the value for a specific attribute for a simple product
|
795 |
+
$value = $product->getData($attribute->getProductAttribute()->getAttributeCode());
|
796 |
+
// add the price adjustment to the total price of the simple product
|
797 |
+
if (isset($pricesByAttributeValues[$value])) {
|
798 |
+
$totalPrice += $pricesByAttributeValues[$value];
|
799 |
+
}
|
800 |
+
}
|
801 |
+
|
802 |
+
return $totalPrice;
|
803 |
+
}
|
804 |
+
|
805 |
+
public function shouldSkipProduct($product,$parent_product){
|
806 |
+
if(is_object($parent_product) && $parent_product->getStatus() == Mage_Catalog_Model_Product_Status::STATUS_DISABLED
|
807 |
+
&& $product->getVisibility() == Mage_Catalog_Model_Product_Visibility::VISIBILITY_NOT_VISIBLE){
|
808 |
+
return true;
|
809 |
+
}
|
810 |
+
return false;
|
811 |
+
}
|
812 |
+
|
813 |
+
public function addDefaultVariantFlag($product,$parent_product, $product_result){
|
814 |
+
|
815 |
+
$attributes = $parent_product->getTypeInstance(true)->getConfigurableAttributesAsArray($parent_product);
|
816 |
+
|
817 |
+
$product_result['dfw_default_variant'] = 1;
|
818 |
+
|
819 |
+
foreach ($attributes as $productAttribute) {
|
820 |
+
|
821 |
+
if(!array_key_exists($productAttribute['attribute_id'],$this->_attributeDefaultValues)) {
|
822 |
+
$attribute = Mage::getModel('catalog/resource_eav_attribute')->load($productAttribute['attribute_id']);
|
823 |
+
$this->_attributeDefaultValues[$productAttribute['attribute_id']] = $attribute->getData('default_value');
|
824 |
+
}
|
825 |
+
|
826 |
+
//reset to 0 if any attribute doesn't have default value
|
827 |
+
$currentValue = $product->getData($productAttribute['attribute_code']);
|
828 |
+
if($currentValue != $this->_attributeDefaultValues[$productAttribute['attribute_id']]){
|
829 |
+
$product_result['dfw_default_variant'] = 0;
|
830 |
+
|
831 |
+
//return. we already have our result, we don't have to iterate over others
|
832 |
+
return $product_result;
|
833 |
+
}
|
834 |
+
}
|
835 |
+
|
836 |
+
//none "not default" found and value still == 1
|
837 |
+
return $product_result;
|
838 |
+
}
|
839 |
+
|
840 |
+
public function getParentProductFromChild($product){
|
841 |
+
|
842 |
+
$dataFeedWatchHelper = Mage::helper('connector');
|
843 |
+
|
844 |
+
if ($product->getTypeId() == "simple") {
|
845 |
+
|
846 |
+
/* check if the product is grouped */
|
847 |
+
$parentIds = Mage::getModel('catalog/product_type_grouped')->getParentIdsByChild($product->getId());
|
848 |
+
|
849 |
+
/* if not grouped, check if configurable */
|
850 |
+
if (!$parentIds) {
|
851 |
+
$parentIds = Mage::getModel('catalog/product_type_configurable')->getParentIdsByChild($product->getId());
|
852 |
+
}
|
853 |
+
|
854 |
+
/* if at least one parent has been found in child details */
|
855 |
+
if (isset($parentIds[0])) {
|
856 |
+
|
857 |
+
$parent_product = Mage::getModel('catalog/product')->setStoreId($dataFeedWatchHelper->storeId)->load($parentIds[0]);
|
858 |
+
/* @var $parent_product Mage_Catalog_Model_Product_Type_Configurable */
|
859 |
+
|
860 |
+
while (!$parent_product->getId()) {
|
861 |
+
if (count($parentIds) > 1) {
|
862 |
+
//parent not found, remove and retry with next one
|
863 |
+
array_shift($parentIds);
|
864 |
+
$parent_product = Mage::getModel('catalog/product')->load($parentIds[0]);
|
865 |
+
} else {
|
866 |
+
break;
|
867 |
+
}
|
868 |
+
}
|
869 |
+
return $parent_product;
|
870 |
+
}
|
871 |
+
return null;
|
872 |
+
} else {
|
873 |
+
return null;
|
874 |
+
}
|
875 |
+
}
|
876 |
+
|
877 |
+
public function getFullUrl (Mage_Catalog_Model_Product $product ,
|
878 |
+
Mage_Catalog_Model_Category $category = null ,
|
879 |
+
$mustBeIncludedInNavigation = true ){
|
880 |
+
|
881 |
+
$storeId = Mage::getModel('core/store')->load('en', 'code')->getId(); //the store you need the base url:
|
882 |
+
$homeUrl = Mage::getUrl('', array('_store' => $storeId));
|
883 |
+
|
884 |
+
// Try to find url matching provided category
|
885 |
+
if( $category != null){
|
886 |
+
// Category is no match then we'll try to find some other category later
|
887 |
+
if( !in_array($product->getId() , $category->getProductCollection()->getAllIds() )
|
888 |
+
|| !self::isCategoryAcceptable($category , $mustBeIncludedInNavigation )){
|
889 |
+
$category = null;
|
890 |
+
}
|
891 |
+
}
|
892 |
+
if ($category == null) {
|
893 |
+
if( is_null($product->getCategoryIds() )){
|
894 |
+
return $product->getProductUrl();
|
895 |
+
}
|
896 |
+
$catCount = 0;
|
897 |
+
$productCategories = $product->getCategoryIds();
|
898 |
+
// Go through all product's categories
|
899 |
+
while( $catCount < count($productCategories) && $category == null ) {
|
900 |
+
$tmpCategory = Mage::getModel('catalog/category')->load($productCategories[$catCount]);
|
901 |
+
// See if category fits (active, url key, included in menu)
|
902 |
+
if ( !self::isCategoryAcceptable($tmpCategory , $mustBeIncludedInNavigation ) ) {
|
903 |
+
$catCount++;
|
904 |
+
}else{
|
905 |
+
$category = Mage::getModel('catalog/category')->load($productCategories[$catCount]);
|
906 |
+
}
|
907 |
+
}
|
908 |
+
}
|
909 |
+
if($category && !is_null( $product->getUrlPath($category))) {
|
910 |
+
$url = $homeUrl . str_replace('.html', '/', $category->getUrlPath()) . $product->getData('url_key') . '.html';
|
911 |
+
} else {
|
912 |
+
$url = $product->getProductUrl();
|
913 |
+
|
914 |
+
}
|
915 |
+
//$url = (!is_null( $product->getUrlPath($category))) ? $homeUrl . $product->getUrlPath($category) : $product->getProductUrl();
|
916 |
+
|
917 |
+
return $url;
|
918 |
+
}
|
919 |
+
|
920 |
+
/**
|
921 |
+
* Checks if a category matches criteria: active && url_key not null && included in menu if it has to
|
922 |
+
*/
|
923 |
+
protected function isCategoryAcceptable(Mage_Catalog_Model_Category $category = null, $mustBeIncludedInNavigation = true){
|
924 |
+
if( !$category->getIsActive() || is_null( $category->getUrlKey() )
|
925 |
+
|| ( $mustBeIncludedInNavigation && !$category->getIncludeInMenu()) ){
|
926 |
+
return false;
|
927 |
+
}
|
928 |
+
return true;
|
929 |
+
}
|
930 |
+
|
931 |
+
public function getUpdatedProductList($options){
|
932 |
+
$mageObject = new Mage;
|
933 |
+
$dataFeedWatchHelper = $this;
|
934 |
+
/* @var $dataFeedWatchHelper DataFeedWatch_Connector_Helper_Data */
|
935 |
+
|
936 |
+
$fetchList = array();
|
937 |
+
|
938 |
+
if (!isset($options['updated_at'])){
|
939 |
+
return 'No updated_at option given! Please provide datetime in following format: 2015-03-25 23:34:59';
|
940 |
+
}
|
941 |
+
|
942 |
+
$updatedAt = $options['updated_at'];
|
943 |
+
$updatedAt = date("Y-m-d H:i:s",strtotime($updatedAt));
|
944 |
+
|
945 |
+
/*remove updated at filter, we do not want to use it on normal call*/
|
946 |
+
unset($options['updated_at']);
|
947 |
+
|
948 |
+
$this->_versionInfo = Mage::getVersionInfo();
|
949 |
+
|
950 |
+
/* If we have Enterprise Edition, make sure our current Enterprise is supported */
|
951 |
+
if (method_exists($mageObject, 'getEdition')
|
952 |
+
&& Mage::getEdition() == Mage::EDITION_ENTERPRISE
|
953 |
+
&& version_compare(implode('.',$this->_versionInfo),implode('.',$this->_supportedEnterprise),'>=')) {
|
954 |
+
$this->_isSupportedEnterprise = true;
|
955 |
+
$dataFeedWatchHelper->isSupportedEnterprise = true;
|
956 |
+
}
|
957 |
+
|
958 |
+
/* Use default page if not set */
|
959 |
+
if (!array_key_exists('page', $options)) {
|
960 |
+
$options['page'] = 0;
|
961 |
+
}
|
962 |
+
|
963 |
+
/* Use default limit if not set */
|
964 |
+
if (!array_key_exists('per_page', $options)) {
|
965 |
+
$options['per_page'] = 100;
|
966 |
+
}
|
967 |
+
|
968 |
+
/* Get Product Collection by updated_at field */
|
969 |
+
$collection = $dataFeedWatchHelper->prepareCollection($options);
|
970 |
+
$collection->addFieldToFilter('updated_at',array('gteq' => $updatedAt));
|
971 |
+
|
972 |
+
foreach($collection as $product){
|
973 |
+
$fetchList[]=$product->getId();
|
974 |
+
|
975 |
+
|
976 |
+
/* add configurable children to fetchlist */
|
977 |
+
if ($product->getTypeId() == "configurable") {
|
978 |
+
$product = Mage::getModel('catalog/product')->load($product->getId());
|
979 |
+
$childProducts = Mage::getModel('catalog/product_type_configurable')
|
980 |
+
->getUsedProducts(null, $product);
|
981 |
+
if ($childProducts) {
|
982 |
+
foreach ($childProducts as $child) {
|
983 |
+
$fetchList[] = $child->getId();
|
984 |
+
}
|
985 |
+
}
|
986 |
+
}
|
987 |
+
}
|
988 |
+
|
989 |
+
/* Catalog price rules */
|
990 |
+
/* @TODO: move to our catalogrule model, should return $promotionAffectedProducts array */
|
991 |
+
$promotionAffectedProducts = array();
|
992 |
+
$catalogRuleDates = Mage::getModel('connector/catalogrule_info')->getCollection();
|
993 |
+
$catalogRuleDates->addFieldToFilter('updated_at',array('gteq' => $updatedAt));
|
994 |
+
if($catalogRuleDates) {
|
995 |
+
foreach ($catalogRuleDates as $info) {
|
996 |
+
$rule = Mage::getModel('catalogrule/rule')->load($info->getCatalogruleId());
|
997 |
+
$productIds = $rule->getMatchingProductIds();
|
998 |
+
foreach ($productIds as $productId => $ifApplicable) {
|
999 |
+
$uniqueValues = array_values(array_unique($ifApplicable));
|
1000 |
+
if (count($uniqueValues) == 1 && $uniqueValues[0] == 1) {
|
1001 |
+
$promotionAffectedProducts[] = (int)$productId;
|
1002 |
+
}
|
1003 |
+
}
|
1004 |
+
}
|
1005 |
+
}
|
1006 |
+
|
1007 |
+
/* Checkout price rules */
|
1008 |
+
/* @TODO: move to our salesrule model, should return $promotionAffectedProducts array */
|
1009 |
+
$saleRuleDates = Mage::getModel('connector/salesrule_info')->getCollection();
|
1010 |
+
$saleRuleDates->addFieldToFilter('updated_at',array('gteq' => $updatedAt));
|
1011 |
+
|
1012 |
+
if($saleRuleDates) {
|
1013 |
+
foreach ($saleRuleDates as $info) {
|
1014 |
+
$rule = Mage::getModel('catalogrule/rule')->load($info->getSalesruleId());
|
1015 |
+
$productIds = $rule->getMatchingProductIds();
|
1016 |
+
foreach ($productIds as $productId => $ifApplicable) {
|
1017 |
+
$uniqueValues = array_values(array_unique($ifApplicable));
|
1018 |
+
if (count($uniqueValues) == 1 && $uniqueValues[0] == 1) {
|
1019 |
+
$promotionAffectedProducts[] = (int)$productId;
|
1020 |
+
}
|
1021 |
+
}
|
1022 |
+
}
|
1023 |
+
}
|
1024 |
+
|
1025 |
+
if(count($promotionAffectedProducts)>0) {
|
1026 |
+
$promotionAffectedProducts = array_values(array_unique($promotionAffectedProducts));
|
1027 |
+
foreach ($promotionAffectedProducts as $productId) {
|
1028 |
+
/* Add to fetchlist */
|
1029 |
+
$fetchList[] = (int)$productId;
|
1030 |
+
|
1031 |
+
/* Foreach promoted products, make sure that also children are fetched. */
|
1032 |
+
$product = Mage::getModel('catalog/product')->load($productId);
|
1033 |
+
if ($product->getTypeId() == "configurable") {
|
1034 |
+
$childProducts = Mage::getModel('catalog/product_type_configurable')
|
1035 |
+
->getUsedProducts(null, $product);
|
1036 |
+
if ($childProducts) {
|
1037 |
+
foreach ($childProducts as $child) {
|
1038 |
+
$fetchList[] = $child->getId();
|
1039 |
+
}
|
1040 |
+
}
|
1041 |
+
}
|
1042 |
+
}
|
1043 |
+
}
|
1044 |
+
|
1045 |
+
return $fetchList;
|
1046 |
+
}
|
1047 |
|
1048 |
}
|
1049 |
|
app/code/community/DataFeedWatch/Connector/Model/Catalogrule/Info.php
ADDED
@@ -0,0 +1,8 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
|
3 |
+
class DataFeedWatch_Connector_Model_Catalogrule_Info extends Mage_Core_Model_Abstract {
|
4 |
+
|
5 |
+
public function _construct(){
|
6 |
+
$this->_init('connector/catalogrule_info','catalogruleinfo_id');
|
7 |
+
}
|
8 |
+
}
|
app/code/community/DataFeedWatch/Connector/Model/Catalogrule/Info/Collection.php
ADDED
@@ -0,0 +1,8 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
|
3 |
+
class DataFeedWatch_Connector_Model_Resource_Catalogrule_Info_Collection extends Mage_Core_Model_Resource_Db_Collection_Abstract {
|
4 |
+
protected function _construct()
|
5 |
+
{
|
6 |
+
$this->_init('connector/catalogrule_info');
|
7 |
+
}
|
8 |
+
}
|
app/code/community/DataFeedWatch/Connector/Model/Datafeedwatch/Api.php
CHANGED
@@ -5,14 +5,16 @@ class DataFeedWatch_Connector_Model_Datafeedwatch_Api extends Mage_Catalog_Model
|
|
5 |
// category
|
6 |
const CATEGORY_NAME_FIELD = 'name';
|
7 |
const CATEGORY_SEPARATOR = ' > ';
|
8 |
-
public $categories = array();
|
9 |
|
10 |
-
public $storeId = 0;
|
11 |
public $storeRootCategoryId = 2;
|
|
|
|
|
12 |
public $storeCategories = array();
|
13 |
|
|
|
|
|
14 |
/* has been tested with this EE version and works completely */
|
15 |
-
|
16 |
'major' => '1',
|
17 |
'minor' => '13',
|
18 |
'revision' => '0',
|
@@ -20,20 +22,27 @@ class DataFeedWatch_Connector_Model_Datafeedwatch_Api extends Mage_Catalog_Model
|
|
20 |
'stability' => '',
|
21 |
'number' => '',
|
22 |
);
|
|
|
|
|
23 |
|
24 |
public function __construct()
|
25 |
{
|
26 |
-
$this->productCategories = array();
|
27 |
ini_set('memory_limit', '1024M');
|
28 |
}
|
29 |
|
30 |
-
|
|
|
|
|
31 |
public function stores()
|
32 |
{
|
|
|
33 |
foreach (Mage::app()->getWebsites() as $website) {
|
|
|
34 |
foreach ($website->getGroups() as $group) {
|
|
|
35 |
$stores = $group->getStores();
|
36 |
foreach ($stores as $store) {
|
|
|
37 |
$returned[$store->getCode()] = array(
|
38 |
'Website' => $website->getName(),
|
39 |
'Store' => $group->getName(),
|
@@ -45,137 +54,188 @@ class DataFeedWatch_Connector_Model_Datafeedwatch_Api extends Mage_Catalog_Model
|
|
45 |
return $returned;
|
46 |
}
|
47 |
|
48 |
-
|
|
|
|
|
|
|
|
|
49 |
public function product_ids($options = array())
|
50 |
{
|
|
|
|
|
|
|
51 |
if (!array_key_exists('page', $options)) {
|
52 |
-
$options['page'] =
|
53 |
}
|
54 |
|
55 |
if (!array_key_exists('per_page', $options)) {
|
56 |
$options['per_page'] = 100;
|
57 |
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
58 |
|
59 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
60 |
|
61 |
-
return
|
62 |
}
|
63 |
|
64 |
-
|
|
|
|
|
65 |
public function version()
|
66 |
{
|
67 |
return (string)Mage::getConfig()->getNode('modules/DataFeedWatch_Connector')->version;
|
68 |
}
|
69 |
|
70 |
-
|
|
|
|
|
|
|
|
|
71 |
public function product_count($options = array())
|
72 |
{
|
|
|
|
|
|
|
|
|
73 |
|
74 |
-
$collection
|
75 |
-
|
76 |
-
$apiHelper = Mage::helper('api');
|
77 |
-
if (method_exists($apiHelper, 'parseFilters')) {
|
78 |
-
$filters = $apiHelper->parseFilters($options, $this->_filtersMap);
|
79 |
-
} else {
|
80 |
-
/* added to support older releases without parseFilters */
|
81 |
-
$dataFeedWatchHelper = Mage::helper('connector');
|
82 |
-
$filters = $dataFeedWatchHelper->parseFiltersReplacement($options, $this->_filtersMap);
|
83 |
-
}
|
84 |
|
85 |
-
|
86 |
-
|
87 |
-
|
88 |
-
|
89 |
-
|
90 |
-
|
91 |
-
|
92 |
-
//ignore fields when flat catalog is not enabled
|
93 |
-
if (in_array($field, $fieldToIgnore) && !Mage::helper('catalog/product_flat')->isEnabled()) {
|
94 |
-
continue;
|
95 |
}
|
96 |
|
97 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
98 |
}
|
99 |
-
} catch (Mage_Core_Exception $e) {
|
100 |
-
$this->_fault('filters_invalid', $e->getMessage());
|
101 |
}
|
102 |
|
|
|
|
|
|
|
103 |
$numberOfProducts = 0;
|
104 |
if (!empty($collection)) {
|
105 |
$numberOfProducts = $collection->getSize();
|
106 |
}
|
|
|
107 |
|
108 |
-
return
|
109 |
}
|
110 |
|
111 |
-
|
112 |
-
|
|
|
|
|
|
|
|
|
113 |
{
|
114 |
$mageObject = new Mage;
|
|
|
|
|
|
|
115 |
$this->_versionInfo = Mage::getVersionInfo();
|
116 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
117 |
if (!array_key_exists('page', $options)) {
|
118 |
-
$options['page'] =
|
119 |
}
|
120 |
|
|
|
121 |
if (!array_key_exists('per_page', $options)) {
|
122 |
$options['per_page'] = 100;
|
123 |
}
|
124 |
|
125 |
-
|
|
|
126 |
|
127 |
-
|
128 |
-
|
129 |
-
->setPage($options['page'], $options['per_page']);
|
130 |
|
131 |
-
|
132 |
-
|
133 |
-
unset($options['per_page']);
|
134 |
unset($options['store']);
|
135 |
|
|
|
|
|
|
|
|
|
136 |
|
137 |
/* set current store manually so we get specific store url returned in getBaseUrl */
|
138 |
-
$this->storeRootCategoryId = Mage::app()->getStore($
|
139 |
-
$storeCategoriesCollection = Mage::getResourceModel('catalog/category_collection');
|
140 |
-
$storeCategoriesCollection->addAttributeToSelect('name')
|
141 |
-
->addAttributeToSelect('is_active')
|
142 |
-
->addPathsFilter('%/' . $this->storeRootCategoryId);
|
143 |
|
144 |
$baseUrl = Mage::getBaseUrl(Mage_Core_Model_Store::URL_TYPE_WEB);
|
145 |
|
146 |
-
|
147 |
-
|
148 |
-
}
|
149 |
-
|
150 |
-
/*@TODO: check if we still use this, or we can rely on storeCategories*/
|
151 |
-
Mage::helper('connector')->loadCategories();
|
152 |
-
$this->categories = Mage::helper('connector')->getCategories();
|
153 |
-
$this->productCategories = Mage::helper('connector')->getProductCategories();
|
154 |
-
|
155 |
-
/** @var $apiHelper Mage_Api_Helper_Data */
|
156 |
-
$apiHelper = Mage::helper('api');
|
157 |
-
if (method_exists($apiHelper, 'parseFilters')) {
|
158 |
-
$filters = $apiHelper->parseFilters($options, $this->_filtersMap);
|
159 |
-
} else {
|
160 |
-
$dataFeedWatchHelper = Mage::helper('connector');
|
161 |
-
$filters = $dataFeedWatchHelper->parseFiltersReplacement($options, $this->_filtersMap);
|
162 |
-
}
|
163 |
-
|
164 |
-
|
165 |
-
try {
|
166 |
-
foreach ($filters as $field => $value) {
|
167 |
-
//ignore status when flat catalog is enabled, as flat catalog does not have status
|
168 |
-
if ($field == 'status' && Mage::helper('catalog/product_flat')->isEnabled()) {
|
169 |
-
continue;
|
170 |
-
}
|
171 |
-
$collection->addFieldToFilter($field, $value);
|
172 |
-
}
|
173 |
-
} catch (Mage_Core_Exception $e) {
|
174 |
-
$this->_fault('filters_invalid', $e->getMessage());
|
175 |
-
}
|
176 |
|
177 |
$result = array();
|
178 |
-
$price_keys = array('price', 'special_price');
|
179 |
|
180 |
foreach ($collection as $product) {
|
181 |
|
@@ -183,110 +243,116 @@ class DataFeedWatch_Connector_Model_Datafeedwatch_Api extends Mage_Catalog_Model
|
|
183 |
$parent_id = null;
|
184 |
$parent_sku = null;
|
185 |
$parent_url = null;
|
186 |
-
$
|
187 |
|
188 |
-
|
189 |
-
|
|
|
190 |
} else {
|
191 |
$product = Mage::getModel('catalog/product')->load($product->getId());
|
192 |
}
|
|
|
193 |
|
194 |
-
$product_result = array(
|
|
|
195 |
'product_id' => $product->getId(),
|
196 |
'sku' => $product->getSku(),
|
197 |
'product_type' => $product->getTypeId()
|
198 |
);
|
199 |
|
|
|
|
|
200 |
$selected_attributes = $this->synced_fields();
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
201 |
foreach ($product->getAttributes() as $attribute) {
|
202 |
|
203 |
/* ignore excluded attributes */
|
204 |
-
if(array_key_exists($attribute->getAttributeCode(),
|
205 |
continue;
|
206 |
}
|
207 |
|
208 |
/* only use user-selected fields from DataFeedWatch -> Settings + required attributes */
|
209 |
-
if (in_array($attribute->getAttributeCode(),
|
210 |
$value = $product->getData($attribute->getAttributeCode());
|
211 |
if (!empty($value)) {
|
212 |
-
|
213 |
-
|
214 |
-
|
215 |
-
$value = trim($attribute->getFrontend()->getValue($product));
|
216 |
}
|
217 |
}
|
218 |
$product_result[$attribute->getAttributeCode()] = $value;
|
219 |
} else {
|
220 |
-
|
|
|
221 |
}
|
222 |
}
|
223 |
|
224 |
-
/* get product main image file */
|
225 |
-
$imageUrl = (string)$product->getMediaConfig()->getMediaUrl($product->getData('image'));
|
226 |
-
$imageTmpArr = explode('.', $imageUrl);
|
227 |
-
$countImgArr = count($imageTmpArr);
|
228 |
-
if (empty($imageUrl) || $imageUrl == '' || !isset($imageUrl) || $countImgArr < 2) {
|
229 |
-
$imageUrl = (string)Mage::helper('catalog/image')->init($product, 'image');
|
230 |
-
}
|
231 |
-
$product_result['image_url'] = $imageUrl;
|
232 |
-
|
233 |
/* get product Url */
|
234 |
-
if (
|
235 |
$product_result['product_url'] = $product->getProductUrl();
|
236 |
} else {
|
237 |
-
$product_result['product_url_rewritten'] = $baseUrl .
|
238 |
$product_result['product_url'] = $baseUrl . $product->getUrlPath();
|
239 |
}
|
240 |
|
241 |
-
|
242 |
-
|
243 |
-
|
244 |
-
|
245 |
-
|
246 |
-
|
247 |
-
|
248 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
249 |
}
|
|
|
250 |
|
251 |
-
if (isset($parentIds[0])) {
|
252 |
-
$parent_product = Mage::getModel('catalog/product')->load($parentIds[0]);
|
253 |
-
while (!$parent_product->getId()) {
|
254 |
-
if (count($parentIds) > 1) {
|
255 |
-
//parent not found, remove and retry with next one
|
256 |
-
array_shift($parentIds);
|
257 |
-
$parent_product = Mage::getModel('catalog/product')->load($parentIds[0]);
|
258 |
-
} else {
|
259 |
-
break;
|
260 |
-
}
|
261 |
-
}
|
262 |
|
263 |
-
|
264 |
-
|
265 |
-
|
266 |
-
|
267 |
-
|
268 |
-
|
269 |
-
|
270 |
-
|
271 |
-
|
272 |
-
|
273 |
-
|
274 |
-
|
275 |
-
|
276 |
-
|
277 |
-
|
278 |
-
|
279 |
-
|
280 |
|
|
|
|
|
|
|
|
|
|
|
|
|
281 |
}
|
282 |
}
|
283 |
|
284 |
-
|
285 |
-
$
|
286 |
-
|
287 |
-
|
288 |
-
//rewrite to prepare array of fields to overwrite with parent values
|
289 |
-
$productAttributes = Mage::helper('connector')->getProductAttributes($parent_product);
|
290 |
|
291 |
// get child product visibility
|
292 |
$visibilityStatuses = Mage_Catalog_Model_Product_Visibility::getOptionArray();
|
@@ -296,99 +362,102 @@ class DataFeedWatch_Connector_Model_Datafeedwatch_Api extends Mage_Catalog_Model
|
|
296 |
$productAttributes['visibility'] = null;
|
297 |
}
|
298 |
} else {
|
299 |
-
$productAttributes =
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
300 |
}
|
|
|
|
|
|
|
301 |
|
302 |
-
|
303 |
-
if
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
304 |
foreach ($productAttributes as $key => $value) {
|
305 |
-
|
306 |
-
|
307 |
-
|
308 |
-
|
309 |
-
|
310 |
-
|
311 |
-
if (!array_key_exists($key, $product_result)
|
312 |
-
|
313 |
-
|
314 |
-
|
315 |
-
&& !stristr($product_result[$key], '.jpeg')
|
316 |
-
&& !stristr($product_result[$key], '.gif')
|
317 |
-
&& !stristr($product_result[$key], '.bmp')
|
318 |
-
) {
|
319 |
-
//overwrite record image_url with parent's value when child doesn't have correct image url
|
320 |
-
$product_result[$key] = $value;
|
321 |
-
} elseif ($key != 'image_url') {
|
322 |
-
//overwrite description,short_description and product_url
|
323 |
-
$product_result[$key] = $value;
|
324 |
-
}
|
325 |
}
|
326 |
}
|
|
|
327 |
}
|
328 |
|
329 |
-
$product_result = Mage::helper('connector')->addStockInfoToResult($product,$product_result);
|
330 |
// add some parent attributes
|
331 |
-
$
|
332 |
-
|
333 |
-
'categories' => $this->categories,
|
334 |
-
);
|
335 |
-
if ($parent_id && $configurable && ($product->getVisibility() == Mage_Catalog_Model_Product_Visibility::VISIBILITY_NOT_VISIBLE)) {
|
336 |
-
$product_result = Mage::helper('connector')->addProductDynamicAttributesToResult($product,$product_result, $parent_product, $categoriesData);
|
337 |
} else {
|
338 |
-
$product_result =
|
339 |
}
|
340 |
|
341 |
-
|
342 |
-
|
343 |
-
if ( $product->getTypeId() == "simple" ) {
|
344 |
// which is child of some parent product
|
345 |
-
if (
|
346 |
-
if($parent_product->getTypeInstance(true) instanceof Mage_Catalog_Model_Product_Type_Configurable) {
|
347 |
-
// get all configurable attributes
|
348 |
-
|
349 |
-
if ($parent_product) {
|
350 |
-
$attributes = $parent_product->getTypeInstance(true)->getConfigurableAttributes($parent_product);
|
351 |
-
}
|
352 |
-
// array to keep the price differences for each attribute value
|
353 |
-
$pricesByAttributeValues = array();
|
354 |
-
// base price of the configurable product
|
355 |
-
$basePrice = $parent_product->getFinalPrice();
|
356 |
-
// loop through the attributes and get the price adjustments specified in the configurable product admin page
|
357 |
-
foreach ($attributes as $attribute) {
|
358 |
-
$prices = $attribute->getPrices();
|
359 |
-
foreach ($prices as $price) {
|
360 |
-
if ($price['is_percent']) {
|
361 |
-
$pricesByAttributeValues[$price['value_index']] = (float)$price['pricing_value'] * $basePrice / 100;
|
362 |
-
} else {
|
363 |
-
$pricesByAttributeValues[$price['value_index']] = (float)$price['pricing_value'];
|
364 |
-
}
|
365 |
-
}
|
366 |
-
}
|
367 |
-
|
368 |
-
$totalPrice = $basePrice;
|
369 |
-
// loop through the configurable attributes
|
370 |
-
foreach ($attributes as $attribute) {
|
371 |
-
// get the value for a specific attribute for a simple product
|
372 |
-
$value = $product->getData($attribute->getProductAttribute()->getAttributeCode());
|
373 |
-
// add the price adjustment to the total price of the simple product
|
374 |
-
if (isset($pricesByAttributeValues[$value])) {
|
375 |
-
$totalPrice += $pricesByAttributeValues[$value];
|
376 |
-
}
|
377 |
-
}
|
378 |
-
$_taxHelper = Mage::helper('tax');
|
379 |
|
380 |
$product_result['variant_name'] = $product->getName();
|
381 |
-
$product_result
|
382 |
-
|
383 |
-
$product_result['variant_special_price_with_tax'] = $_taxHelper->getPrice($product, $product->getSpecialPrice(), 2);
|
384 |
} else {
|
385 |
-
// item has a parent
|
386 |
// it has no effect on price modifiers, however, so we ignore it
|
387 |
}
|
388 |
}
|
389 |
}
|
390 |
|
391 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
392 |
|
393 |
$result[] = $product_result;
|
394 |
|
@@ -396,7 +465,9 @@ class DataFeedWatch_Connector_Model_Datafeedwatch_Api extends Mage_Catalog_Model
|
|
396 |
return $result;
|
397 |
}
|
398 |
|
399 |
-
|
|
|
|
|
400 |
public function gmt_offset(){
|
401 |
// get timezone offset in GMT
|
402 |
$timeZone = new DateTimeZone(Mage::getStoreConfig('general/locale/timezone'));
|
@@ -406,89 +477,56 @@ class DataFeedWatch_Connector_Model_Datafeedwatch_Api extends Mage_Catalog_Model
|
|
406 |
return $offset;
|
407 |
}
|
408 |
|
409 |
-
|
410 |
-
|
411 |
-
|
412 |
-
|
413 |
-
if($finalPrice){
|
414 |
-
$product_result['price'] = sprintf("%.2f", round($finalPrice, 2));
|
415 |
-
}
|
416 |
-
|
417 |
-
|
418 |
-
return $product_result;
|
419 |
-
}
|
420 |
-
|
421 |
-
/* API Method */
|
422 |
public function synced_fields(){
|
423 |
$additional = array();
|
424 |
if(Mage::getStoreConfig('datafeedwatch/settings/attributes')){
|
425 |
-
$additional =
|
426 |
}
|
427 |
|
428 |
return $additional;
|
429 |
}
|
430 |
|
431 |
-
|
432 |
-
|
433 |
-
|
434 |
-
|
435 |
-
|
436 |
-
$collection = Mage::getModel('catalog/product')->getCollection()
|
437 |
-
->addAttributeToFilter(array(
|
438 |
-
array('attribute'=>'ignore_datafeedwatch', 'neq'=> 1),
|
439 |
-
array('attribute'=>'ignore_datafeedwatch', 'null'=> true),
|
440 |
-
),
|
441 |
-
'',
|
442 |
-
'left'
|
443 |
-
)
|
444 |
-
;
|
445 |
-
} else {
|
446 |
-
$collection = Mage::getModel('catalog/product')->getCollection();
|
447 |
-
}
|
448 |
-
|
449 |
|
450 |
-
|
|
|
451 |
|
452 |
-
|
453 |
-
if (!is_numeric($options['store'])) {
|
454 |
-
$options['store'] = Mage::app()->getStore($options['store'])->getId();
|
455 |
-
}
|
456 |
|
457 |
-
|
458 |
-
|
459 |
-
Mage::app()->setCurrentStore($this->storeId);
|
460 |
-
|
461 |
-
//reinitialize collection because flat catalog settings may have changed
|
462 |
-
if ($attributeId) {
|
463 |
-
$collection = Mage::getModel('catalog/product')->getCollection()
|
464 |
-
->addAttributeToFilter(array(
|
465 |
-
array('attribute'=>'ignore_datafeedwatch', 'neq'=> 1),
|
466 |
-
array('attribute'=>'ignore_datafeedwatch', 'null'=> true),
|
467 |
-
),
|
468 |
-
'',
|
469 |
-
'left'
|
470 |
-
)
|
471 |
-
;
|
472 |
-
} else {
|
473 |
-
$collection = Mage::getModel('catalog/product')->getCollection();
|
474 |
-
}
|
475 |
|
476 |
-
|
|
|
|
|
477 |
|
478 |
-
|
479 |
-
|
480 |
-
|
481 |
-
|
482 |
}
|
|
|
483 |
|
484 |
-
|
485 |
-
|
486 |
-
|
487 |
-
|
488 |
-
|
489 |
-
|
490 |
-
|
|
|
|
|
|
|
491 |
|
492 |
-
return $
|
493 |
}
|
|
|
|
|
494 |
}
|
5 |
// category
|
6 |
const CATEGORY_NAME_FIELD = 'name';
|
7 |
const CATEGORY_SEPARATOR = ' > ';
|
|
|
8 |
|
|
|
9 |
public $storeRootCategoryId = 2;
|
10 |
+
|
11 |
+
public $categories = array();
|
12 |
public $storeCategories = array();
|
13 |
|
14 |
+
private $_versionInfo;
|
15 |
+
|
16 |
/* has been tested with this EE version and works completely */
|
17 |
+
private $_supportedEnterprise = array(
|
18 |
'major' => '1',
|
19 |
'minor' => '13',
|
20 |
'revision' => '0',
|
22 |
'stability' => '',
|
23 |
'number' => '',
|
24 |
);
|
25 |
+
private $_isSupportedEnterprise = false;
|
26 |
+
|
27 |
|
28 |
public function __construct()
|
29 |
{
|
|
|
30 |
ini_set('memory_limit', '1024M');
|
31 |
}
|
32 |
|
33 |
+
/**
|
34 |
+
* @return array
|
35 |
+
*/
|
36 |
public function stores()
|
37 |
{
|
38 |
+
$returned = array();
|
39 |
foreach (Mage::app()->getWebsites() as $website) {
|
40 |
+
/* @var $website Mage_Core_Model_Website */
|
41 |
foreach ($website->getGroups() as $group) {
|
42 |
+
/* @var $group Mage_Core_Model_Store_Group */
|
43 |
$stores = $group->getStores();
|
44 |
foreach ($stores as $store) {
|
45 |
+
/* @var $store Mage_Core_Model_Store */
|
46 |
$returned[$store->getCode()] = array(
|
47 |
'Website' => $website->getName(),
|
48 |
'Store' => $group->getName(),
|
54 |
return $returned;
|
55 |
}
|
56 |
|
57 |
+
/**
|
58 |
+
* @param array $options
|
59 |
+
* @return mixed
|
60 |
+
* @throws Mage_Api_Exception
|
61 |
+
*/
|
62 |
public function product_ids($options = array())
|
63 |
{
|
64 |
+
$dataFeedWatchHelper = Mage::helper('connector');
|
65 |
+
/* @var $dataFeedWatchHelper DataFeedWatch_Connector_Helper_Data */
|
66 |
+
|
67 |
if (!array_key_exists('page', $options)) {
|
68 |
+
$options['page'] = 0;
|
69 |
}
|
70 |
|
71 |
if (!array_key_exists('per_page', $options)) {
|
72 |
$options['per_page'] = 100;
|
73 |
}
|
74 |
+
$collection = $dataFeedWatchHelper->prepareCollection($options)->setPage($options['page'],$options['per_page']);
|
75 |
+
|
76 |
+
if(count($collection)>0){
|
77 |
+
foreach($collection as $product){
|
78 |
+
|
79 |
+
if ($product->getTypeId() == "simple") {
|
80 |
+
$parentIds = Mage::getModel('catalog/product_type_grouped')->getParentIdsByChild($product->getId());
|
81 |
+
if (!$parentIds) {
|
82 |
+
$parentIds = Mage::getModel('catalog/product_type_configurable')->getParentIdsByChild($product->getId());
|
83 |
+
if (isset($parentIds[0])) {
|
84 |
+
$isConfigurable = true;
|
85 |
+
}
|
86 |
+
}
|
87 |
+
|
88 |
+
if (isset($parentIds[0])) {
|
89 |
+
$parent_product = Mage::getModel('catalog/product')->load($parentIds[0]);
|
90 |
+
/* @var $parent_product Mage_Catalog_Model_Product_Type_Configurable */
|
91 |
+
while (!$parent_product->getId()) {
|
92 |
+
if (count($parentIds) > 1) {
|
93 |
+
//parent not found, remove and retry with next one
|
94 |
+
array_shift($parentIds);
|
95 |
+
$parent_product = Mage::getModel('catalog/product')->load($parentIds[0]);
|
96 |
+
} else {
|
97 |
+
break;
|
98 |
+
}
|
99 |
+
}
|
100 |
|
101 |
+
//do not include variant products that will not be fetched by products method
|
102 |
+
if ($dataFeedWatchHelper->shouldSkipProduct($product,$parent_product)) {
|
103 |
+
continue;
|
104 |
+
}
|
105 |
+
}
|
106 |
+
$products[] = $product->getId();
|
107 |
+
}else {
|
108 |
+
$products[] = $product->getId();
|
109 |
+
}
|
110 |
+
}
|
111 |
+
return array_values($products);
|
112 |
+
}
|
113 |
|
114 |
+
return array();
|
115 |
}
|
116 |
|
117 |
+
/**
|
118 |
+
* @return string
|
119 |
+
*/
|
120 |
public function version()
|
121 |
{
|
122 |
return (string)Mage::getConfig()->getNode('modules/DataFeedWatch_Connector')->version;
|
123 |
}
|
124 |
|
125 |
+
/**
|
126 |
+
* @param array $options
|
127 |
+
* @return int
|
128 |
+
* @throws Mage_Api_Exception
|
129 |
+
*/
|
130 |
public function product_count($options = array())
|
131 |
{
|
132 |
+
$products = array();
|
133 |
+
$dataFeedWatchHelper = Mage::helper('connector');
|
134 |
+
/* var $dataFeedWatchHelper DataFeedWatch_Connector_Helper_Data */
|
135 |
+
$collection = $dataFeedWatchHelper->prepareCollection($options);
|
136 |
|
137 |
+
foreach($collection as $product){
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
138 |
|
139 |
+
if ($product->getTypeId() == "simple") {
|
140 |
+
$parentIds = Mage::getModel('catalog/product_type_grouped')->getParentIdsByChild($product->getId());
|
141 |
+
if (!$parentIds) {
|
142 |
+
$parentIds = Mage::getModel('catalog/product_type_configurable')->getParentIdsByChild($product->getId());
|
143 |
+
if (isset($parentIds[0])) {
|
144 |
+
$isConfigurable = true;
|
145 |
+
}
|
|
|
|
|
|
|
146 |
}
|
147 |
|
148 |
+
if (isset($parentIds[0])) {
|
149 |
+
$parent_product = Mage::getModel('catalog/product')->load($parentIds[0]);
|
150 |
+
/* @var $parent_product Mage_Catalog_Model_Product_Type_Configurable */
|
151 |
+
while (!$parent_product->getId()) {
|
152 |
+
if (count($parentIds) > 1) {
|
153 |
+
//parent not found, remove and retry with next one
|
154 |
+
array_shift($parentIds);
|
155 |
+
$parent_product = Mage::getModel('catalog/product')->load($parentIds[0]);
|
156 |
+
} else {
|
157 |
+
break;
|
158 |
+
}
|
159 |
+
}
|
160 |
+
|
161 |
+
//do not include variant products that will not be fetched by products method
|
162 |
+
if ($dataFeedWatchHelper->shouldSkipProduct($product,$parent_product)) {
|
163 |
+
continue;
|
164 |
+
}
|
165 |
+
}
|
166 |
+
$products[] = $product->getId();
|
167 |
+
}else {
|
168 |
+
$products[] = $product->getId();
|
169 |
}
|
|
|
|
|
170 |
}
|
171 |
|
172 |
+
$numberOfProducts = count($products);
|
173 |
+
|
174 |
+
/* @deprecated since this doesn't apply filters based on status
|
175 |
$numberOfProducts = 0;
|
176 |
if (!empty($collection)) {
|
177 |
$numberOfProducts = $collection->getSize();
|
178 |
}
|
179 |
+
*/
|
180 |
|
181 |
+
return $numberOfProducts;
|
182 |
}
|
183 |
|
184 |
+
/**
|
185 |
+
* @param array $options
|
186 |
+
* @return array
|
187 |
+
* @throws Mage_Api_Exception
|
188 |
+
*/
|
189 |
+
public function products($options = array(), $fetchingUpdatedProducts = false)
|
190 |
{
|
191 |
$mageObject = new Mage;
|
192 |
+
$dataFeedWatchHelper = Mage::helper('connector');
|
193 |
+
/* @var $dataFeedWatchHelper DataFeedWatch_Connector_Helper_Data */
|
194 |
+
|
195 |
$this->_versionInfo = Mage::getVersionInfo();
|
196 |
|
197 |
+
/* If we have Enterprise Edition, make sure our current Enterprise is supported */
|
198 |
+
if (method_exists($mageObject, 'getEdition')
|
199 |
+
&& Mage::getEdition() == Mage::EDITION_ENTERPRISE
|
200 |
+
&& version_compare(implode('.',$this->_versionInfo),implode('.',$this->_supportedEnterprise),'>=')) {
|
201 |
+
$this->_isSupportedEnterprise = true;
|
202 |
+
$dataFeedWatchHelper->isSupportedEnterprise = true;
|
203 |
+
}
|
204 |
+
|
205 |
+
/* Use default page if not set */
|
206 |
if (!array_key_exists('page', $options)) {
|
207 |
+
$options['page'] = 0;
|
208 |
}
|
209 |
|
210 |
+
/* Use default limit if not set */
|
211 |
if (!array_key_exists('per_page', $options)) {
|
212 |
$options['per_page'] = 100;
|
213 |
}
|
214 |
|
215 |
+
/* Get Product Collection */
|
216 |
+
$collection = $dataFeedWatchHelper->prepareCollection($options);
|
217 |
|
218 |
+
/* Set current store using storeId got in prepareCollection */
|
219 |
+
$store = Mage::app()->getStore($dataFeedWatchHelper->storeId);
|
|
|
220 |
|
221 |
+
/* Clear options that are not product filters and were meant only for prepareCollection */
|
222 |
+
/* page and per_page already removed in preparecollection */
|
|
|
223 |
unset($options['store']);
|
224 |
|
225 |
+
/* @TODO: check if this shouldn't be prepareCollection part */
|
226 |
+
$collection->addAttributeToSelect('*')
|
227 |
+
->joinAttribute('visibility', 'catalog_product/visibility', 'entity_id', null, 'inner', $dataFeedWatchHelper->storeId)
|
228 |
+
->setPage($options['page'], $options['per_page']);
|
229 |
|
230 |
/* set current store manually so we get specific store url returned in getBaseUrl */
|
231 |
+
$this->storeRootCategoryId = Mage::app()->getStore($dataFeedWatchHelper->storeId)->getRootCategoryId();
|
|
|
|
|
|
|
|
|
232 |
|
233 |
$baseUrl = Mage::getBaseUrl(Mage_Core_Model_Store::URL_TYPE_WEB);
|
234 |
|
235 |
+
/* prepare categories and storeCategories */
|
236 |
+
$dataFeedWatchHelper->loadCategories($this->storeRootCategoryId);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
237 |
|
238 |
$result = array();
|
|
|
239 |
|
240 |
foreach ($collection as $product) {
|
241 |
|
243 |
$parent_id = null;
|
244 |
$parent_sku = null;
|
245 |
$parent_url = null;
|
246 |
+
$isConfigurable = false;
|
247 |
|
248 |
+
//reload product to get all attributes for particular store
|
249 |
+
if ($dataFeedWatchHelper->storeId) {
|
250 |
+
$product = Mage::getModel('catalog/product')->setStoreId($dataFeedWatchHelper->storeId)->load($product->getId());
|
251 |
} else {
|
252 |
$product = Mage::getModel('catalog/product')->load($product->getId());
|
253 |
}
|
254 |
+
/* @var $product Mage_Catalog_Model_Product */
|
255 |
|
256 |
+
$product_result = array(
|
257 |
+
// Basic product data
|
258 |
'product_id' => $product->getId(),
|
259 |
'sku' => $product->getSku(),
|
260 |
'product_type' => $product->getTypeId()
|
261 |
);
|
262 |
|
263 |
+
/* Get attribute settings */
|
264 |
+
/* user attributes selected in Admin -> Catalog -> Datafeedwatch -> Settings */
|
265 |
$selected_attributes = $this->synced_fields();
|
266 |
+
|
267 |
+
/* hardcoded attributes list to fetch */
|
268 |
+
$requiredAttributes = $dataFeedWatchHelper->getRequiredAttributes();
|
269 |
+
|
270 |
+
/* join two of the above into one */
|
271 |
+
$allowedAttributes = array_merge($selected_attributes, $requiredAttributes);
|
272 |
+
|
273 |
+
/* attributes that should never be returned */
|
274 |
+
$excludedAttributes = $dataFeedWatchHelper->getExcludedAttributes();
|
275 |
+
|
276 |
foreach ($product->getAttributes() as $attribute) {
|
277 |
|
278 |
/* ignore excluded attributes */
|
279 |
+
if (array_key_exists($attribute->getAttributeCode(), $excludedAttributes)) {
|
280 |
continue;
|
281 |
}
|
282 |
|
283 |
/* only use user-selected fields from DataFeedWatch -> Settings + required attributes */
|
284 |
+
if (in_array($attribute->getAttributeCode(), $allowedAttributes)) {
|
285 |
$value = $product->getData($attribute->getAttributeCode());
|
286 |
if (!empty($value)) {
|
287 |
+
$value = $attribute->getFrontend()->getValue($product);
|
288 |
+
if(is_string($value)) {
|
289 |
+
$value = trim($value);
|
|
|
290 |
}
|
291 |
}
|
292 |
$product_result[$attribute->getAttributeCode()] = $value;
|
293 |
} else {
|
294 |
+
//if you ever decide to log this:
|
295 |
+
//Mage::log('attr_code: '.$attribute->getAttributeCode().' was not synced',null,'datafeedwatch_connector.log');
|
296 |
}
|
297 |
}
|
298 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
299 |
/* get product Url */
|
300 |
+
if ($this->_isSupportedEnterprise) {
|
301 |
$product_result['product_url'] = $product->getProductUrl();
|
302 |
} else {
|
303 |
+
$product_result['product_url_rewritten'] = $baseUrl . $dataFeedWatchHelper->getRewrittenProductUrl($product, null, $dataFeedWatchHelper->storeId);
|
304 |
$product_result['product_url'] = $baseUrl . $product->getUrlPath();
|
305 |
}
|
306 |
|
307 |
+
|
308 |
+
$parent_product = $dataFeedWatchHelper->getParentProductFromChild($product);
|
309 |
+
/* @var $parent_product Mage_Catalog_Model_Product */
|
310 |
+
|
311 |
+
if($parent_product) {
|
312 |
+
$parent_id = $parent_product->getId();
|
313 |
+
|
314 |
+
$product_result['parent_id'] = $parent_id;
|
315 |
+
$product_result['parent_sku'] = $parent_sku =$parent_product->getSku();
|
316 |
+
$product_result['parent_url'] = $parent_url;
|
317 |
+
|
318 |
+
$configurableParentIds = Mage::getModel('catalog/product_type_configurable')->getParentIdsByChild($product->getId());
|
319 |
+
if(in_array($parent_product->getId(),$configurableParentIds)){
|
320 |
+
$isConfigurable = true;
|
321 |
}
|
322 |
+
}
|
323 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
324 |
|
325 |
+
/* Do not return the product if we should skip it */
|
326 |
+
if (
|
327 |
+
!$fetchingUpdatedProducts
|
328 |
+
&& $dataFeedWatchHelper->shouldSkipProduct($product, $parent_product)
|
329 |
+
) {
|
330 |
+
continue;
|
331 |
+
}
|
332 |
+
|
333 |
+
/* Change child product status to disabled if using updated_products and parent status is Disabled */
|
334 |
+
if(
|
335 |
+
$fetchingUpdatedProducts
|
336 |
+
&& $product->getVisibility() == Mage_Catalog_Model_Product_Visibility::VISIBILITY_NOT_VISIBLE
|
337 |
+
&& is_object($parent_product)
|
338 |
+
&& $parent_product->getStatus()==Mage_Catalog_Model_Product_Status::STATUS_DISABLED
|
339 |
+
){
|
340 |
+
$product_result['status'] = Mage::helper('catalog')->__('Disabled');
|
341 |
+
}
|
342 |
|
343 |
+
//parent_url
|
344 |
+
if($parent_product) {
|
345 |
+
if ($this->_isSupportedEnterprise) {
|
346 |
+
$parent_url = $parent_product->getProductUrl();
|
347 |
+
} else {
|
348 |
+
$parent_url = $baseUrl . $parent_product->getUrlPath();
|
349 |
}
|
350 |
}
|
351 |
|
352 |
+
/* if child is NVI, use parent attributes */
|
353 |
+
if ($parent_id && $isConfigurable && $product->getVisibility() == Mage_Catalog_Model_Product_Visibility::VISIBILITY_NOT_VISIBLE) {
|
354 |
+
/* rewrite to prepare array of fields to overwrite with parent values */
|
355 |
+
$productAttributes = $dataFeedWatchHelper->getProductAttributes($parent_product);
|
|
|
|
|
356 |
|
357 |
// get child product visibility
|
358 |
$visibilityStatuses = Mage_Catalog_Model_Product_Visibility::getOptionArray();
|
362 |
$productAttributes['visibility'] = null;
|
363 |
}
|
364 |
} else {
|
365 |
+
$productAttributes = $dataFeedWatchHelper->getProductAttributes($product);
|
366 |
+
}
|
367 |
+
|
368 |
+
|
369 |
+
|
370 |
+
//add product main image
|
371 |
+
/* @TODO: move to helper */
|
372 |
+
$imageUrl = (string)$product->getMediaConfig()->getMediaUrl($product->getData('image'));
|
373 |
+
$imageTmpArr = explode('.', $imageUrl);
|
374 |
+
$countImgArr = count($imageTmpArr);
|
375 |
+
if (empty($imageUrl) || $imageUrl == '' || !isset($imageUrl) || $countImgArr < 2) {
|
376 |
+
$imageUrl = (string)Mage::helper('catalog/image')->init($product, 'image');
|
377 |
}
|
378 |
+
$product_result['image_url'] = $imageUrl;
|
379 |
+
|
380 |
+
|
381 |
|
382 |
+
//always use parent values for description, short_description
|
383 |
+
if($parent_id){
|
384 |
+
$product_results['short_description'] = $parent_product->getShortDescription();
|
385 |
+
$product_results['description'] = $parent_product->getDescription();
|
386 |
+
|
387 |
+
|
388 |
+
//use parent image_url if(only if) it's empty in child
|
389 |
+
if(!array_key_exists('image_url',$product_result) || $product_result['image_url']==''){
|
390 |
+
$product_result['image_url'] = $parent_product->getImageUrl();
|
391 |
+
}
|
392 |
+
|
393 |
+
//use parent attribute value if child attribute value empty or doesn't exist in child
|
394 |
foreach ($productAttributes as $key => $value) {
|
395 |
+
|
396 |
+
/*skip attributes we overwritten above */
|
397 |
+
if(in_array($key,array('description','short_description','image_url'))){
|
398 |
+
continue;
|
399 |
+
}
|
400 |
+
|
401 |
+
if (!array_key_exists($key, $product_result)
|
402 |
+
|| (array_key_exists($key, $product_result) && !$product_result[$key])
|
403 |
+
){
|
404 |
+
$product_result[$key] = $value;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
405 |
}
|
406 |
}
|
407 |
+
|
408 |
}
|
409 |
|
|
|
410 |
// add some parent attributes
|
411 |
+
if ($parent_id && $isConfigurable && ($product->getVisibility() == Mage_Catalog_Model_Product_Visibility::VISIBILITY_NOT_VISIBLE)) {
|
412 |
+
$product_result = $dataFeedWatchHelper->addProductDynamicAttributesToResult($product, $product_result, $parent_product);
|
|
|
|
|
|
|
|
|
413 |
} else {
|
414 |
+
$product_result = $dataFeedWatchHelper->addProductDynamicAttributesToResult($product, $product_result, null);
|
415 |
}
|
416 |
|
417 |
+
// get variant name and default flag
|
418 |
+
if ($product->getTypeId() == "simple") {
|
|
|
419 |
// which is child of some parent product
|
420 |
+
if (!empty($parent_id) && gettype($parent_product) == 'object') {
|
421 |
+
if ($parent_product->getTypeInstance(true) instanceof Mage_Catalog_Model_Product_Type_Configurable) {
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
422 |
|
423 |
$product_result['variant_name'] = $product->getName();
|
424 |
+
$product_result = $dataFeedWatchHelper->addDefaultVariantFlag($product, $parent_product, $product_result);
|
425 |
+
|
|
|
426 |
} else {
|
427 |
+
// item has a parent because it extends Mage_Catalog_Model_Product_Type_Grouped
|
428 |
// it has no effect on price modifiers, however, so we ignore it
|
429 |
}
|
430 |
}
|
431 |
}
|
432 |
|
433 |
+
//add multiple product images to result
|
434 |
+
$product_result = $dataFeedWatchHelper->addImageToResult($product,$product_result);
|
435 |
+
//add prices and custom price fields
|
436 |
+
|
437 |
+
|
438 |
+
$product_result = $dataFeedWatchHelper->addPricesToResult($product,$product_result,$parent_product);
|
439 |
+
//format prices and get rid of empty price fields (nullify them)
|
440 |
+
$product_result = $dataFeedWatchHelper->formatPrices($product, $product_result);
|
441 |
+
//add in stock and qty information
|
442 |
+
$product_result = $dataFeedWatchHelper->addStockInfoToResult($product, $product_result,$parent_product);
|
443 |
+
|
444 |
+
// adding currency code ex. 'USD'
|
445 |
+
$product_result['currency_code'] = $store->getCurrentCurrencyCode();
|
446 |
+
|
447 |
+
|
448 |
+
|
449 |
+
/*override product url*/
|
450 |
+
if(Mage::getStoreConfig('datafeedwatch/settings/url_type')){
|
451 |
+
/* 2 stands for Full URL */
|
452 |
+
if(Mage::getStoreConfig('datafeedwatch/settings/url_type') == 2){
|
453 |
+
$product_result['product_url'] = Mage::helper('connector')->getFullUrl($product);
|
454 |
+
if($parent_product) {
|
455 |
+
$product_result['parent_url'] = Mage::helper('connector')->getFullUrl($parent_product);
|
456 |
+
}
|
457 |
+
}
|
458 |
+
}
|
459 |
+
|
460 |
+
|
461 |
|
462 |
$result[] = $product_result;
|
463 |
|
465 |
return $result;
|
466 |
}
|
467 |
|
468 |
+
/**
|
469 |
+
* @return int
|
470 |
+
*/
|
471 |
public function gmt_offset(){
|
472 |
// get timezone offset in GMT
|
473 |
$timeZone = new DateTimeZone(Mage::getStoreConfig('general/locale/timezone'));
|
477 |
return $offset;
|
478 |
}
|
479 |
|
480 |
+
/**
|
481 |
+
* @return array|mixed
|
482 |
+
*/
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
483 |
public function synced_fields(){
|
484 |
$additional = array();
|
485 |
if(Mage::getStoreConfig('datafeedwatch/settings/attributes')){
|
486 |
+
$additional = unserialize(Mage::getStoreConfig('datafeedwatch/settings/attributes'));
|
487 |
}
|
488 |
|
489 |
return $additional;
|
490 |
}
|
491 |
|
492 |
+
/**
|
493 |
+
* @param $options
|
494 |
+
* @return array
|
495 |
+
*/
|
496 |
+
public function updated_products($options){
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
497 |
|
498 |
+
$dataFeedWatchHelper = Mage::helper('connector');
|
499 |
+
/* @var $dataFeedWatchHelper DataFeedWatch_Connector_Helper_Data */
|
500 |
|
501 |
+
$fetchList = $dataFeedWatchHelper->getUpdatedProductList($options);
|
|
|
|
|
|
|
502 |
|
503 |
+
if(!empty($fetchList)) {
|
504 |
+
$options['entity_id'] = $fetchList;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
505 |
|
506 |
+
/*remove updated at filter, we do not want to use it on normal call*/
|
507 |
+
unset($options['updated_at']);
|
508 |
+
unset($options['status']);
|
509 |
|
510 |
+
$fetchingUpdatedProducts = true;
|
511 |
+
return $this->products($options,$fetchingUpdatedProducts);
|
512 |
+
} else {
|
513 |
+
return array();
|
514 |
}
|
515 |
+
}
|
516 |
|
517 |
+
/**
|
518 |
+
* @param $options
|
519 |
+
* @return int
|
520 |
+
*/
|
521 |
+
public function updated_product_count($options){
|
522 |
+
|
523 |
+
$dataFeedWatchHelper = Mage::helper('connector');
|
524 |
+
/* @var $dataFeedWatchHelper DataFeedWatch_Connector_Helper_Data */
|
525 |
+
|
526 |
+
$fetchList = $dataFeedWatchHelper->getUpdatedProductList($options);
|
527 |
|
528 |
+
return count($fetchList);
|
529 |
}
|
530 |
+
|
531 |
+
|
532 |
}
|
app/code/community/DataFeedWatch/Connector/Model/Observer.php
ADDED
@@ -0,0 +1,51 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
class DataFeedWatch_Connector_Model_Observer extends Mage_Core_Model_Abstract {
|
3 |
+
|
4 |
+
/* @TODO: the date should update on rule apply! */
|
5 |
+
public function catalogruleRuleSaveAfter(Varien_Event_Observer $observer){
|
6 |
+
$object = $observer->getEvent();
|
7 |
+
|
8 |
+
$ruleId = $object->getRule()->getRuleId();
|
9 |
+
|
10 |
+
$dfwCatalogRuleInfo = Mage::getModel('connector/catalogrule_info')->load($ruleId,'catalogrule_id');
|
11 |
+
$dfwCatalogRuleInfo
|
12 |
+
->setCatalogruleId($ruleId)
|
13 |
+
->setUpdatedAt(time())
|
14 |
+
->save();
|
15 |
+
}
|
16 |
+
|
17 |
+
/* @TODO: the date should update on rule apply! */
|
18 |
+
public function salesruleRuleSaveAfter(Varien_Event_Observer $observer){
|
19 |
+
$object = $observer->getEvent();
|
20 |
+
$ruleId = $object->getRule()->getRuleId();
|
21 |
+
|
22 |
+
$dfwSalesRuleInfo = Mage::getModel('connector/salesrule_info')->load($ruleId,'salesrule_id');;
|
23 |
+
$dfwSalesRuleInfo
|
24 |
+
->setSalesruleId($object->getRule()->getRuleId())
|
25 |
+
->setUpdatedAt(time())
|
26 |
+
->save();
|
27 |
+
}
|
28 |
+
|
29 |
+
/* after you press apply All Catalog Rules in admin */
|
30 |
+
public function catalogruleRuleApplyAllAfter(Varien_Event_Observer $observer){
|
31 |
+
$object = $observer->getEvent();
|
32 |
+
$rules = array();
|
33 |
+
|
34 |
+
//get all current rules
|
35 |
+
$rules = Mage::getModel('catalogrule/rule')->getCollection();
|
36 |
+
|
37 |
+
foreach($rules as $rule){
|
38 |
+
/* @var $rule Mage_CatalogRule_Model_Rule */
|
39 |
+
if($rule->getIsActive() && $rule->getMatchingProductIds()) {
|
40 |
+
/* save current datetime to info for each of them */
|
41 |
+
$dfwCatalogRuleInfo = Mage::getModel('connector/catalogrule_info')->load($rule->getRuleId(), 'catalogrule_id');
|
42 |
+
$dfwCatalogRuleInfo
|
43 |
+
->setCatalogruleId($rule->getRuleId())
|
44 |
+
->setUpdatedAt(time())
|
45 |
+
->save();
|
46 |
+
}
|
47 |
+
}
|
48 |
+
|
49 |
+
|
50 |
+
}
|
51 |
+
}
|
app/code/community/DataFeedWatch/Connector/Model/Resource/Catalogrule/Info.php
ADDED
@@ -0,0 +1,8 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
|
3 |
+
class DataFeedWatch_Connector_Model_Resource_Catalogrule_Info extends Mage_Core_Model_Resource_Db_Abstract {
|
4 |
+
|
5 |
+
public function _construct(){
|
6 |
+
$this->_init('connector/catalogrule_info','catalogruleinfo_id');
|
7 |
+
}
|
8 |
+
}
|
app/code/community/DataFeedWatch/Connector/Model/Resource/Catalogrule/Info/Collection.php
ADDED
@@ -0,0 +1,8 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
|
3 |
+
class DataFeedWatch_Connector_Model_Resource_Catalogrule_Info_Collection extends Mage_Core_Model_Resource_Db_Collection_Abstract {
|
4 |
+
protected function _construct()
|
5 |
+
{
|
6 |
+
$this->_init('connector/catalogrule_info');
|
7 |
+
}
|
8 |
+
}
|
app/code/community/DataFeedWatch/Connector/Model/Resource/Salesrule/Info.php
ADDED
@@ -0,0 +1,8 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
|
3 |
+
class DataFeedWatch_Connector_Model_Resource_Salesrule_Info extends Mage_Core_Model_Resource_Db_Abstract {
|
4 |
+
|
5 |
+
public function _construct(){
|
6 |
+
$this->_init('connector/salesrule_info','salesruleinfo_id');
|
7 |
+
}
|
8 |
+
}
|
app/code/community/DataFeedWatch/Connector/Model/Resource/Salesrule/Info/Collection.php
ADDED
@@ -0,0 +1,7 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
class DataFeedWatch_Connector_Model_Resource_Salesrule_Info_Collection extends Mage_Core_Model_Resource_Db_Collection_Abstract {
|
3 |
+
protected function _construct()
|
4 |
+
{
|
5 |
+
$this->_init('connector/salesrule_info');
|
6 |
+
}
|
7 |
+
}
|
app/code/community/DataFeedWatch/Connector/Model/Resource/Setup.php
ADDED
@@ -0,0 +1,5 @@
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
|
3 |
+
class DataFeedWatch_Connector_Model_Resource_Setup extends Mage_Core_Model_Resource_Setup {
|
4 |
+
|
5 |
+
}
|
app/code/community/DataFeedWatch/Connector/Model/Salesrule/Info.php
ADDED
@@ -0,0 +1,8 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
|
3 |
+
class DataFeedWatch_Connector_Model_Salesrule_Info extends Mage_Core_Model_Abstract {
|
4 |
+
|
5 |
+
public function _construct(){
|
6 |
+
$this->_init('connector/salesrule_info','salesruleinfo_id');
|
7 |
+
}
|
8 |
+
}
|
app/code/community/DataFeedWatch/Connector/Model/Salesrule/Info/Collection.php
ADDED
@@ -0,0 +1,7 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
class DataFeedWatch_Connector_Model_Resource_Salesrule_Info_Collection extends Mage_Core_Model_Resource_Db_Collection_Abstract {
|
3 |
+
protected function _construct()
|
4 |
+
{
|
5 |
+
$this->_init('connector/salesrule_info');
|
6 |
+
}
|
7 |
+
}
|
app/code/community/DataFeedWatch/Connector/controllers/Adminhtml/ConnectorbackendController.php
DELETED
@@ -1,135 +0,0 @@
|
|
1 |
-
<?php
|
2 |
-
class DataFeedWatch_Connector_Adminhtml_ConnectorbackendController extends Mage_Adminhtml_Controller_Action {
|
3 |
-
protected $username = 'datafeedwatch';
|
4 |
-
protected $firstname = 'Api Access';
|
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() {
|
16 |
-
$ready = Mage::getStoreConfig('datafeedwatch/settings/ready');
|
17 |
-
if(!$ready){
|
18 |
-
Mage::getSingleton('adminhtml/session')
|
19 |
-
->addError(Mage::helper('connector')
|
20 |
-
->__('You need to pick your attributes and save your attribute settings before you can access My DataFeedWatch.'));
|
21 |
-
|
22 |
-
$this->_redirect('*/adminhtml_settings/index');
|
23 |
-
return;
|
24 |
-
}
|
25 |
-
$this->loadLayout();
|
26 |
-
$this->_title($this->__("DataFeedWatch"));
|
27 |
-
$this->renderLayout();
|
28 |
-
}
|
29 |
-
|
30 |
-
public function createuserAction() {
|
31 |
-
|
32 |
-
//Create Api Role for datafeedwatch user
|
33 |
-
$role = $this->_createApiRole();
|
34 |
-
|
35 |
-
//Prepare Api Key
|
36 |
-
$api_key = $this->_generateApiKey();
|
37 |
-
|
38 |
-
//send the api key to DFW
|
39 |
-
file_get_contents($this->_registerUrl($api_key));
|
40 |
-
|
41 |
-
//Get Api User
|
42 |
-
$user = $this->getUser();
|
43 |
-
if ($user->getId()) {
|
44 |
-
//Update Api User
|
45 |
-
$user = $this->_updateApiUser($api_key, $user);
|
46 |
-
} else {
|
47 |
-
//Create Api User
|
48 |
-
$user = $this->_createApiUser($api_key);
|
49 |
-
}
|
50 |
-
|
51 |
-
//Assign Api User to the Api Role
|
52 |
-
$user->setRoleId($role->getId())->setUserId($user->getId());
|
53 |
-
$user->add();
|
54 |
-
|
55 |
-
//redirect to register token url in DFW
|
56 |
-
$this->getResponse()->setRedirect($this->_registerUrl($api_key));
|
57 |
-
return;
|
58 |
-
}
|
59 |
-
|
60 |
-
public function redirectAction(){
|
61 |
-
$this->getResponse()->setRedirect($this->redirect_url);
|
62 |
-
return;
|
63 |
-
}
|
64 |
-
|
65 |
-
public function getUser() {
|
66 |
-
$model = Mage::getModel('api/user');
|
67 |
-
return $model->load($this->email, 'email');
|
68 |
-
}
|
69 |
-
|
70 |
-
private function _generateApiKey() {
|
71 |
-
return sha1(time()+substr(str_shuffle("0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ"), 0, 32));
|
72 |
-
}
|
73 |
-
|
74 |
-
private function _registerUrl($api_key) {
|
75 |
-
return $this->register_url.'?shop='.Mage::getBaseUrl().'&token='.$api_key;
|
76 |
-
}
|
77 |
-
|
78 |
-
private function _createApiRole(){
|
79 |
-
$role = Mage::getModel('api/roles')->load($this->lastname, 'role_name');
|
80 |
-
if ($role->isObjectNew()) {
|
81 |
-
$role = $role
|
82 |
-
->setName($this->lastname)
|
83 |
-
->setPid(false)
|
84 |
-
->setRoleType('G')
|
85 |
-
->save();
|
86 |
-
|
87 |
-
$resource = array("all");
|
88 |
-
|
89 |
-
Mage::getModel("api/rules")
|
90 |
-
->setRoleId($role->getId())
|
91 |
-
->setResources($resource)
|
92 |
-
->saveRel();
|
93 |
-
}
|
94 |
-
return $role;
|
95 |
-
}
|
96 |
-
|
97 |
-
private function _createApiUser($api_key){
|
98 |
-
$data = array(
|
99 |
-
'username' => $this->username,
|
100 |
-
'firstname' => $this->firstname,
|
101 |
-
'lastname' => $this->lastname,
|
102 |
-
'email' => $this->email,
|
103 |
-
'is_active' => 1,
|
104 |
-
'api_key' => $api_key,
|
105 |
-
'api_key_confirmation' => $api_key,
|
106 |
-
);
|
107 |
-
|
108 |
-
$user = Mage::getModel('api/user');
|
109 |
-
$user->setData($data);
|
110 |
-
$user->save();
|
111 |
-
return $user;
|
112 |
-
}
|
113 |
-
|
114 |
-
/**
|
115 |
-
* @param $api_key string
|
116 |
-
* @param $user Mage_Api_Model_User
|
117 |
-
*
|
118 |
-
* @return Mage_Api_Model_User
|
119 |
-
*/
|
120 |
-
|
121 |
-
private function _updateApiUser($api_key, $user) {
|
122 |
-
$data = array(
|
123 |
-
'username' => $this->username,
|
124 |
-
'firstname' => $this->firstname,
|
125 |
-
'lastname' => $this->lastname,
|
126 |
-
'is_active' => 1,
|
127 |
-
'api_key' => $api_key,
|
128 |
-
'api_key_confirmation' => $api_key,
|
129 |
-
);
|
130 |
-
|
131 |
-
$user->setData($data);
|
132 |
-
$user->save();
|
133 |
-
return $user;
|
134 |
-
}
|
135 |
-
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
app/code/community/DataFeedWatch/Connector/controllers/Adminhtml/{SettingsController.php → ConnectorsettingsController.php}
RENAMED
@@ -1,15 +1,20 @@
|
|
1 |
<?php
|
2 |
|
3 |
-
class
|
4 |
|
5 |
public function indexAction(){
|
6 |
-
|
7 |
if($this->_request->isPost()) {
|
8 |
$additional_attributes = $this->_request->getParam('additional_attributes');
|
9 |
if ($additional_attributes) {
|
10 |
-
Mage::getModel('core/config')->saveConfig('datafeedwatch/settings/attributes',
|
|
|
|
|
|
|
|
|
|
|
11 |
}
|
12 |
|
|
|
13 |
Mage::getModel('core/config')->saveConfig('datafeedwatch/settings/ready', 1);
|
14 |
|
15 |
//also clean config cache
|
@@ -30,12 +35,14 @@ class DataFeedWatch_Connector_Adminhtml_SettingsController extends Mage_Adminhtm
|
|
30 |
protected $lastname = 'DataFeedWatch';
|
31 |
protected $email = 'magento@datafeedwatch.com';
|
32 |
protected $register_url = 'https://my.datafeedwatch.com/platforms/magento/sessions/finalize';
|
|
|
33 |
|
34 |
/**
|
35 |
* currently the same as $register_url
|
36 |
* @var string
|
37 |
*/
|
38 |
protected $redirect_url = 'https://my.datafeedwatch.com/';
|
|
|
39 |
|
40 |
public function createuserAction() {
|
41 |
|
@@ -68,7 +75,11 @@ class DataFeedWatch_Connector_Adminhtml_SettingsController extends Mage_Adminhtm
|
|
68 |
}
|
69 |
|
70 |
public function redirectAction(){
|
71 |
-
|
|
|
|
|
|
|
|
|
72 |
return;
|
73 |
}
|
74 |
|
@@ -82,7 +93,11 @@ class DataFeedWatch_Connector_Adminhtml_SettingsController extends Mage_Adminhtm
|
|
82 |
}
|
83 |
|
84 |
private function _registerUrl($api_key) {
|
85 |
-
|
|
|
|
|
|
|
|
|
86 |
}
|
87 |
|
88 |
private function _createApiRole(){
|
1 |
<?php
|
2 |
|
3 |
+
class DataFeedWatch_Connector_Adminhtml_ConnectorsettingsController extends Mage_Adminhtml_Controller_Action{
|
4 |
|
5 |
public function indexAction(){
|
|
|
6 |
if($this->_request->isPost()) {
|
7 |
$additional_attributes = $this->_request->getParam('additional_attributes');
|
8 |
if ($additional_attributes) {
|
9 |
+
Mage::getModel('core/config')->saveConfig('datafeedwatch/settings/attributes', serialize($additional_attributes));
|
10 |
+
}
|
11 |
+
|
12 |
+
$url_type = $this->_request->getParam('url_type');
|
13 |
+
if($url_type){
|
14 |
+
Mage::getModel('core/config')->saveConfig('datafeedwatch/settings/url_type', $url_type);
|
15 |
}
|
16 |
|
17 |
+
|
18 |
Mage::getModel('core/config')->saveConfig('datafeedwatch/settings/ready', 1);
|
19 |
|
20 |
//also clean config cache
|
35 |
protected $lastname = 'DataFeedWatch';
|
36 |
protected $email = 'magento@datafeedwatch.com';
|
37 |
protected $register_url = 'https://my.datafeedwatch.com/platforms/magento/sessions/finalize';
|
38 |
+
protected $register_url_dev = 'https://my.preview.datafeedwatch.com/platforms/magento/sessions/finalize';
|
39 |
|
40 |
/**
|
41 |
* currently the same as $register_url
|
42 |
* @var string
|
43 |
*/
|
44 |
protected $redirect_url = 'https://my.datafeedwatch.com/';
|
45 |
+
protected $redirect_url_dev = 'https://my.preview.datafeedwatch.com/';
|
46 |
|
47 |
public function createuserAction() {
|
48 |
|
75 |
}
|
76 |
|
77 |
public function redirectAction(){
|
78 |
+
if (stristr(Mage::getUrl(),'http://datafeedwatch.stronazen.pl/')) {
|
79 |
+
$this->getResponse()->setRedirect($this->redirect_url_dev);
|
80 |
+
} else {
|
81 |
+
$this->getResponse()->setRedirect($this->redirect_url);
|
82 |
+
}
|
83 |
return;
|
84 |
}
|
85 |
|
93 |
}
|
94 |
|
95 |
private function _registerUrl($api_key) {
|
96 |
+
if (stristr(Mage::getUrl(),'http://datafeedwatch.stronazen.pl/')) {
|
97 |
+
return $this->register_url_dev.'?shop='.Mage::getBaseUrl().'&token='.$api_key;
|
98 |
+
} else {
|
99 |
+
return $this->register_url.'?shop='.Mage::getBaseUrl().'&token='.$api_key;
|
100 |
+
}
|
101 |
}
|
102 |
|
103 |
private function _createApiRole(){
|
app/code/community/DataFeedWatch/Connector/etc/api.xml
CHANGED
@@ -27,6 +27,12 @@
|
|
27 |
<gmt_offset translate="title" module="connector">
|
28 |
<title>Retrieve datetime in GMT</title>
|
29 |
</gmt_offset>
|
|
|
|
|
|
|
|
|
|
|
|
|
30 |
</methods>
|
31 |
</datafeedwatch>
|
32 |
</resources>
|
27 |
<gmt_offset translate="title" module="connector">
|
28 |
<title>Retrieve datetime in GMT</title>
|
29 |
</gmt_offset>
|
30 |
+
<updated_products translate="title" module="connector">
|
31 |
+
<title>Retrieve products based on last update</title>
|
32 |
+
</updated_products>
|
33 |
+
<updated_product_count translate="title" module="connector">
|
34 |
+
<title>Retrieve product count based on last update</title>
|
35 |
+
</updated_product_count>
|
36 |
</methods>
|
37 |
</datafeedwatch>
|
38 |
</resources>
|
app/code/community/DataFeedWatch/Connector/etc/config.xml
CHANGED
@@ -2,28 +2,28 @@
|
|
2 |
<config>
|
3 |
<modules>
|
4 |
<DataFeedWatch_Connector>
|
5 |
-
<version>0.2.
|
6 |
</DataFeedWatch_Connector>
|
7 |
</modules>
|
8 |
<admin>
|
9 |
<routers>
|
10 |
-
<
|
11 |
-
<use>admin</use>
|
12 |
<args>
|
13 |
-
<
|
14 |
-
|
|
|
15 |
</args>
|
16 |
-
</
|
17 |
</routers>
|
18 |
</admin>
|
19 |
<adminhtml>
|
20 |
<menu>
|
21 |
<catalog translate="title" module="adminhtml">
|
22 |
<children>
|
23 |
-
<
|
24 |
<title>DataFeedWatch</title>
|
25 |
-
<action>
|
26 |
-
</
|
27 |
</children>
|
28 |
</catalog>
|
29 |
</menu>
|
@@ -32,9 +32,9 @@
|
|
32 |
<admin>
|
33 |
<catalog>
|
34 |
<children>
|
35 |
-
<
|
36 |
<title>DataFeedWatch</title>
|
37 |
-
</
|
38 |
</children>
|
39 |
</catalog>
|
40 |
</admin>
|
@@ -52,7 +52,20 @@
|
|
52 |
<models>
|
53 |
<connector>
|
54 |
<class>DataFeedWatch_Connector_Model</class>
|
|
|
55 |
</connector>
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
56 |
</models>
|
57 |
<helpers>
|
58 |
<connector>
|
@@ -71,5 +84,34 @@
|
|
71 |
</setup>
|
72 |
</datafeedwatch_connector_setup>
|
73 |
</resources>
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
74 |
</global>
|
75 |
</config>
|
2 |
<config>
|
3 |
<modules>
|
4 |
<DataFeedWatch_Connector>
|
5 |
+
<version>0.2.18.12a</version>
|
6 |
</DataFeedWatch_Connector>
|
7 |
</modules>
|
8 |
<admin>
|
9 |
<routers>
|
10 |
+
<adminhtml>
|
|
|
11 |
<args>
|
12 |
+
<modules>
|
13 |
+
<connector after="Mage_Adminhtml">DataFeedWatch_Connector_Adminhtml</connector>
|
14 |
+
</modules>
|
15 |
</args>
|
16 |
+
</adminhtml>
|
17 |
</routers>
|
18 |
</admin>
|
19 |
<adminhtml>
|
20 |
<menu>
|
21 |
<catalog translate="title" module="adminhtml">
|
22 |
<children>
|
23 |
+
<connector translate="title" module="connector">
|
24 |
<title>DataFeedWatch</title>
|
25 |
+
<action>adminhtml/connectorsettings</action>
|
26 |
+
</connector>
|
27 |
</children>
|
28 |
</catalog>
|
29 |
</menu>
|
32 |
<admin>
|
33 |
<catalog>
|
34 |
<children>
|
35 |
+
<connector translate="title" module="connector">
|
36 |
<title>DataFeedWatch</title>
|
37 |
+
</connector>
|
38 |
</children>
|
39 |
</catalog>
|
40 |
</admin>
|
52 |
<models>
|
53 |
<connector>
|
54 |
<class>DataFeedWatch_Connector_Model</class>
|
55 |
+
<resourceModel>connector_resource</resourceModel>
|
56 |
</connector>
|
57 |
+
<connector_resource>
|
58 |
+
<class>DataFeedWatch_Connector_Model_Resource</class>
|
59 |
+
<deprecatedNode>connector_mysql4</deprecatedNode>
|
60 |
+
<entities>
|
61 |
+
<catalogrule_info>
|
62 |
+
<table>datafeedwatch_catalogrule_info</table>
|
63 |
+
</catalogrule_info>
|
64 |
+
<salesrule_info>
|
65 |
+
<table>datafeedwatch_salesrule_info</table>
|
66 |
+
</salesrule_info>
|
67 |
+
</entities>
|
68 |
+
</connector_resource>
|
69 |
</models>
|
70 |
<helpers>
|
71 |
<connector>
|
84 |
</setup>
|
85 |
</datafeedwatch_connector_setup>
|
86 |
</resources>
|
87 |
+
<events>
|
88 |
+
<catalogrule_rule_save_after>
|
89 |
+
<observers>
|
90 |
+
<datafeedwatch_connector_save_catalogrule_date>
|
91 |
+
<type>singleton</type>
|
92 |
+
<class>DataFeedWatch_Connector_Model_Observer</class>
|
93 |
+
<method>catalogruleRuleSaveAfter</method>
|
94 |
+
</datafeedwatch_connector_save_catalogrule_date>
|
95 |
+
</observers>
|
96 |
+
</catalogrule_rule_save_after>
|
97 |
+
<salesrule_rule_save_after>
|
98 |
+
<observers>
|
99 |
+
<datafeedwatch_connector_save_salesrule_date>
|
100 |
+
<type>singleton</type>
|
101 |
+
<class>DataFeedWatch_Connector_Model_Observer</class>
|
102 |
+
<method>salesruleRuleSaveAfter</method>
|
103 |
+
</datafeedwatch_connector_save_salesrule_date>
|
104 |
+
</observers>
|
105 |
+
</salesrule_rule_save_after>
|
106 |
+
<controller_action_postdispatch_adminhtml_promo_catalog_applyRules>
|
107 |
+
<observers>
|
108 |
+
<datafeedwatch_connector_applyAll_catalogrule_date>
|
109 |
+
<type>singleton</type>
|
110 |
+
<class>DataFeedWatch_Connector_Model_Observer</class>
|
111 |
+
<method>catalogruleRuleApplyAllAfter</method>
|
112 |
+
</datafeedwatch_connector_applyAll_catalogrule_date>
|
113 |
+
</observers>
|
114 |
+
</controller_action_postdispatch_adminhtml_promo_catalog_applyRules>
|
115 |
+
</events>
|
116 |
</global>
|
117 |
</config>
|
app/code/community/DataFeedWatch/Connector/sql/datafeedwatch_connector_setup/upgrade-0.2.10-0.2.11.ph
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.18-0.2.18.6.ph
ADDED
@@ -0,0 +1,72 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
$installer = $this;
|
3 |
+
/* @var $installer Mage_Core_Model_Resource_Setup */
|
4 |
+
$installer->startSetup();
|
5 |
+
|
6 |
+
// Add custom_hash for finding users
|
7 |
+
$catalogRuleInfoTable = $installer->getConnection()->newTable($installer->getTable('connector/catalogrule_info'))
|
8 |
+
->addColumn('catalogruleinfo_id', Varien_Db_Ddl_Table::TYPE_INTEGER, null, array(
|
9 |
+
'identity' => true,
|
10 |
+
'unsigned' => true,
|
11 |
+
'nullable' => false,
|
12 |
+
'primary' => true,
|
13 |
+
), 'CatalogRuleInfo ID')
|
14 |
+
->addColumn('catalogrule_id', Varien_Db_Ddl_Table::TYPE_INTEGER, null, array(
|
15 |
+
'unsigned' => true,
|
16 |
+
'nullable' => false,
|
17 |
+
'default' => '0',
|
18 |
+
), 'Catalog Rule ID')
|
19 |
+
->addColumn('updated_at', Varien_Db_Ddl_Table::TYPE_TIMESTAMP, null,
|
20 |
+
array(
|
21 |
+
'nullable' => true
|
22 |
+
), 'Updated At')
|
23 |
+
->addIndex($installer->getIdxName('connector/catalogrule_info', array('catalogrule_id'), Varien_Db_Adapter_Interface::INDEX_TYPE_UNIQUE),
|
24 |
+
array('catalogrule_id'), array('type' => Varien_Db_Adapter_Interface::INDEX_TYPE_UNIQUE))
|
25 |
+
->addIndex(
|
26 |
+
$installer->getIdxName('connector/catalogrule_info', array('updated_at')),
|
27 |
+
array('updated_at')
|
28 |
+
)
|
29 |
+
->addForeignKey(
|
30 |
+
$installer->getFkName('connector/catalogrule_info', 'role_id', 'catalogrule/rule', 'rule_id'),
|
31 |
+
'catalogrule_id',
|
32 |
+
Mage::getSingleton('core/resource')->getTableName('catalogrule/rule'),
|
33 |
+
'rule_id',
|
34 |
+
Varien_Db_Ddl_Table::ACTION_CASCADE,
|
35 |
+
Varien_Db_Ddl_Table::ACTION_CASCADE
|
36 |
+
)
|
37 |
+
->setComment('CatalogRule Info Table');
|
38 |
+
$installer->getConnection()->createTable($catalogRuleInfoTable);
|
39 |
+
|
40 |
+
|
41 |
+
$salesRuleInfoTable = $installer->getConnection()->newTable($installer->getTable('connector/salesrule_info'))
|
42 |
+
->addColumn('salesruleinfo_id', Varien_Db_Ddl_Table::TYPE_INTEGER, null, array(
|
43 |
+
'identity' => true,
|
44 |
+
'unsigned' => true,
|
45 |
+
'nullable' => false,
|
46 |
+
'primary' => true,
|
47 |
+
), 'SalesRuleInfo ID')
|
48 |
+
->addColumn('salesrule_id', Varien_Db_Ddl_Table::TYPE_INTEGER, null, array(
|
49 |
+
'unsigned' => true,
|
50 |
+
'nullable' => false,
|
51 |
+
'default' => '0',
|
52 |
+
), 'Sales Rule ID')
|
53 |
+
->addColumn('updated_at', Varien_Db_Ddl_Table::TYPE_TIMESTAMP, null,
|
54 |
+
array(
|
55 |
+
'nullable' => true
|
56 |
+
), 'Updated At')
|
57 |
+
->addIndex($installer->getIdxName('connector/salesrule_info', array('rule_id'), Varien_Db_Adapter_Interface::INDEX_TYPE_UNIQUE),
|
58 |
+
array('salesrule_id'), array('type' => Varien_Db_Adapter_Interface::INDEX_TYPE_UNIQUE))
|
59 |
+
->addIndex($installer->getIdxName('admin/role', array('updated_at')),
|
60 |
+
array('updated_at'))
|
61 |
+
->addForeignKey(
|
62 |
+
$installer->getFkName('connector/salesrule_info', 'salesrule_id', 'salesrule/rule', 'rule_id'),
|
63 |
+
'salesrule_id',
|
64 |
+
Mage::getSingleton('core/resource')->getTableName('salesrule/rule'),
|
65 |
+
'rule_id',
|
66 |
+
Varien_Db_Ddl_Table::ACTION_CASCADE,
|
67 |
+
Varien_Db_Ddl_Table::ACTION_CASCADE
|
68 |
+
)
|
69 |
+
->setComment('SalesRule Info Table');
|
70 |
+
$installer->getConnection()->createTable($salesRuleInfoTable);
|
71 |
+
|
72 |
+
$installer->endSetup();
|
app/code/community/DataFeedWatch/Connector/sql/datafeedwatch_connector_setup/upgrade-0.2.18-0.2.18.6.php
ADDED
@@ -0,0 +1,72 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
$installer = $this;
|
3 |
+
/* @var $installer Mage_Core_Model_Resource_Setup */
|
4 |
+
$installer->startSetup();
|
5 |
+
|
6 |
+
// Add custom_hash for finding users
|
7 |
+
$catalogRuleInfoTable = $installer->getConnection()->newTable($installer->getTable('connector/catalogrule_info'))
|
8 |
+
->addColumn('catalogruleinfo_id', Varien_Db_Ddl_Table::TYPE_INTEGER, null, array(
|
9 |
+
'identity' => true,
|
10 |
+
'unsigned' => true,
|
11 |
+
'nullable' => false,
|
12 |
+
'primary' => true,
|
13 |
+
), 'CatalogRuleInfo ID')
|
14 |
+
->addColumn('catalogrule_id', Varien_Db_Ddl_Table::TYPE_INTEGER, null, array(
|
15 |
+
'unsigned' => true,
|
16 |
+
'nullable' => false,
|
17 |
+
'default' => '0',
|
18 |
+
), 'Catalog Rule ID')
|
19 |
+
->addColumn('updated_at', Varien_Db_Ddl_Table::TYPE_TIMESTAMP, null,
|
20 |
+
array(
|
21 |
+
'nullable' => true
|
22 |
+
), 'Updated At')
|
23 |
+
->addIndex($installer->getIdxName('connector/catalogrule_info', array('catalogrule_id'), Varien_Db_Adapter_Interface::INDEX_TYPE_UNIQUE),
|
24 |
+
array('catalogrule_id'), array('type' => Varien_Db_Adapter_Interface::INDEX_TYPE_UNIQUE))
|
25 |
+
->addIndex(
|
26 |
+
$installer->getIdxName('connector/catalogrule_info', array('updated_at')),
|
27 |
+
array('updated_at')
|
28 |
+
)
|
29 |
+
->addForeignKey(
|
30 |
+
$installer->getFkName('connector/catalogrule_info', 'role_id', 'catalogrule/rule', 'rule_id'),
|
31 |
+
'catalogrule_id',
|
32 |
+
Mage::getSingleton('core/resource')->getTableName('catalogrule/rule'),
|
33 |
+
'rule_id',
|
34 |
+
Varien_Db_Ddl_Table::ACTION_CASCADE,
|
35 |
+
Varien_Db_Ddl_Table::ACTION_CASCADE
|
36 |
+
)
|
37 |
+
->setComment('CatalogRule Info Table');
|
38 |
+
$installer->getConnection()->createTable($catalogRuleInfoTable);
|
39 |
+
|
40 |
+
|
41 |
+
$salesRuleInfoTable = $installer->getConnection()->newTable($installer->getTable('connector/salesrule_info'))
|
42 |
+
->addColumn('salesruleinfo_id', Varien_Db_Ddl_Table::TYPE_INTEGER, null, array(
|
43 |
+
'identity' => true,
|
44 |
+
'unsigned' => true,
|
45 |
+
'nullable' => false,
|
46 |
+
'primary' => true,
|
47 |
+
), 'SalesRuleInfo ID')
|
48 |
+
->addColumn('salesrule_id', Varien_Db_Ddl_Table::TYPE_INTEGER, null, array(
|
49 |
+
'unsigned' => true,
|
50 |
+
'nullable' => false,
|
51 |
+
'default' => '0',
|
52 |
+
), 'Sales Rule ID')
|
53 |
+
->addColumn('updated_at', Varien_Db_Ddl_Table::TYPE_TIMESTAMP, null,
|
54 |
+
array(
|
55 |
+
'nullable' => true
|
56 |
+
), 'Updated At')
|
57 |
+
->addIndex($installer->getIdxName('connector/salesrule_info', array('rule_id'), Varien_Db_Adapter_Interface::INDEX_TYPE_UNIQUE),
|
58 |
+
array('salesrule_id'), array('type' => Varien_Db_Adapter_Interface::INDEX_TYPE_UNIQUE))
|
59 |
+
->addIndex($installer->getIdxName('admin/role', array('updated_at')),
|
60 |
+
array('updated_at'))
|
61 |
+
->addForeignKey(
|
62 |
+
$installer->getFkName('connector/salesrule_info', 'salesrule_id', 'salesrule/rule', 'rule_id'),
|
63 |
+
'salesrule_id',
|
64 |
+
Mage::getSingleton('core/resource')->getTableName('salesrule/rule'),
|
65 |
+
'rule_id',
|
66 |
+
Varien_Db_Ddl_Table::ACTION_CASCADE,
|
67 |
+
Varien_Db_Ddl_Table::ACTION_CASCADE
|
68 |
+
)
|
69 |
+
->setComment('SalesRule Info Table');
|
70 |
+
$installer->getConnection()->createTable($salesRuleInfoTable);
|
71 |
+
|
72 |
+
$installer->endSetup();
|
app/code/community/DataFeedWatch/Connector/sql/datafeedwatch_connector_setup/upgrade-0.2.9-0.2.10.ph
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/layout/connector.xml
CHANGED
@@ -1,6 +1,6 @@
|
|
1 |
<?xml version="1.0"?>
|
2 |
<layout version="0.1.0">
|
3 |
-
<
|
4 |
<reference name="head">
|
5 |
<action method="addItem">
|
6 |
<type>skin_js</type>
|
@@ -14,5 +14,5 @@
|
|
14 |
<reference name="content">
|
15 |
<block type="connector/adminhtml_settings_edit" name="settings"/>
|
16 |
</reference>
|
17 |
-
</
|
18 |
</layout>
|
1 |
<?xml version="1.0"?>
|
2 |
<layout version="0.1.0">
|
3 |
+
<adminhtml_connectorsettings_index>
|
4 |
<reference name="head">
|
5 |
<action method="addItem">
|
6 |
<type>skin_js</type>
|
14 |
<reference name="content">
|
15 |
<block type="connector/adminhtml_settings_edit" name="settings"/>
|
16 |
</reference>
|
17 |
+
</adminhtml_connectorsettings_index>
|
18 |
</layout>
|
app/etc/modules/DataFeedWatch_Connector.xml
CHANGED
@@ -6,6 +6,8 @@
|
|
6 |
<codePool>community</codePool>
|
7 |
<depends>
|
8 |
<Mage_Api />
|
|
|
|
|
9 |
</depends>
|
10 |
</DataFeedWatch_Connector>
|
11 |
</modules>
|
6 |
<codePool>community</codePool>
|
7 |
<depends>
|
8 |
<Mage_Api />
|
9 |
+
<Mage_CatalogRule/>
|
10 |
+
<Mage_SalesRule/>
|
11 |
</depends>
|
12 |
</DataFeedWatch_Connector>
|
13 |
</modules>
|
package.xml
CHANGED
@@ -1,19 +1,19 @@
|
|
1 |
<?xml version="1.0"?>
|
2 |
<package>
|
3 |
<name>DataFeedWatch_Connector</name>
|
4 |
-
<version>0.2.
|
5 |
-
<stability>
|
6 |
-
<license uri="
|
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
|
11 |
</description>
|
12 |
-
<notes>DataFeedWatch Release version 0.2.
|
13 |
-
<authors><author><name>DataFeedWatch</name><user>
|
14 |
-
<date>2015-
|
15 |
-
<time>
|
16 |
-
<contents><target name="magecommunity"><dir name="DataFeedWatch"><dir name="Connector"><dir name="Block"><dir name="Adminhtml"><file name="Connectorbackend.php" hash="e5b1e0824f6f8a0131cb9df7c43ed1e6"/><dir name="Settings"><dir name="Edit"><file name="Form.php" hash="
|
17 |
<compatible/>
|
18 |
-
<dependencies><required><php><min>5.
|
19 |
</package>
|
1 |
<?xml version="1.0"?>
|
2 |
<package>
|
3 |
<name>DataFeedWatch_Connector</name>
|
4 |
+
<version>0.2.18.12</version>
|
5 |
+
<stability>devel</stability>
|
6 |
+
<license uri="https://opensource.org/licenses/OSL-3.0">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
|
11 |
</description>
|
12 |
+
<notes>DataFeedWatch Release version 0.2.18.12a with SUPEE-6788 admin fix</notes>
|
13 |
+
<authors><author><name>DataFeedWatch</name><user>WordWatch</user><email>support@datafeedwatch.com</email></author></authors>
|
14 |
+
<date>2015-11-17</date>
|
15 |
+
<time>13:47:16</time>
|
16 |
+
<contents><target name="magecommunity"><dir name="DataFeedWatch"><dir name="Connector"><dir><dir name="Block"><dir name="Adminhtml"><file name="Connectorbackend.php" hash="e5b1e0824f6f8a0131cb9df7c43ed1e6"/><dir name="Settings"><dir name="Edit"><file name="Form.php" hash="0c45d4958ce54ab628954ac6bd33d9fd"/></dir><file name="Edit.php" hash="06a86343380547f2da83e610d4494d12"/></dir></dir></dir><dir name="Helper"><file name="Data.php" hash="79bf96679344cf581a5f8f9e4ddc2dd9"/></dir><dir name="Model"><dir name="Catalogrule"><dir name="Info"><file name="Collection.php" hash="b8920aeaa92fd18d1b6e3a73acbfab65"/></dir><file name="Info.php" hash="2ebd6a5518b8648cddd869fca691f769"/></dir><dir name="Datafeedwatch"><file name="Api.php" hash="d2ee16c3430424c5bc1ff31d4d20bdeb"/></dir><file name="Observer.php" hash="a00cf47b5e27b957183b18491421f536"/><dir name="Resource"><dir name="Catalogrule"><dir name="Info"><file name="Collection.php" hash="b8920aeaa92fd18d1b6e3a73acbfab65"/></dir><file name="Info.php" hash="3e16299f467bb84d3b48d20032f3467e"/></dir><dir name="Salesrule"><dir name="Info"><file name="Collection.php" hash="b6cd6a5f19a0c99e19a1688246cdc9a9"/></dir><file name="Info.php" hash="253ed05c71352b4a707bfa8592ee42c9"/></dir><file name="Setup.php" hash="0367daf07ad69fd53e39c7b81e24be07"/></dir><dir name="Salesrule"><dir name="Info"><file name="Collection.php" hash="b6cd6a5f19a0c99e19a1688246cdc9a9"/></dir><file name="Info.php" hash="200e06dcd82934da31af541f43eb5435"/></dir></dir><dir name="controllers"><dir name="Adminhtml"><file name="ConnectorsettingsController.php" hash="7c31c6c49826d79403ddd2061b4591c9"/></dir></dir><dir name="etc"><file name="api.xml" hash="8d542985773a3120280678349227a4a3"/><file name="config.xml" hash="b3ff9526f984e967bc9c308345d35cb6"/><file name="system.xml" hash="ab5e8d56d032ba69c930ab7879484212"/></dir><dir name="sql"><dir name="datafeedwatch_connector_setup"><file name="install-0.2.9.php" hash="326a2968b7af5a987604f880ed7c4a3c"/><file name="upgrade-0.2.10-0.2.11.ph" hash="9dcefa5cafd7efd8f192af4d9c1f0c2e"/><file name="upgrade-0.2.10-0.2.11.php" hash="9dcefa5cafd7efd8f192af4d9c1f0c2e"/><file name="upgrade-0.2.18-0.2.18.6.ph" hash="01aa13d9de38c46e91fb90f79c790da4"/><file name="upgrade-0.2.18-0.2.18.6.php" hash="01aa13d9de38c46e91fb90f79c790da4"/><file name="upgrade-0.2.9-0.2.10.ph" hash="c9e575e9925df8440eca5aa817c1d5e4"/><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="c33ecbe7c4dcfd7c68fade80c7bf40c3"/></dir></dir></dir></dir></target><target name="mageetc"><dir name="modules"><file name="DataFeedWatch_Connector.xml" hash="0794fc14d8eefe9cd8168cc1250ad48b"/></dir></target><target name="mageskin"><dir name="adminhtml"><dir name="default"><dir name="default"><dir name="js"><dir name="connector"><file name="connector.js" hash="a4018ca934e589a6cc6014463b3fa24a"/></dir></dir><file name="connector.css" hash="15d63fea8a6b3bd0befcd326ecda3642"/></dir></dir></dir></target></contents>
|
17 |
<compatible/>
|
18 |
+
<dependencies><required><php><min>5.3.0</min><max>7.0.0</max></php></required></dependencies>
|
19 |
</package>
|