Version Notes
DataFeedWatch - Release version 0.3.0
Download this release
Release Info
Developer | WordWatch |
Extension | DataFeedWatch_Connector |
Version | 0.3 |
Comparing to | |
See all releases |
Code changes from version 0.2.18.12 to 0.3
- .gitignore +1 -0
- app/code/community/DataFeedWatch/Connector/Block/Adminhtml/Connectorbackend.php +0 -32
- app/code/community/DataFeedWatch/Connector/Block/Adminhtml/Settings/Edit.php +0 -34
- app/code/community/DataFeedWatch/Connector/Block/Adminhtml/Settings/Edit/Form.php +0 -75
- app/code/community/DataFeedWatch/Connector/Block/Adminhtml/System/Config/Form/Button/Add.php +25 -0
- app/code/community/DataFeedWatch/Connector/Block/Adminhtml/System/Config/Form/Button/Extort.php +25 -0
- app/code/community/DataFeedWatch/Connector/Block/Adminhtml/System/Config/Form/Button/Open.php +25 -0
- app/code/community/DataFeedWatch/Connector/Block/Adminhtml/System/Config/Form/Button/Refresh.php +25 -0
- app/code/community/DataFeedWatch/Connector/Block/Adminhtml/System/Config/Form/Button/Restore.php +25 -0
- app/code/community/DataFeedWatch/Connector/Block/Adminhtml/System/Config/Form/Grid/Inheritance.php +15 -0
- app/code/community/DataFeedWatch/Connector/Block/Adminhtml/System/Config/Grid.php +29 -0
- app/code/community/DataFeedWatch/Connector/Block/Adminhtml/System/Config/Grid/Items.php +64 -0
- app/code/community/DataFeedWatch/Connector/Block/Adminhtml/System/Config/Grid/Items/Row.php +54 -0
- app/code/community/DataFeedWatch/Connector/Block/Adminhtml/System/Config/Grid/Pager.php +69 -0
- app/code/community/DataFeedWatch/Connector/Helper/Data.php +157 -977
- app/code/community/DataFeedWatch/Connector/Helper/Registry.php +154 -0
- app/code/community/DataFeedWatch/Connector/Model/Api.php +351 -0
- app/code/community/DataFeedWatch/Connector/Model/Api/User.php +112 -0
- app/code/community/DataFeedWatch/Connector/Model/Catalog/Attribute/Info.php +121 -0
- app/code/community/DataFeedWatch/Connector/Model/Catalogrule/Info.php +0 -8
- app/code/community/DataFeedWatch/Connector/Model/Catalogrule/Info/Collection.php +0 -8
- app/code/community/DataFeedWatch/Connector/Model/Cron.php +64 -0
- app/code/community/DataFeedWatch/Connector/Model/Datafeedwatch/Api.php +0 -532
- app/code/community/DataFeedWatch/Connector/Model/Observer.php +210 -35
- app/code/community/DataFeedWatch/Connector/Model/Product.php +415 -0
- app/code/community/DataFeedWatch/Connector/Model/Resource/Catalog/Attribute/Info.php +10 -0
- app/code/community/DataFeedWatch/Connector/Model/Resource/Catalog/Attribute/Info/Collection.php +10 -0
- app/code/community/DataFeedWatch/Connector/Model/Resource/Catalogrule/Info.php +0 -8
- app/code/community/DataFeedWatch/Connector/Model/Resource/Catalogrule/Info/Collection.php +0 -8
- app/code/community/DataFeedWatch/Connector/Model/Resource/Product.php +7 -0
- app/code/community/DataFeedWatch/Connector/Model/Resource/Product/Collection.php +222 -0
- app/code/community/DataFeedWatch/Connector/Model/Resource/Product/Collection/Db.php +306 -0
- app/code/community/DataFeedWatch/Connector/Model/Resource/Salesrule/Info.php +0 -8
- app/code/community/DataFeedWatch/Connector/Model/Resource/Salesrule/Info/Collection.php +0 -7
- app/code/community/DataFeedWatch/Connector/Model/Resource/Setup.php +0 -5
- app/code/community/DataFeedWatch/Connector/Model/Salesrule/Info.php +0 -8
- app/code/community/DataFeedWatch/Connector/Model/Salesrule/Info/Collection.php +0 -7
- app/code/community/DataFeedWatch/Connector/Model/System/Config/Source/Inheritance.php +55 -0
- app/code/community/DataFeedWatch/Connector/controllers/Adminhtml/ConnectorsettingsController.php +0 -160
- app/code/community/DataFeedWatch/Connector/controllers/Adminhtml/DatafeedwatchController.php +121 -0
- app/code/community/DataFeedWatch/Connector/data/datafeedwatch_connector_setup/data-upgrade-0.2.40-0.2.50.php +48 -0
- app/code/community/DataFeedWatch/Connector/etc/adminhtml.xml +40 -0
- app/code/community/DataFeedWatch/Connector/etc/api.xml +18 -21
- app/code/community/DataFeedWatch/Connector/etc/config.xml +164 -88
- app/code/community/DataFeedWatch/Connector/etc/system.xml +104 -7
- app/code/community/DataFeedWatch/Connector/sql/datafeedwatch_connector_setup/install-0.2.9.php +0 -13
- app/code/community/DataFeedWatch/Connector/sql/datafeedwatch_connector_setup/upgrade-0.2.10-0.2.11.ph +0 -9
- app/code/community/DataFeedWatch/Connector/sql/datafeedwatch_connector_setup/upgrade-0.2.10-0.2.11.php +0 -9
- app/code/community/DataFeedWatch/Connector/sql/datafeedwatch_connector_setup/upgrade-0.2.18-0.2.18.6.ph +0 -72
- app/code/community/DataFeedWatch/Connector/sql/datafeedwatch_connector_setup/upgrade-0.2.18-0.2.18.6.php +0 -72
- app/code/community/DataFeedWatch/Connector/sql/datafeedwatch_connector_setup/upgrade-0.2.40-0.2.50.php +84 -0
- app/code/community/DataFeedWatch/Connector/sql/datafeedwatch_connector_setup/upgrade-0.2.9-0.2.10.ph +0 -6
- app/code/community/DataFeedWatch/Connector/sql/datafeedwatch_connector_setup/upgrade-0.2.9-0.2.10.php +0 -6
- app/design/adminhtml/default/default/layout/connector.xml +0 -18
- app/design/adminhtml/default/default/layout/datafeedwatch/connector.xml +22 -0
- app/design/adminhtml/default/default/template/datafeedwatch/connector/grid.phtml +17 -0
- app/design/adminhtml/default/default/template/datafeedwatch/connector/grid/items.phtml +6 -0
- app/design/adminhtml/default/default/template/datafeedwatch/connector/grid/items/row.phtml +57 -0
- app/design/adminhtml/default/default/template/datafeedwatch/connector/grid/pager.phtml +54 -0
- app/etc/modules/DataFeedWatch_Connector.xml +2 -3
- app/locale/en_US/DataFeedWatch_Connector.csv +41 -0
- app/locale/pl_PL/DataFeedWatch_Connector.csv +41 -0
- package.xml +7 -8
- skin/adminhtml/default/default/connector.css +0 -3
- skin/adminhtml/default/default/datafeedwatch/connector/css/grid/inheritance.css +13 -0
- skin/adminhtml/default/default/datafeedwatch/connector/js/grid/inheritance.js +41 -0
- skin/adminhtml/default/default/js/connector/connector.js +0 -17
.gitignore
ADDED
@@ -0,0 +1 @@
|
|
|
1 |
+
.idea/
|
app/code/community/DataFeedWatch/Connector/Block/Adminhtml/Connectorbackend.php
DELETED
@@ -1,32 +0,0 @@
|
|
1 |
-
<?php
|
2 |
-
|
3 |
-
class DataFeedWatch_Connector_Block_Adminhtml_Connectorbackend extends Mage_Adminhtml_Block_Template {
|
4 |
-
protected $email = 'magento@datafeedwatch.com';
|
5 |
-
private static $instance = null;
|
6 |
-
|
7 |
-
public function __construct() {
|
8 |
-
parent::__construct();
|
9 |
-
$this->assign('user', $this->getUser());
|
10 |
-
}
|
11 |
-
|
12 |
-
public function getCreateUserUrl() {
|
13 |
-
return $this->getUrl('*/*/createuser');
|
14 |
-
}
|
15 |
-
|
16 |
-
public function getUser() {
|
17 |
-
$model = Mage::getModel('api/user');
|
18 |
-
return $model->load($this->email, 'email');
|
19 |
-
}
|
20 |
-
|
21 |
-
public function getRedirectUrl() {
|
22 |
-
return $this->getUrl('*/*/redirect');
|
23 |
-
}
|
24 |
-
public static function getInstance()
|
25 |
-
{
|
26 |
-
if (self::$instance == null) {
|
27 |
-
self::$instance = new self;
|
28 |
-
}
|
29 |
-
|
30 |
-
return self::$instance;
|
31 |
-
}
|
32 |
-
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
app/code/community/DataFeedWatch/Connector/Block/Adminhtml/Settings/Edit.php
DELETED
@@ -1,34 +0,0 @@
|
|
1 |
-
<?php
|
2 |
-
|
3 |
-
class DataFeedWatch_Connector_Block_Adminhtml_Settings_Edit extends Mage_Adminhtml_Block_Widget_Form_Container{
|
4 |
-
|
5 |
-
public function __construct()
|
6 |
-
{
|
7 |
-
parent::__construct();
|
8 |
-
$this->_objectId = 'id';
|
9 |
-
$this->_blockGroup = 'connector';
|
10 |
-
$this->_controller = 'adminhtml_settings';
|
11 |
-
$this->_mode = 'edit';
|
12 |
-
|
13 |
-
$user = Mage::getModel('api/user')->load('datafeedwatch','username');
|
14 |
-
|
15 |
-
if ($user->isObjectNew()) {
|
16 |
-
$linkUrl = DataFeedWatch_Connector_Block_Adminhtml_Connectorbackend::getInstance()->getCreateUserUrl();
|
17 |
-
} else {
|
18 |
-
$linkUrl = DataFeedWatch_Connector_Block_Adminhtml_Connectorbackend::getInstance()->getRedirectUrl();
|
19 |
-
}
|
20 |
-
|
21 |
-
$this->removeButton('reset');
|
22 |
-
$this->removeButton('back');
|
23 |
-
|
24 |
-
$this->addButton('goToMyDataFeedWatch', array(
|
25 |
-
'label' => $this->__('Go to my DataFeedWatch'),
|
26 |
-
'onclick' => "setLocation('$linkUrl')",
|
27 |
-
));
|
28 |
-
}
|
29 |
-
public function getHeaderText()
|
30 |
-
{
|
31 |
-
return Mage::helper('connector')->__('DataFeedWatch Settings');
|
32 |
-
}
|
33 |
-
|
34 |
-
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
app/code/community/DataFeedWatch/Connector/Block/Adminhtml/Settings/Edit/Form.php
DELETED
@@ -1,75 +0,0 @@
|
|
1 |
-
<?php
|
2 |
-
|
3 |
-
class DataFeedWatch_Connector_Block_Adminhtml_Settings_Edit_Form extends Mage_Adminhtml_Block_Widget_Form{
|
4 |
-
|
5 |
-
protected function _prepareForm()
|
6 |
-
{
|
7 |
-
|
8 |
-
$form = new Varien_Data_Form(array(
|
9 |
-
'id' => 'edit_form',
|
10 |
-
'method' => 'post'
|
11 |
-
));
|
12 |
-
|
13 |
-
$form->setUseContainer(true);
|
14 |
-
|
15 |
-
$this->setForm($form);
|
16 |
-
|
17 |
-
$fieldset = $form->addFieldset('attributes', array(
|
18 |
-
'legend' =>Mage::helper('connector')->__('Select Attributes')
|
19 |
-
));
|
20 |
-
|
21 |
-
$data = array();
|
22 |
-
|
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"),
|
53 |
-
"required" => false,
|
54 |
-
"options" => $required,
|
55 |
-
"name" => "required_attributes[]",
|
56 |
-
"disabled" => array_keys($required),
|
57 |
-
"ignore" => true
|
58 |
-
));
|
59 |
-
|
60 |
-
$attributesList = array('0_all'=>'Select/Unselect all');
|
61 |
-
|
62 |
-
$attributesList = array_merge($attributesList,Mage::helper('connector')->getAttributesList());
|
63 |
-
|
64 |
-
$fieldset->addField('additional_attributes', 'checkboxes',array(
|
65 |
-
"label" => Mage::helper('connector')->__("Optional Attributes"),
|
66 |
-
"required" => false,
|
67 |
-
"options" => $attributesList,
|
68 |
-
"name" => "additional_attributes[]"
|
69 |
-
));
|
70 |
-
|
71 |
-
$form->setValues($data);
|
72 |
-
|
73 |
-
return parent::_prepareForm();
|
74 |
-
}
|
75 |
-
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
app/code/community/DataFeedWatch/Connector/Block/Adminhtml/System/Config/Form/Button/Add.php
ADDED
@@ -0,0 +1,25 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
|
3 |
+
class DataFeedWatch_Connector_Block_Adminhtml_System_Config_Form_Button_Add
|
4 |
+
extends Mage_Adminhtml_Block_System_Config_Form_Field
|
5 |
+
{
|
6 |
+
/**
|
7 |
+
* @param Varien_Data_Form_Element_Abstract $element
|
8 |
+
* @return mixed
|
9 |
+
* @throws Exception
|
10 |
+
*/
|
11 |
+
protected function _getElementHtml(Varien_Data_Form_Element_Abstract $element)
|
12 |
+
{
|
13 |
+
$url = Mage::helper('adminhtml')->getUrl('adminhtml/datafeedwatch/addStore');
|
14 |
+
$onclick = sprintf("window.open('%s', '_blank')", $url);
|
15 |
+
$html = $this->getLayout()
|
16 |
+
->createBlock('adminhtml/widget_button')
|
17 |
+
->setType('button')
|
18 |
+
->setClass('scalable')
|
19 |
+
->setLabel($this->__('Add Store'))
|
20 |
+
->setOnClick($onclick)
|
21 |
+
->toHtml();
|
22 |
+
|
23 |
+
return $html;
|
24 |
+
}
|
25 |
+
}
|
app/code/community/DataFeedWatch/Connector/Block/Adminhtml/System/Config/Form/Button/Extort.php
ADDED
@@ -0,0 +1,25 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
|
3 |
+
class DataFeedWatch_Connector_Block_Adminhtml_System_Config_Form_Button_Extort
|
4 |
+
extends Mage_Adminhtml_Block_System_Config_Form_Field
|
5 |
+
{
|
6 |
+
/**
|
7 |
+
* @param Varien_Data_Form_Element_Abstract $element
|
8 |
+
* @return mixed
|
9 |
+
* @throws Exception
|
10 |
+
*/
|
11 |
+
protected function _getElementHtml(Varien_Data_Form_Element_Abstract $element)
|
12 |
+
{
|
13 |
+
$url = Mage::helper('adminhtml')->getUrl('adminhtml/datafeedwatch/extort');
|
14 |
+
$onclick = sprintf("setLocation('%s')", $url);
|
15 |
+
$html = $this->getLayout()
|
16 |
+
->createBlock('adminhtml/widget_button')
|
17 |
+
->setType('button')
|
18 |
+
->setClass('scalable')
|
19 |
+
->setLabel($this->__('Get All'))
|
20 |
+
->setOnClick($onclick)
|
21 |
+
->toHtml();
|
22 |
+
|
23 |
+
return $html;
|
24 |
+
}
|
25 |
+
}
|
app/code/community/DataFeedWatch/Connector/Block/Adminhtml/System/Config/Form/Button/Open.php
ADDED
@@ -0,0 +1,25 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
|
3 |
+
class DataFeedWatch_Connector_Block_Adminhtml_System_Config_Form_Button_Open
|
4 |
+
extends Mage_Adminhtml_Block_System_Config_Form_Field
|
5 |
+
{
|
6 |
+
/**
|
7 |
+
* @param Varien_Data_Form_Element_Abstract $element
|
8 |
+
* @return mixed
|
9 |
+
* @throws Exception
|
10 |
+
*/
|
11 |
+
protected function _getElementHtml(Varien_Data_Form_Element_Abstract $element)
|
12 |
+
{
|
13 |
+
$url = Mage::helper('adminhtml')->getUrl('adminhtml/datafeedwatch/open');
|
14 |
+
$onclick = sprintf("window.open('%s', '_blank')", $url);
|
15 |
+
$html = $this->getLayout()
|
16 |
+
->createBlock('adminhtml/widget_button')
|
17 |
+
->setType('button')
|
18 |
+
->setClass('scalable')
|
19 |
+
->setLabel($this->__('Open'))
|
20 |
+
->setOnClick($onclick)
|
21 |
+
->toHtml();
|
22 |
+
|
23 |
+
return $html;
|
24 |
+
}
|
25 |
+
}
|
app/code/community/DataFeedWatch/Connector/Block/Adminhtml/System/Config/Form/Button/Refresh.php
ADDED
@@ -0,0 +1,25 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
|
3 |
+
class DataFeedWatch_Connector_Block_Adminhtml_System_Config_Form_Button_Refresh
|
4 |
+
extends Mage_Adminhtml_Block_System_Config_Form_Field
|
5 |
+
{
|
6 |
+
/**
|
7 |
+
* @param Varien_Data_Form_Element_Abstract $element
|
8 |
+
* @return mixed
|
9 |
+
* @throws Exception
|
10 |
+
*/
|
11 |
+
protected function _getElementHtml(Varien_Data_Form_Element_Abstract $element)
|
12 |
+
{
|
13 |
+
$url = Mage::helper('adminhtml')->getUrl('adminhtml/datafeedwatch/refresh');
|
14 |
+
$onclick = sprintf("setLocation('%s')", $url);
|
15 |
+
$html = $this->getLayout()
|
16 |
+
->createBlock('adminhtml/widget_button')
|
17 |
+
->setType('button')
|
18 |
+
->setClass('scalable')
|
19 |
+
->setLabel($this->__('Refresh'))
|
20 |
+
->setOnClick($onclick)
|
21 |
+
->toHtml();
|
22 |
+
|
23 |
+
return $html;
|
24 |
+
}
|
25 |
+
}
|
app/code/community/DataFeedWatch/Connector/Block/Adminhtml/System/Config/Form/Button/Restore.php
ADDED
@@ -0,0 +1,25 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
|
3 |
+
class DataFeedWatch_Connector_Block_Adminhtml_System_Config_Form_Button_Restore
|
4 |
+
extends Mage_Adminhtml_Block_System_Config_Form_Field
|
5 |
+
{
|
6 |
+
/**
|
7 |
+
* @param Varien_Data_Form_Element_Abstract $element
|
8 |
+
* @return mixed
|
9 |
+
* @throws Exception
|
10 |
+
*/
|
11 |
+
protected function _getElementHtml(Varien_Data_Form_Element_Abstract $element)
|
12 |
+
{
|
13 |
+
$url = Mage::helper('adminhtml')->getUrl('adminhtml/datafeedwatch/restoreOriginalAttributeConfig');
|
14 |
+
$onclick = sprintf("setLocation('%s')", $url);
|
15 |
+
$html = $this->getLayout()
|
16 |
+
->createBlock('adminhtml/widget_button')
|
17 |
+
->setType('button')
|
18 |
+
->setClass('scalable')
|
19 |
+
->setLabel($this->__('Restore'))
|
20 |
+
->setOnClick($onclick)
|
21 |
+
->toHtml();
|
22 |
+
|
23 |
+
return $html;
|
24 |
+
}
|
25 |
+
}
|
app/code/community/DataFeedWatch/Connector/Block/Adminhtml/System/Config/Form/Grid/Inheritance.php
ADDED
@@ -0,0 +1,15 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
|
3 |
+
class DataFeedWatch_Connector_Block_Adminhtml_System_Config_Form_Grid_Inheritance
|
4 |
+
extends Mage_Adminhtml_Block_System_Config_Form_Field
|
5 |
+
{
|
6 |
+
/**
|
7 |
+
* @param Varien_Data_Form_Element_Abstract $element
|
8 |
+
* @return mixed
|
9 |
+
* @throws Exception
|
10 |
+
*/
|
11 |
+
protected function _getElementHtml(Varien_Data_Form_Element_Abstract $element)
|
12 |
+
{
|
13 |
+
return $this->getLayout()->getBlock('datafeedwatch_connector_inheritance_grid')->toHtml();
|
14 |
+
}
|
15 |
+
}
|
app/code/community/DataFeedWatch/Connector/Block/Adminhtml/System/Config/Grid.php
ADDED
@@ -0,0 +1,29 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
|
3 |
+
class DataFeedWatch_Connector_Block_Adminhtml_System_Config_Grid
|
4 |
+
extends Mage_Adminhtml_Block_Abstract
|
5 |
+
{
|
6 |
+
/**
|
7 |
+
* @return string
|
8 |
+
*/
|
9 |
+
public function getActionUrl()
|
10 |
+
{
|
11 |
+
return Mage::helper('adminhtml')->getUrl('adminhtml/datafeedwatch/renderInheritanceGrid');
|
12 |
+
}
|
13 |
+
|
14 |
+
/**
|
15 |
+
* @return string
|
16 |
+
*/
|
17 |
+
public function getSaveInheritanceActionUrl()
|
18 |
+
{
|
19 |
+
return Mage::helper('adminhtml')->getUrl('adminhtml/datafeedwatch/saveAttributeInheritance');
|
20 |
+
}
|
21 |
+
|
22 |
+
/**
|
23 |
+
* @return string
|
24 |
+
*/
|
25 |
+
public function getSaveImportActionUrl()
|
26 |
+
{
|
27 |
+
return Mage::helper('adminhtml')->getUrl('adminhtml/datafeedwatch/saveAttributeImport');
|
28 |
+
}
|
29 |
+
}
|
app/code/community/DataFeedWatch/Connector/Block/Adminhtml/System/Config/Grid/Items.php
ADDED
@@ -0,0 +1,64 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
|
3 |
+
class DataFeedWatch_Connector_Block_Adminhtml_System_Config_Grid_Items
|
4 |
+
extends Mage_Adminhtml_Block_Abstract
|
5 |
+
{
|
6 |
+
/**
|
7 |
+
* @param Mage_Catalog_Model_Resource_Eav_Attribute $attribute
|
8 |
+
* @return string
|
9 |
+
*/
|
10 |
+
public function getItemRow($attribute)
|
11 |
+
{
|
12 |
+
return $this->getChild('datafeedwatch_connector_inheritance_grid_items_row')->setAttributeItem($attribute)->toHtml();
|
13 |
+
}
|
14 |
+
|
15 |
+
/**
|
16 |
+
* @return Mage_Catalog_Model_Resource_Product_Attribute_Collection
|
17 |
+
*/
|
18 |
+
public function getCollection()
|
19 |
+
{
|
20 |
+
return $this->getPager()->getCollection();
|
21 |
+
}
|
22 |
+
|
23 |
+
/**
|
24 |
+
* @param int $page
|
25 |
+
* @return DataFeedWatch_Connector_Block_Adminhtml_System_Config_Grid_Items $this
|
26 |
+
*/
|
27 |
+
public function setPage($page)
|
28 |
+
{
|
29 |
+
if (!empty($page)) {
|
30 |
+
$this->getPager()->setPage($page);
|
31 |
+
}
|
32 |
+
|
33 |
+
return $this;
|
34 |
+
}
|
35 |
+
|
36 |
+
/**
|
37 |
+
* @param int $limit
|
38 |
+
* @return DataFeedWatch_Connector_Block_Adminhtml_System_Config_Grid_Items $this
|
39 |
+
*/
|
40 |
+
public function setLimit($limit)
|
41 |
+
{
|
42 |
+
if (!empty($limit)) {
|
43 |
+
$this->getPager()->setLimit($limit);
|
44 |
+
}
|
45 |
+
|
46 |
+
return $this;
|
47 |
+
}
|
48 |
+
|
49 |
+
/**
|
50 |
+
* @return string
|
51 |
+
*/
|
52 |
+
public function getPagerHtml()
|
53 |
+
{
|
54 |
+
return $this->getPager()->toHtml();
|
55 |
+
}
|
56 |
+
|
57 |
+
/**
|
58 |
+
* @return DataFeedWatch_Connector_Block_Adminhtml_System_Config_Grid_Pager
|
59 |
+
*/
|
60 |
+
public function getPager()
|
61 |
+
{
|
62 |
+
return $this->getChild('datafeedwatch_connector_inheritance_grid_pager');
|
63 |
+
}
|
64 |
+
}
|
app/code/community/DataFeedWatch/Connector/Block/Adminhtml/System/Config/Grid/Items/Row.php
ADDED
@@ -0,0 +1,54 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
|
3 |
+
class DataFeedWatch_Connector_Block_Adminhtml_System_Config_Grid_Items_Row
|
4 |
+
extends Mage_Adminhtml_Block_Abstract
|
5 |
+
{
|
6 |
+
/** @var Mage_Catalog_Model_Resource_Eav_Attribute $attributeItem */
|
7 |
+
public $attributeItem;
|
8 |
+
|
9 |
+
/**
|
10 |
+
* @param Mage_Catalog_Model_Resource_Eav_Attribute $attribute
|
11 |
+
* @return DataFeedWatch_Connector_Block_Adminhtml_System_Config_Grid_Items_Row $this
|
12 |
+
*/
|
13 |
+
public function setAttributeItem($attribute)
|
14 |
+
{
|
15 |
+
$this->attributeItem = $attribute;
|
16 |
+
|
17 |
+
return $this;
|
18 |
+
}
|
19 |
+
|
20 |
+
/**
|
21 |
+
* @return Mage_Catalog_Model_Resource_Eav_Attribute
|
22 |
+
*/
|
23 |
+
public function getAttributeItem()
|
24 |
+
{
|
25 |
+
return $this->attributeItem;
|
26 |
+
}
|
27 |
+
|
28 |
+
/**
|
29 |
+
* @return string
|
30 |
+
*/
|
31 |
+
public function getAttributeLabel()
|
32 |
+
{
|
33 |
+
$attribute = $this->getAttributeItem();
|
34 |
+
$label = $attribute->getFrontendLabel();
|
35 |
+
|
36 |
+
if (empty($label)) {
|
37 |
+
$label = $attribute->getAttributeCode();
|
38 |
+
}
|
39 |
+
|
40 |
+
return $label;
|
41 |
+
}
|
42 |
+
|
43 |
+
/**
|
44 |
+
* @return mixed
|
45 |
+
*/
|
46 |
+
public function getAttributeLink()
|
47 |
+
{
|
48 |
+
$attribute = $this->getAttributeItem();
|
49 |
+
|
50 |
+
return Mage::helper('adminhtml')->getUrl('adminhtml/catalog_product_attribute/edit', array(
|
51 |
+
'attribute_id' => $attribute->getId(),
|
52 |
+
));
|
53 |
+
}
|
54 |
+
}
|
app/code/community/DataFeedWatch/Connector/Block/Adminhtml/System/Config/Grid/Pager.php
ADDED
@@ -0,0 +1,69 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
|
3 |
+
class DataFeedWatch_Connector_Block_Adminhtml_System_Config_Grid_Pager
|
4 |
+
extends Mage_Adminhtml_Block_Abstract
|
5 |
+
{
|
6 |
+
public $page = 1;
|
7 |
+
public $limit = 10;
|
8 |
+
/**
|
9 |
+
* @return Mage_Catalog_Model_Resource_Product_Attribute_Collection
|
10 |
+
*/
|
11 |
+
public function getCollection()
|
12 |
+
{
|
13 |
+
$attributeCollection = Mage::getResourceModel('catalog/product_attribute_collection')
|
14 |
+
->addVisibleFilter()
|
15 |
+
->setPageSize($this->limit)
|
16 |
+
->setCurPage($this->page);
|
17 |
+
$attributeCollection->getSelect()->joinLeft(
|
18 |
+
array('cai' => Mage::getModel('core/resource')
|
19 |
+
->getTableName('datafeedwatch_connector/catalog_attribute_info')),
|
20 |
+
'cai.catalog_attribute_id = main_table.attribute_id'
|
21 |
+
)
|
22 |
+
->where('cai.can_configure_inheritance != 0 and cai.import_to_dfw != 0 or cai.can_configure_inheritance = 1');
|
23 |
+
$attributeCollection->setOrder('frontend_label', 'asc');
|
24 |
+
|
25 |
+
return $attributeCollection;
|
26 |
+
}
|
27 |
+
|
28 |
+
/**
|
29 |
+
* @param int $page
|
30 |
+
* @return DataFeedWatch_Connector_Block_Adminhtml_System_Config_Grid_Pager $this
|
31 |
+
*/
|
32 |
+
public function setPage($page)
|
33 |
+
{
|
34 |
+
if (!empty($page) && is_numeric($page)) {
|
35 |
+
$this->page = $page;
|
36 |
+
}
|
37 |
+
|
38 |
+
return $this;
|
39 |
+
}
|
40 |
+
|
41 |
+
/**
|
42 |
+
* @return int
|
43 |
+
*/
|
44 |
+
public function getPage()
|
45 |
+
{
|
46 |
+
return (int)$this->page;
|
47 |
+
}
|
48 |
+
|
49 |
+
/**
|
50 |
+
* @param int $limit
|
51 |
+
* @return DataFeedWatch_Connector_Block_Adminhtml_System_Config_Grid_Pager $this
|
52 |
+
*/
|
53 |
+
public function setLimit($limit)
|
54 |
+
{
|
55 |
+
if (!empty($limit) && is_numeric($limit)) {
|
56 |
+
$this->limit = $limit;
|
57 |
+
}
|
58 |
+
|
59 |
+
return $this;
|
60 |
+
}
|
61 |
+
|
62 |
+
/**
|
63 |
+
* @return int
|
64 |
+
*/
|
65 |
+
public function getLimit()
|
66 |
+
{
|
67 |
+
return (int)$this->limit;
|
68 |
+
}
|
69 |
+
}
|
app/code/community/DataFeedWatch/Connector/Helper/Data.php
CHANGED
@@ -1,1049 +1,229 @@
|
|
1 |
<?php
|
2 |
-
class DataFeedWatch_Connector_Helper_Data extends Mage_Core_Helper_Abstract
|
3 |
-
{
|
4 |
-
|
5 |
-
private $_categories;
|
6 |
-
private $_storeCategories;
|
7 |
-
|
8 |
-
private $_required_attributes = array(
|
9 |
-
"product_id",
|
10 |
-
"sku",
|
11 |
-
"product_type",
|
12 |
-
"parent_id",
|
13 |
-
"parent_sku",
|
14 |
-
"parent_url",
|
15 |
-
"name",
|
16 |
-
"description",
|
17 |
-
"short_description",
|
18 |
-
"weight",
|
19 |
-
"status",
|
20 |
-
"visibility",
|
21 |
-
"country_of_manufacture",
|
22 |
-
"price",
|
23 |
-
"special_price",
|
24 |
-
"special_from_date",
|
25 |
-
"special_to_date",
|
26 |
-
"tax_class_id",
|
27 |
-
"meta_title",
|
28 |
-
"meta_keyword",
|
29 |
-
"meta_description",
|
30 |
-
"gift_wrapping_available",
|
31 |
-
"gift_wrapping_price",
|
32 |
-
"color",
|
33 |
-
"occasion",
|
34 |
-
"apparel_type",
|
35 |
-
"sleeve_length",
|
36 |
-
"fit",
|
37 |
-
"size",
|
38 |
-
"length",
|
39 |
-
"gender",
|
40 |
-
"product_url",
|
41 |
-
"image_url",
|
42 |
-
"price_with_tax",
|
43 |
-
"special_price_with_tax",
|
44 |
-
"additional_image_url1",
|
45 |
-
"additional_image_url2",
|
46 |
-
"quantity",
|
47 |
-
"is_in_stock",
|
48 |
-
'msrp_enabled',
|
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(
|
57 |
-
'type' => 0,
|
58 |
-
'type_id' => 0,
|
59 |
-
'set' => 0,
|
60 |
-
'categories' => 0,
|
61 |
-
'websites' => 0,
|
62 |
-
'old_id' => 0,
|
63 |
-
'news_from_date' => 0,
|
64 |
-
'news_to_date' => 0,
|
65 |
-
'category_ids' => 0,
|
66 |
-
'required_options' => 0,
|
67 |
-
'has_options' => 0,
|
68 |
-
'image_label' => 0,
|
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,
|
76 |
-
'is_recurring' => 0,
|
77 |
-
'recurring_profile' => 0,
|
78 |
-
'custom_design' => 0,
|
79 |
-
'custom_design_from' => 0,
|
80 |
-
'custom_design_to' => 0,
|
81 |
-
'custom_layout_update' => 0,
|
82 |
-
'page_layout' => 0,
|
83 |
-
'options_container' => 0,
|
84 |
-
'gift_message_available' => 0,
|
85 |
-
'url_key' => 0,
|
86 |
-
'url_path' => 0,
|
87 |
-
'image' => 0,
|
88 |
-
'small_image' => 0,
|
89 |
-
'media_gallery' => 0,
|
90 |
-
'gallery' => 0,
|
91 |
-
'entity_type_id' => 0,
|
92 |
-
'attribute_set_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 |
-
|
110 |
-
|
111 |
-
|
112 |
-
|
113 |
-
|
114 |
-
|
115 |
-
|
116 |
-
|
117 |
-
|
118 |
-
|
119 |
-
|
120 |
-
|
121 |
-
|
122 |
-
if(!in_array($attribute->getAttributeCode(),$this->_required_attributes)){
|
123 |
-
$attributesList[$attribute->getAttributeCode()] = $attribute->getAttributeCode();
|
124 |
-
}
|
125 |
-
}
|
126 |
-
return $attributesList;
|
127 |
-
}
|
128 |
|
129 |
/**
|
130 |
-
*
|
131 |
-
*
|
132 |
-
* @param null|object|array $filters
|
133 |
-
* @param array $fieldsMap Map of field names in format: array('field_name_in_filter' => 'field_name_in_db')
|
134 |
-
* @return array
|
135 |
*/
|
136 |
-
public function
|
137 |
{
|
138 |
-
|
139 |
-
if (is_object($filters)) {
|
140 |
-
$parsedFilters = array();
|
141 |
-
// parse simple filter
|
142 |
-
if (isset($filters->filter) && is_array($filters->filter)) {
|
143 |
-
foreach ($filters->filter as $field => $value) {
|
144 |
-
if (is_object($value) && isset($value->key) && isset($value->value)) {
|
145 |
-
$parsedFilters[$value->key] = $value->value;
|
146 |
-
} else {
|
147 |
-
$parsedFilters[$field] = $value;
|
148 |
-
}
|
149 |
-
}
|
150 |
-
}
|
151 |
-
// parse complex filter
|
152 |
-
if (isset($filters->complex_filter) && is_array($filters->complex_filter)) {
|
153 |
-
$parsedFilters += $this->_parseComplexFilterReplacement($filters->complex_filter);
|
154 |
-
}
|
155 |
-
|
156 |
-
$filters = $parsedFilters;
|
157 |
-
}
|
158 |
-
// make sure that method result is always array
|
159 |
-
if (!is_array($filters)) {
|
160 |
-
$filters = array();
|
161 |
-
}
|
162 |
-
// apply fields mapping
|
163 |
-
if (isset($fieldsMap) && is_array($fieldsMap)) {
|
164 |
-
foreach ($filters as $field => $value) {
|
165 |
-
if (isset($fieldsMap[$field])) {
|
166 |
-
unset($filters[$field]);
|
167 |
-
$field = $fieldsMap[$field];
|
168 |
-
$filters[$field] = $value;
|
169 |
-
}
|
170 |
-
}
|
171 |
-
}
|
172 |
-
return $filters;
|
173 |
}
|
174 |
|
175 |
/**
|
176 |
-
*
|
177 |
-
* between two dates.
|
178 |
-
*
|
179 |
-
* @param array $complexFilter
|
180 |
-
* @return array
|
181 |
*/
|
182 |
-
|
183 |
{
|
184 |
-
|
185 |
-
|
186 |
-
foreach ($complexFilter as $filter) {
|
187 |
-
if (!isset($filter->key) || !isset($filter->value)) {
|
188 |
-
continue;
|
189 |
-
}
|
190 |
-
|
191 |
-
list($fieldName, $condition) = array($filter->key, $filter->value);
|
192 |
-
$conditionName = $condition->key;
|
193 |
-
$conditionValue = $condition->value;
|
194 |
-
$this->formatFilterConditionValueReplacement($conditionName, $conditionValue);
|
195 |
-
|
196 |
-
if (array_key_exists($fieldName, $parsedFilters)) {
|
197 |
-
$parsedFilters[$fieldName] += array($conditionName => $conditionValue);
|
198 |
-
} else {
|
199 |
-
$parsedFilters[$fieldName] = array($conditionName => $conditionValue);
|
200 |
-
}
|
201 |
-
}
|
202 |
-
|
203 |
-
return $parsedFilters;
|
204 |
}
|
205 |
|
206 |
/**
|
207 |
-
*
|
208 |
-
* for the condition operators that require value to be an array.
|
209 |
-
* Condition value is changed by reference
|
210 |
-
*
|
211 |
-
* @param string $conditionOperator
|
212 |
-
* @param string $conditionValue
|
213 |
*/
|
214 |
-
public function
|
215 |
{
|
216 |
-
|
217 |
-
&& is_string($conditionValue)
|
218 |
-
) {
|
219 |
-
$delimiter = ',';
|
220 |
-
$conditionValue = explode($delimiter, $conditionValue);
|
221 |
-
}
|
222 |
}
|
223 |
|
224 |
-
|
|
|
|
|
|
|
225 |
{
|
226 |
-
|
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 |
-
*
|
245 |
-
* @return array
|
246 |
-
* @throws Mage_Core_Exception
|
247 |
*/
|
248 |
-
public function
|
249 |
{
|
250 |
-
|
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 */
|
265 |
-
$tree = Mage::getResourceSingleton('catalog/category_tree')->load();
|
266 |
-
$root = $tree->getNodeById($parentId);
|
267 |
-
|
268 |
-
if ($root && $root->getId() == 1) {
|
269 |
-
$root->setName(Mage::helper('catalog')->__('Root'));
|
270 |
-
}
|
271 |
-
|
272 |
-
$collection = Mage::getModel('catalog/category')->getCollection()
|
273 |
-
->addAttributeToSelect('name')
|
274 |
-
->addAttributeToSelect('is_active');
|
275 |
-
|
276 |
-
$tree->addCollectionData($collection, true);
|
277 |
-
|
278 |
-
return $this->_nodeToArray($root);
|
279 |
}
|
280 |
|
281 |
/**
|
282 |
-
*
|
283 |
-
*
|
284 |
-
* @param Varien_Data_Tree_Node $node
|
285 |
-
* @return array
|
286 |
*/
|
287 |
-
|
288 |
{
|
289 |
-
|
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 |
-
|
316 |
-
|
|
|
|
|
|
|
|
|
317 |
}
|
318 |
|
319 |
-
public function
|
320 |
{
|
321 |
-
$
|
322 |
-
|
323 |
-
$prices['description'] = $product->getDescription();
|
324 |
-
$prices['short_description'] = $product->getShortDescription();
|
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();
|
340 |
-
foreach ($attributes as $attribute) {
|
341 |
-
|
342 |
-
//only fetch if this is not excluded field
|
343 |
-
if (!array_key_exists($attribute->getAttributeCode(), Mage::helper('connector')->getExcludedAttributes())) {
|
344 |
-
$value = $product->getData($attribute->getAttributeCode());
|
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 |
-
}
|
355 |
-
}
|
356 |
-
|
357 |
-
return $prices;
|
358 |
}
|
359 |
|
360 |
/**
|
361 |
-
* @param $
|
362 |
-
* @param $product_result array
|
363 |
-
* @param $parent_product Mage_Catalog_Model_Product
|
364 |
-
* @return array
|
365 |
*/
|
366 |
-
public function
|
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 {
|
432 |
-
$index++;
|
433 |
-
}
|
434 |
-
}
|
435 |
-
}
|
436 |
-
|
437 |
-
return $product_result;
|
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) {
|
458 |
-
if ($images->getUrl() != $product_result['image_url']) {
|
459 |
-
$product_result['additional_image_url' . $i++] = $images->getUrl();
|
460 |
-
}
|
461 |
-
}
|
462 |
-
}
|
463 |
-
return $product_result;
|
464 |
-
}
|
465 |
-
|
466 |
-
public function addExcludedImagesToResult($product,$product_result)
|
467 |
{
|
468 |
-
$
|
469 |
-
|
470 |
-
$i = 1;
|
471 |
-
foreach ($allImages as $image) {
|
472 |
-
if ($image['disabled']) {
|
473 |
-
$excludedUrl = (string)$product->getMediaConfig()->getMediaUrl($image['file']);
|
474 |
-
$product_result['image_url_excluded'.$i++] = $excludedUrl;
|
475 |
-
}
|
476 |
-
}
|
477 |
-
|
478 |
-
return $product_result;
|
479 |
-
}
|
480 |
-
|
481 |
-
private function prepareCurrencyRates(){
|
482 |
-
if($this->_currencyRates===null) {
|
483 |
-
$store_code = Mage::app()->getStore()->getCode();
|
484 |
-
// Get Currency Code
|
485 |
-
$this->_bas_curncy_code = Mage::app()->getStore()->getBaseCurrencyCode();
|
486 |
-
$this->_cur_curncy_code = Mage::app()->getStore($store_code)->getCurrentCurrencyCode();
|
487 |
-
|
488 |
-
$this->_allowedCurrencies = Mage::getModel('directory/currency')
|
489 |
-
->getConfigAllowCurrencies();
|
490 |
-
$this->_currencyRates = Mage::getModel('directory/currency')
|
491 |
-
->getCurrencyRates($this->_bas_curncy_code, array_values($this->_allowedCurrencies));
|
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 |
-
}
|
520 |
-
|
521 |
-
if ($this->_bas_curncy_code != $this->_cur_curncy_code
|
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);
|
532 |
-
}
|
533 |
-
|
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 |
-
|
578 |
-
|
579 |
-
|
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 |
-
|
600 |
-
public function getRewrittenProductUrl($productObject, $categoryId, $storeId)
|
601 |
{
|
602 |
-
$
|
603 |
-
$rewrite = Mage::getSingleton('core/url_rewrite');
|
604 |
-
$idPath = sprintf('product/%d', $productId);
|
605 |
-
if ($categoryId) {
|
606 |
-
$idPath = sprintf('%s/%d', $idPath, $categoryId);
|
607 |
-
}
|
608 |
-
$rewrite->loadByIdPath($idPath);
|
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 |
-
*
|
693 |
-
* @param $product Mage_Catalog_Model_Product
|
694 |
-
* @return float|null
|
695 |
*/
|
696 |
-
public function
|
697 |
-
|
698 |
-
|
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 $
|
764 |
-
* @param $
|
765 |
-
* @param $attributes
|
766 |
-
* @return mixed
|
767 |
*/
|
768 |
-
public function
|
769 |
-
|
770 |
-
|
771 |
-
|
772 |
-
$
|
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 |
-
|
841 |
-
|
842 |
-
|
843 |
-
|
844 |
-
|
845 |
-
|
846 |
-
|
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 |
-
|
878 |
-
|
879 |
-
|
880 |
-
|
881 |
-
$
|
882 |
-
|
883 |
-
|
884 |
-
|
885 |
-
|
886 |
-
|
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 |
-
*
|
922 |
*/
|
923 |
-
|
924 |
-
|
925 |
-
|
926 |
-
return false;
|
927 |
-
}
|
928 |
-
return true;
|
929 |
}
|
930 |
|
931 |
-
public function
|
932 |
-
|
933 |
-
$
|
934 |
-
|
935 |
-
|
936 |
-
|
937 |
-
|
938 |
-
|
939 |
-
|
940 |
-
|
941 |
-
|
942 |
-
|
943 |
-
|
944 |
-
|
945 |
-
|
946 |
-
|
947 |
-
|
948 |
-
|
949 |
-
|
950 |
-
|
951 |
-
|
952 |
-
|
953 |
-
|
954 |
-
|
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 |
-
|
990 |
-
|
991 |
-
|
992 |
-
|
993 |
-
|
994 |
-
|
995 |
-
|
996 |
-
|
997 |
-
|
998 |
-
|
999 |
-
|
1000 |
-
|
1001 |
-
|
1002 |
-
}
|
1003 |
-
}
|
1004 |
-
}
|
1005 |
-
}
|
1006 |
|
1007 |
-
|
1008 |
-
|
1009 |
-
|
1010 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1011 |
|
1012 |
-
|
1013 |
-
|
1014 |
-
|
1015 |
-
|
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 |
-
|
1026 |
-
$promotionAffectedProducts = array_values(array_unique($promotionAffectedProducts));
|
1027 |
-
foreach ($promotionAffectedProducts as $productId) {
|
1028 |
-
/* Add to fetchlist */
|
1029 |
-
$fetchList[] = (int)$productId;
|
1030 |
|
1031 |
-
|
1032 |
-
|
1033 |
-
|
1034 |
-
|
1035 |
-
|
1036 |
-
|
1037 |
-
foreach ($childProducts as $child) {
|
1038 |
-
$fetchList[] = $child->getId();
|
1039 |
-
}
|
1040 |
-
}
|
1041 |
-
}
|
1042 |
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1043 |
}
|
1044 |
|
1045 |
-
|
|
|
1046 |
}
|
1047 |
-
|
1048 |
-
}
|
1049 |
-
|
1 |
<?php
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
2 |
|
3 |
+
class DataFeedWatch_Connector_Helper_Data
|
4 |
+
extends Mage_Core_Helper_Abstract
|
5 |
+
{
|
6 |
+
const MY_DATA_FEED_WATCH_URL = 'https://my.datafeedwatch.com/';
|
7 |
+
const LOG_DIR_NAME = 'DataFeedWatch_Connector';
|
8 |
+
const API_LOG_DIR_NAME = 'api';
|
9 |
+
const SQL_LOG_DIR_NAME = 'sql';
|
10 |
+
const CRON_LOG_DIR_NAME = 'cron';
|
11 |
+
const DEBUG_XPATH = 'datafeedwatch_connector/general/debug';
|
12 |
+
const PRODUCT_URL_CUSTOM_INHERITANCE_XPATH = 'datafeedwatch_connector/custom_inheritance/product_url';
|
13 |
+
const IMAGE_URL_CUSTOM_INHERITANCE_XPATH = 'datafeedwatch_connector/custom_inheritance/image_url';
|
14 |
+
const LAST_CATALOGRULE_PRICE_ID_XPATH = 'datafeedwatch_connector/custom_inheritance/last_catalogrule_price_id';
|
15 |
+
const LAST_INHERITANCE_UPDATE_XPATH = 'datafeedwatch_connector/custom_inheritance/last_inheritance_update';
|
|
|
|
|
|
|
|
|
|
|
|
|
16 |
|
17 |
/**
|
18 |
+
* @return bool
|
|
|
|
|
|
|
|
|
19 |
*/
|
20 |
+
public function isDebugModeEnabled()
|
21 |
{
|
22 |
+
return Mage::getStoreConfigFlag(self::DEBUG_XPATH);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
23 |
}
|
24 |
|
25 |
/**
|
26 |
+
* @return bool
|
|
|
|
|
|
|
|
|
27 |
*/
|
28 |
+
public function isProductUrlInherited()
|
29 |
{
|
30 |
+
return Mage::getStoreConfigFlag(self::PRODUCT_URL_CUSTOM_INHERITANCE_XPATH);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
31 |
}
|
32 |
|
33 |
/**
|
34 |
+
* @return bool
|
|
|
|
|
|
|
|
|
|
|
35 |
*/
|
36 |
+
public function isImageUrlInherited()
|
37 |
{
|
38 |
+
return Mage::getStoreConfigFlag(self::IMAGE_URL_CUSTOM_INHERITANCE_XPATH);
|
|
|
|
|
|
|
|
|
|
|
39 |
}
|
40 |
|
41 |
+
/**
|
42 |
+
* @return string
|
43 |
+
*/
|
44 |
+
public function getLastCatalogRulePriceId()
|
45 |
{
|
46 |
+
return Mage::getStoreConfig(self::LAST_CATALOGRULE_PRICE_ID_XPATH);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
47 |
}
|
48 |
|
49 |
/**
|
50 |
+
* @param string|int $id
|
|
|
|
|
51 |
*/
|
52 |
+
public function setLastCatalogRulePriceId($id)
|
53 |
{
|
54 |
+
Mage::getModel('core/config')->saveConfig(self::LAST_CATALOGRULE_PRICE_ID_XPATH, $id);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
55 |
}
|
56 |
|
57 |
/**
|
58 |
+
* @return string
|
|
|
|
|
|
|
59 |
*/
|
60 |
+
public function getLastInheritanceUpdateDate()
|
61 |
{
|
62 |
+
return Mage::getStoreConfig(self::LAST_INHERITANCE_UPDATE_XPATH);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
63 |
}
|
64 |
|
65 |
+
/**
|
66 |
+
* @param string $date
|
67 |
+
*/
|
68 |
+
public function setLastInheritanceUpdateDate($date)
|
69 |
+
{
|
70 |
+
Mage::getModel('core/config')->saveConfig(self::LAST_INHERITANCE_UPDATE_XPATH, $date)->reinit();
|
71 |
}
|
72 |
|
73 |
+
public function updateLastInheritanceUpdateDate()
|
74 |
{
|
75 |
+
$this->setLastInheritanceUpdateDate(date('Y-m-d H:i:s'));
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
76 |
}
|
77 |
|
78 |
/**
|
79 |
+
* @param mixed $message
|
|
|
|
|
|
|
80 |
*/
|
81 |
+
public function log($message)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
82 |
{
|
83 |
+
$this->logToFile($message, self::API_LOG_DIR_NAME);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
84 |
}
|
85 |
|
86 |
+
/**
|
87 |
+
* @param mixed $message
|
88 |
+
*/
|
89 |
+
public function sqlLog($message)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
90 |
{
|
91 |
+
$this->logToFile($message, self::SQL_LOG_DIR_NAME);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
92 |
}
|
93 |
|
94 |
/**
|
95 |
+
* @param mixed $message
|
|
|
|
|
96 |
*/
|
97 |
+
public function cronLog($message)
|
98 |
+
{
|
99 |
+
$this->logToFile($message, self::CRON_LOG_DIR_NAME);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
100 |
}
|
101 |
|
102 |
/**
|
103 |
+
* @param string $message
|
104 |
+
* @param string $type
|
|
|
|
|
105 |
*/
|
106 |
+
public function logToFile($message, $type)
|
107 |
+
{
|
108 |
+
if ($this->isDebugModeEnabled()) {
|
109 |
+
$this->createLogFileDir($type);
|
110 |
+
$fileName = $this->getLogFilePath($type);
|
111 |
+
Mage::log($message, null, $fileName, true);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
112 |
}
|
|
|
|
|
|
|
113 |
}
|
114 |
|
115 |
+
/**
|
116 |
+
* @param string $type
|
117 |
+
* @return string
|
118 |
+
*/
|
119 |
+
public function getLogFilePath($type)
|
120 |
+
{
|
121 |
+
return self::LOG_DIR_NAME. DS . $type . DS . sprintf('%s.log', date('Y-m-d'));
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
122 |
}
|
123 |
|
124 |
+
/**
|
125 |
+
* @param string $type
|
126 |
+
*/
|
127 |
+
public function createLogFileDir($type) {
|
128 |
+
$dir = Mage::getBaseDir('var') . DS . 'log' . DS . self::LOG_DIR_NAME . DS . $type . DS;
|
129 |
+
if (!file_exists($dir)) {
|
130 |
+
try {
|
131 |
+
mkdir($dir, 0775, true);
|
132 |
+
} catch (Exception $e) {
|
133 |
+
Mage::log($e->getMessage());
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
134 |
}
|
135 |
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
136 |
}
|
137 |
|
138 |
/**
|
139 |
+
* @return string
|
140 |
*/
|
141 |
+
public function getDataFeedWatchUrl()
|
142 |
+
{
|
143 |
+
return self::MY_DATA_FEED_WATCH_URL;
|
|
|
|
|
|
|
144 |
}
|
145 |
|
146 |
+
public function restoreOriginalAttributesConfig()
|
147 |
+
{
|
148 |
+
$cannotConfigureImportField = array(
|
149 |
+
'name',
|
150 |
+
'description',
|
151 |
+
'short_description',
|
152 |
+
'tax_class_id',
|
153 |
+
'visibility',
|
154 |
+
'status',
|
155 |
+
'meta_title',
|
156 |
+
'meta_keyword',
|
157 |
+
'meta_description',
|
158 |
+
'media_gallery',
|
159 |
+
'image',
|
160 |
+
'small_image',
|
161 |
+
'thumbnail',
|
162 |
+
'price',
|
163 |
+
'special_price',
|
164 |
+
'special_from_date',
|
165 |
+
'special_to_date',
|
166 |
+
'sku',
|
167 |
+
'updated_at',
|
168 |
+
'ignore_datafeedwatch',
|
169 |
+
);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
170 |
|
171 |
+
$cannotConfigureInheritanceField = array(
|
172 |
+
'sku',
|
173 |
+
'price',
|
174 |
+
'special_price',
|
175 |
+
'special_from_date',
|
176 |
+
'special_to_date',
|
177 |
+
'media_gallery',
|
178 |
+
'image',
|
179 |
+
'small_image',
|
180 |
+
'thumbnail',
|
181 |
+
'updated_at',
|
182 |
+
'ignore_datafeedwatch',
|
183 |
+
);
|
|
|
|
|
|
|
|
|
184 |
|
185 |
+
$enableImport = array(
|
186 |
+
'name',
|
187 |
+
'description',
|
188 |
+
'short_description',
|
189 |
+
'tax_class_id',
|
190 |
+
'visibility',
|
191 |
+
'status',
|
192 |
+
'meta_title',
|
193 |
+
'meta_keyword',
|
194 |
+
'meta_description',
|
195 |
+
'sku',
|
196 |
+
'price',
|
197 |
+
'special_price',
|
198 |
+
'special_from_date',
|
199 |
+
'special_to_date',
|
200 |
+
'updated_at',
|
201 |
+
);
|
202 |
|
203 |
+
$inheritanceData = array(
|
204 |
+
'updated_at' => DataFeedWatch_Connector_Model_System_Config_Source_Inheritance::PARENT_OPTION_ID,
|
205 |
+
'ignore_datafeedwatch' => DataFeedWatch_Connector_Model_System_Config_Source_Inheritance::CHILD_OPTION_ID,
|
206 |
+
);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
207 |
|
208 |
+
Mage::getResourceModel('datafeedwatch_connector/catalog_attribute_info_collection')->walk('delete');
|
|
|
|
|
|
|
|
|
209 |
|
210 |
+
$attributes = Mage::getResourceModel('catalog/product_attribute_collection')->addVisibleFilter();
|
211 |
+
foreach ($attributes as $attribute) {
|
212 |
+
$attributeCode = $attribute->getAttributeCode();
|
213 |
+
$inheritance = DataFeedWatch_Connector_Model_System_Config_Source_Inheritance::CHILD_OPTION_ID;
|
214 |
+
if (array_key_exists($attributeCode, $inheritanceData)) {
|
215 |
+
$inheritance = $inheritanceData[$attributeCode];
|
|
|
|
|
|
|
|
|
|
|
216 |
}
|
217 |
+
Mage::getModel('datafeedwatch_connector/catalog_attribute_info')
|
218 |
+
->setCatalogAttributeId($attribute->getId())
|
219 |
+
->setImportToDfw(in_array($attributeCode, $enableImport))
|
220 |
+
->setCanConfigureImport(!in_array($attributeCode, $cannotConfigureImportField))
|
221 |
+
->setCanConfigureInheritance(!in_array($attributeCode, $cannotConfigureInheritanceField))
|
222 |
+
->setInheritance($inheritance)
|
223 |
+
->save();
|
224 |
}
|
225 |
|
226 |
+
Mage::getModel('core/config')->saveConfig('datafeedwatch_connector/custom_inheritance/product_url', 1);
|
227 |
+
Mage::getModel('core/config')->saveConfig('datafeedwatch_connector/custom_inheritance/image_url', 0);
|
228 |
}
|
229 |
+
}
|
|
|
|
app/code/community/DataFeedWatch/Connector/Helper/Registry.php
ADDED
@@ -0,0 +1,154 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
|
3 |
+
class DataFeedWatch_Connector_Helper_Registry
|
4 |
+
extends Mage_Core_Helper_Abstract
|
5 |
+
{
|
6 |
+
const ALL_CATEGORIES_ARRAY_KEY = 'all_categories_array';
|
7 |
+
const ALL_SUPER_ATTRIBUTES_KEY = 'all_super_attributes_array';
|
8 |
+
const ALL_IMPORTABLE_ATTRIBUTES_KEY = 'all_importable_attributes';
|
9 |
+
const ALL_ATTRIBUTE_COLLECTION_KEY = 'all_attribute_collection';
|
10 |
+
const DFW_STATUS_ATTRIBUTE_KEY = 'dfw_status_attribute';
|
11 |
+
const DFW_UPDATED_AT_ATTRIBUTE_KEY = 'dfw_updated_at_attribute';
|
12 |
+
const DFW_VISIBILITY_ATTRIBUTE_KEY = 'dfw_visibility_at_attribute';
|
13 |
+
|
14 |
+
/**
|
15 |
+
* @param string $storeId
|
16 |
+
*/
|
17 |
+
public function initImportRegistry($storeId)
|
18 |
+
{
|
19 |
+
$this->registerCategories($storeId);
|
20 |
+
$this->registerStatusAttribute();
|
21 |
+
$this->registerUpdatedAtAttribute();
|
22 |
+
$this->registerVisibilityAttribute();
|
23 |
+
$this->registerSuperAttributes();
|
24 |
+
$this->registerInheritableAttributes();
|
25 |
+
$this->registerAttributeCollection();
|
26 |
+
}
|
27 |
+
/**
|
28 |
+
* @param string $storeId
|
29 |
+
*/
|
30 |
+
protected function registerCategories($storeId)
|
31 |
+
{
|
32 |
+
$registry = Mage::registry(self::ALL_CATEGORIES_ARRAY_KEY);
|
33 |
+
if (empty($registry)) {
|
34 |
+
$categories = Mage::getResourceModel('catalog/category_collection')
|
35 |
+
->addNameToResult()
|
36 |
+
->setStoreId($storeId)
|
37 |
+
->addFieldToFilter('level', array('gt' => 0))
|
38 |
+
->getItems();
|
39 |
+
|
40 |
+
Mage::register(self::ALL_CATEGORIES_ARRAY_KEY, $categories);
|
41 |
+
}
|
42 |
+
}
|
43 |
+
|
44 |
+
protected function registerSuperAttributes()
|
45 |
+
{
|
46 |
+
$registry = Mage::registry(self::ALL_SUPER_ATTRIBUTES_KEY);
|
47 |
+
if (empty($registry)) {
|
48 |
+
$superAttributes = Mage::getResourceModel('catalog/product_attribute_collection')
|
49 |
+
->addVisibleFilter()
|
50 |
+
->getItems();
|
51 |
+
Mage::register(self::ALL_SUPER_ATTRIBUTES_KEY, $superAttributes);
|
52 |
+
}
|
53 |
+
}
|
54 |
+
|
55 |
+
protected function registerInheritableAttributes()
|
56 |
+
{
|
57 |
+
$registry = Mage::registry(self::ALL_IMPORTABLE_ATTRIBUTES_KEY);
|
58 |
+
if (empty($registry)) {
|
59 |
+
$importableAttributes = Mage::getResourceModel('catalog/product_attribute_collection')
|
60 |
+
->addVisibleFilter()
|
61 |
+
->addFieldToFilter('import_to_dfw', 1);
|
62 |
+
Mage::register(self::ALL_IMPORTABLE_ATTRIBUTES_KEY, $importableAttributes);
|
63 |
+
}
|
64 |
+
}
|
65 |
+
|
66 |
+
protected function registerAttributeCollection()
|
67 |
+
{
|
68 |
+
$registry = Mage::registry(self::ALL_ATTRIBUTE_COLLECTION_KEY);
|
69 |
+
if (empty($registry)) {
|
70 |
+
$attributeCollection = Mage::getResourceModel('catalog/product_attribute_collection')->addVisibleFilter();
|
71 |
+
foreach ($attributeCollection as $key => $attribute) {
|
72 |
+
if (!$this->isAttributeInheritable($attribute) || !$this->isAttributeImportable($attribute)) {
|
73 |
+
$attributeCollection->removeItemByKey($key);
|
74 |
+
}
|
75 |
+
}
|
76 |
+
Mage::register(self::ALL_ATTRIBUTE_COLLECTION_KEY, $attributeCollection);
|
77 |
+
}
|
78 |
+
}
|
79 |
+
|
80 |
+
protected function registerStatusAttribute()
|
81 |
+
{
|
82 |
+
$registry = Mage::registry(self::DFW_STATUS_ATTRIBUTE_KEY);
|
83 |
+
if (empty($registry)) {
|
84 |
+
/** @var Mage_Catalog_Model_Resource_Eav_Attribute $statusAttribute */
|
85 |
+
$statusAttribute = Mage::getResourceModel('catalog/product_attribute_collection')
|
86 |
+
->addVisibleFilter()
|
87 |
+
->addFieldToFilter('attribute_code', 'status')->getFirstItem();
|
88 |
+
Mage::register(self::DFW_STATUS_ATTRIBUTE_KEY, $statusAttribute);
|
89 |
+
}
|
90 |
+
}
|
91 |
+
|
92 |
+
/**
|
93 |
+
* @return bool
|
94 |
+
*/
|
95 |
+
public function isStatusAttributeInheritable()
|
96 |
+
{
|
97 |
+
return $this->isAttributeInheritable(Mage::registry(self::DFW_STATUS_ATTRIBUTE_KEY));
|
98 |
+
}
|
99 |
+
|
100 |
+
protected function registerUpdatedAtAttribute()
|
101 |
+
{
|
102 |
+
$registry = Mage::registry(self::DFW_UPDATED_AT_ATTRIBUTE_KEY);
|
103 |
+
if (empty($registry)) {
|
104 |
+
/** @var Mage_Catalog_Model_Resource_Eav_Attribute $statusAttribute */
|
105 |
+
$updatedAtAttribute = Mage::getResourceModel('catalog/product_attribute_collection')
|
106 |
+
->addVisibleFilter()
|
107 |
+
->addFieldToFilter('attribute_code', 'updated_at')->getFirstItem();
|
108 |
+
Mage::register(self::DFW_UPDATED_AT_ATTRIBUTE_KEY, $updatedAtAttribute);
|
109 |
+
}
|
110 |
+
}
|
111 |
+
|
112 |
+
protected function registerVisibilityAttribute()
|
113 |
+
{
|
114 |
+
$registry = Mage::registry(self::DFW_VISIBILITY_ATTRIBUTE_KEY);
|
115 |
+
if (empty($registry)) {
|
116 |
+
/** @var Mage_Catalog_Model_Resource_Eav_Attribute $statusAttribute */
|
117 |
+
$visibilityAttribute = Mage::getResourceModel('catalog/product_attribute_collection')
|
118 |
+
->addVisibleFilter()
|
119 |
+
->addFieldToFilter('attribute_code', 'visibility')->getFirstItem();
|
120 |
+
Mage::register(self::DFW_VISIBILITY_ATTRIBUTE_KEY, $visibilityAttribute);
|
121 |
+
}
|
122 |
+
}
|
123 |
+
|
124 |
+
/**
|
125 |
+
* @return bool
|
126 |
+
*/
|
127 |
+
public function isUpdatedAtAttributeInheritable()
|
128 |
+
{
|
129 |
+
return $this->isAttributeInheritable(Mage::registry(self::DFW_UPDATED_AT_ATTRIBUTE_KEY));
|
130 |
+
}
|
131 |
+
|
132 |
+
/**
|
133 |
+
* @param Mage_Catalog_Model_Resource_Eav_Attribute $attribute
|
134 |
+
* @return bool
|
135 |
+
*/
|
136 |
+
public function isAttributeInheritable($attribute)
|
137 |
+
{
|
138 |
+
return in_array($attribute->getDfwInheritance(),
|
139 |
+
array(
|
140 |
+
(string) DataFeedWatch_Connector_Model_System_Config_Source_Inheritance::PARENT_OPTION_ID,
|
141 |
+
(string) DataFeedWatch_Connector_Model_System_Config_Source_Inheritance::CHILD_THEN_PARENT_OPTION_ID,
|
142 |
+
)
|
143 |
+
);
|
144 |
+
}
|
145 |
+
|
146 |
+
/**
|
147 |
+
* @param Mage_Catalog_Model_Resource_Eav_Attribute $attribute
|
148 |
+
* @return bool
|
149 |
+
*/
|
150 |
+
public function isAttributeImportable($attribute)
|
151 |
+
{
|
152 |
+
return (int)$attribute->getImportToDfw() === 1;
|
153 |
+
}
|
154 |
+
}
|
app/code/community/DataFeedWatch/Connector/Model/Api.php
ADDED
@@ -0,0 +1,351 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
|
3 |
+
class DataFeedWatch_Connector_Model_Api
|
4 |
+
extends Mage_Catalog_Model_Product_Api
|
5 |
+
{
|
6 |
+
/**
|
7 |
+
* @return DataFeedWatch_Connector_Helper_Data
|
8 |
+
*/
|
9 |
+
public function helper()
|
10 |
+
{
|
11 |
+
return Mage::helper('datafeedwatch_connector');
|
12 |
+
}
|
13 |
+
|
14 |
+
/**
|
15 |
+
* @return string
|
16 |
+
*/
|
17 |
+
public function version()
|
18 |
+
{
|
19 |
+
$this->helper()->log('datafeedwatch.version');
|
20 |
+
$version = Mage::getConfig()->getNode()->modules->DataFeedWatch_Connector->version->__toString();
|
21 |
+
$this->helper()->log($version);
|
22 |
+
|
23 |
+
return $version;
|
24 |
+
}
|
25 |
+
|
26 |
+
/**
|
27 |
+
* @return int
|
28 |
+
*/
|
29 |
+
public function gmt_offset()
|
30 |
+
{
|
31 |
+
$this->helper()->log('datafeedwatch.gmt_offset');
|
32 |
+
$timeZone = Mage::getStoreConfig('general/locale/timezone');
|
33 |
+
$timeZone = new DateTimeZone($timeZone);
|
34 |
+
$time = new DateTime('now', $timeZone);
|
35 |
+
$offset = (int)($timeZone->getOffset($time) / 3600);
|
36 |
+
$this->helper()->log($offset);
|
37 |
+
|
38 |
+
return $offset;
|
39 |
+
}
|
40 |
+
|
41 |
+
/**
|
42 |
+
* @return array
|
43 |
+
*/
|
44 |
+
public function stores()
|
45 |
+
{
|
46 |
+
$this->helper()->log('datafeedwatch.stores');
|
47 |
+
$storeViews = $this->getStoresArray();
|
48 |
+
$this->helper()->log($storeViews);
|
49 |
+
|
50 |
+
return $storeViews;
|
51 |
+
}
|
52 |
+
|
53 |
+
/**
|
54 |
+
* @param array $options
|
55 |
+
* @return array
|
56 |
+
*/
|
57 |
+
public function products($options = array())
|
58 |
+
{
|
59 |
+
$this->helper()->log('datafeedwatch.products');
|
60 |
+
$this->unsetUpdatedOptions($options);
|
61 |
+
$this->filterOptions($options);
|
62 |
+
$collection = $this->getProductCollection($options);
|
63 |
+
$collection->applyInheritanceLogic();
|
64 |
+
|
65 |
+
return $this->processProducts($collection);
|
66 |
+
}
|
67 |
+
|
68 |
+
/**
|
69 |
+
* @param array $options
|
70 |
+
* @return int
|
71 |
+
*/
|
72 |
+
public function product_count($options = array())
|
73 |
+
{
|
74 |
+
$this->helper()->log('datafeedwatch.product_count');
|
75 |
+
$this->unsetUpdatedOptions($options);
|
76 |
+
$this->filterOptions($options);
|
77 |
+
$collection = $this->getProductCollection($options);
|
78 |
+
$amount = (int) $collection->getSize();
|
79 |
+
$this->helper()->log(sprintf('datafeedwatch.product_count %d', $amount));
|
80 |
+
|
81 |
+
return $amount;
|
82 |
+
}
|
83 |
+
|
84 |
+
/**
|
85 |
+
* @param array $options
|
86 |
+
* @return array
|
87 |
+
*/
|
88 |
+
public function updated_products($options = array())
|
89 |
+
{
|
90 |
+
$this->helper()->log('datafeedwatch.updated_products');
|
91 |
+
$this->filterOptions($options);
|
92 |
+
if (!$this->isFromDateEarlierThanConfigDate($options)) {
|
93 |
+
$collection = $this->getProductCollection($options);
|
94 |
+
$collection->applyInheritanceLogic();
|
95 |
+
|
96 |
+
return $this->processProducts($collection);
|
97 |
+
} else {
|
98 |
+
$this->helper()->log('datafeedwatch.updated_products -> datafeedwatch.products');
|
99 |
+
|
100 |
+
return $this->products($options);
|
101 |
+
}
|
102 |
+
}
|
103 |
+
|
104 |
+
/**
|
105 |
+
* @param array $options
|
106 |
+
* @return int
|
107 |
+
*/
|
108 |
+
public function updated_product_count($options = array())
|
109 |
+
{
|
110 |
+
$this->helper()->log('datafeedwatch.updated_product_count');
|
111 |
+
$this->filterOptions($options);
|
112 |
+
if (!$this->isFromDateEarlierThanConfigDate($options)) {
|
113 |
+
$collection = $this->getProductCollection($options);
|
114 |
+
$amount = (int) $collection->getSize();
|
115 |
+
$this->helper()->log(sprintf('datafeedwatch.updated_product_count %d', $amount));
|
116 |
+
} else {
|
117 |
+
$this->helper()->log('datafeedwatch.updated_product_count -> datafeedwatch.product_count');
|
118 |
+
$amount = $this->product_count($options);
|
119 |
+
}
|
120 |
+
|
121 |
+
return $amount;
|
122 |
+
}
|
123 |
+
|
124 |
+
/**
|
125 |
+
* @param array $options
|
126 |
+
* @return array
|
127 |
+
*/
|
128 |
+
public function product_ids($options = array())
|
129 |
+
{
|
130 |
+
$this->helper()->log('datafeedwatch.product_ids');
|
131 |
+
$this->filterOptions($options);
|
132 |
+
$collection = $this->getProductCollection($options);
|
133 |
+
|
134 |
+
return $collection->getColumnValues('entity_id');
|
135 |
+
}
|
136 |
+
|
137 |
+
/**
|
138 |
+
* @param array $options
|
139 |
+
* @return bool
|
140 |
+
*/
|
141 |
+
protected function isFromDateEarlierThanConfigDate($options)
|
142 |
+
{
|
143 |
+
$this->helper()->log('START: Model/Api.php->isFromDateEarlierThanConfigDate()');
|
144 |
+
if (!isset($options['from_date'])) {
|
145 |
+
$this->helper()->log('$options[\'from_date\'] is not set');
|
146 |
+
$this->helper()->log('END: Model/Api.php->isFromDateEarlierThanConfigDate()');
|
147 |
+
|
148 |
+
return false;
|
149 |
+
}
|
150 |
+
$this->helper()->log('$options[\'from_date\']');
|
151 |
+
$this->helper()->log($options['from_date']);
|
152 |
+
$this->helper()->log('$this->helper()->getLastInheritanceUpdateDate()');
|
153 |
+
$this->helper()->log($this->helper()->getLastInheritanceUpdateDate());
|
154 |
+
$this->helper()->log('result');
|
155 |
+
if ($options['from_date'] < $this->helper()->getLastInheritanceUpdateDate()) {
|
156 |
+
$this->helper()->log('$options[\'from_date\'] < $this->helper()->getLastInheritanceUpdateDate()');
|
157 |
+
} else {
|
158 |
+
$this->helper()->log('From date is equal or greater');
|
159 |
+
}
|
160 |
+
$this->helper()->log('END: Model/Api.php->isFromDateEarlierThanConfigDate()');
|
161 |
+
|
162 |
+
return $options['from_date'] < $this->helper()->getLastInheritanceUpdateDate();
|
163 |
+
}
|
164 |
+
|
165 |
+
/**
|
166 |
+
* @return array
|
167 |
+
*/
|
168 |
+
protected function getStoresArray()
|
169 |
+
{
|
170 |
+
$storeViews = array();
|
171 |
+
foreach (Mage::app()->getWebsites() as $website) {
|
172 |
+
foreach ($website->getGroups() as $group) {
|
173 |
+
foreach ($group->getStores() as $store) {
|
174 |
+
$storeViews[$store->getCode()] = array(
|
175 |
+
'Website' => $website->getName(),
|
176 |
+
'Store' => $group->getName(),
|
177 |
+
'Store View' => $store->getName(),
|
178 |
+
);
|
179 |
+
}
|
180 |
+
}
|
181 |
+
}
|
182 |
+
|
183 |
+
return $storeViews;
|
184 |
+
}
|
185 |
+
|
186 |
+
/**
|
187 |
+
* @param array $options
|
188 |
+
* @return DataFeedWatch_Connector_Model_Resource_Product_Collection
|
189 |
+
*/
|
190 |
+
public function getProductCollection($options)
|
191 |
+
{
|
192 |
+
/** @var DataFeedWatch_Connector_Model_Resource_Product_Collection $collection */
|
193 |
+
$collection = Mage::getResourceModel('datafeedwatch_connector/product_collection')->addAttributeToSelect('*');
|
194 |
+
$collection->applyFiltersOnCollection($options);
|
195 |
+
|
196 |
+
return $collection;
|
197 |
+
}
|
198 |
+
|
199 |
+
/**
|
200 |
+
* @param array $options
|
201 |
+
*/
|
202 |
+
public function filterOptions(&$options)
|
203 |
+
{
|
204 |
+
$this->helper()->log($options);
|
205 |
+
|
206 |
+
if (isset($options['store'])) {
|
207 |
+
$this->filterStoreOption($options);
|
208 |
+
}
|
209 |
+
|
210 |
+
if (isset($options['type'])) {
|
211 |
+
$this->filterTypeOption($options);
|
212 |
+
}
|
213 |
+
|
214 |
+
if (isset($options['status'])) {
|
215 |
+
$this->filterStatusOption($options);
|
216 |
+
}
|
217 |
+
|
218 |
+
if (isset($options['timezone'])) {
|
219 |
+
$this->filterTimeZoneOption($options);
|
220 |
+
}
|
221 |
+
|
222 |
+
if (isset($options['updated_at'])) {
|
223 |
+
$options['from_date'] = $options['updated_at'];
|
224 |
+
unset($options['updated_at']);
|
225 |
+
}
|
226 |
+
|
227 |
+
if (isset($options['from_date'])) {
|
228 |
+
$this->filterFromDateOption($options);
|
229 |
+
}
|
230 |
+
|
231 |
+
if (!isset($options['page'])) {
|
232 |
+
$options['page'] = 1;
|
233 |
+
}
|
234 |
+
|
235 |
+
if (!isset($options['per_page'])) {
|
236 |
+
$options['per_page'] = 100;
|
237 |
+
}
|
238 |
+
}
|
239 |
+
|
240 |
+
/**
|
241 |
+
* @param array $options
|
242 |
+
*/
|
243 |
+
public function filterStoreOption(&$options)
|
244 |
+
{
|
245 |
+
$existingStoreViews = array_keys($this->getStoresArray());
|
246 |
+
if (!in_array($options['store'], $existingStoreViews)) {
|
247 |
+
$message = 'The store view %s does not exist. Default store will be applied';
|
248 |
+
$this->helper()->log(sprintf($message, $options['store']));
|
249 |
+
$options['store'] = Mage::app()->getDefaultStoreView()->getCode();
|
250 |
+
}
|
251 |
+
Mage::app()->setCurrentStore($options['store']);
|
252 |
+
}
|
253 |
+
|
254 |
+
/**
|
255 |
+
* @param array $options
|
256 |
+
*/
|
257 |
+
public function filterTypeOption(&$options)
|
258 |
+
{
|
259 |
+
$types = $options['type'];
|
260 |
+
$magentoTypes = array(
|
261 |
+
Mage_Catalog_Model_Product_Type::TYPE_SIMPLE,
|
262 |
+
Mage_Catalog_Model_Product_Type::TYPE_BUNDLE,
|
263 |
+
Mage_Catalog_Model_Product_Type::TYPE_CONFIGURABLE,
|
264 |
+
Mage_Catalog_Model_Product_Type::TYPE_GROUPED,
|
265 |
+
Mage_Catalog_Model_Product_Type::TYPE_VIRTUAL,
|
266 |
+
);
|
267 |
+
if (!is_array($types)) {
|
268 |
+
$types = array($types);
|
269 |
+
}
|
270 |
+
$types = array_map('strtolower', $types);
|
271 |
+
$types = array_intersect($types, $magentoTypes);
|
272 |
+
if (!empty($types)) {
|
273 |
+
$options['type'] = $types;
|
274 |
+
} else {
|
275 |
+
$this->helper()->log('The type below does not exist');
|
276 |
+
$this->helper()->log($options['type']);
|
277 |
+
unset($options['type']);
|
278 |
+
}
|
279 |
+
}
|
280 |
+
|
281 |
+
/**
|
282 |
+
* @param array $options
|
283 |
+
*/
|
284 |
+
public function filterStatusOption(&$options)
|
285 |
+
{
|
286 |
+
$status = (string) $options['status'];
|
287 |
+
if ($status === '0') {
|
288 |
+
$options['status'] = Mage_Catalog_Model_Product_Status::STATUS_DISABLED;
|
289 |
+
} else if ($status === '1') {
|
290 |
+
$options['status'] = Mage_Catalog_Model_Product_Status::STATUS_ENABLED;
|
291 |
+
} else {
|
292 |
+
$message = 'The status %s does not exist';
|
293 |
+
$this->helper()->log(sprintf($message, $options['status']));
|
294 |
+
unset($options['status']);
|
295 |
+
}
|
296 |
+
}
|
297 |
+
|
298 |
+
/**
|
299 |
+
* @param array $options
|
300 |
+
*/
|
301 |
+
public function unsetUpdatedOptions(&$options)
|
302 |
+
{
|
303 |
+
unset($options['from_date']);
|
304 |
+
unset($options['updated_at']);
|
305 |
+
unset($options['timezone']);
|
306 |
+
}
|
307 |
+
|
308 |
+
/**
|
309 |
+
* @param array $options
|
310 |
+
*/
|
311 |
+
public function filterTimeZoneOption(&$options)
|
312 |
+
{
|
313 |
+
try {
|
314 |
+
$options['timezone'] = new DateTimeZone($options['timezone']);
|
315 |
+
} catch (Exception $e) {
|
316 |
+
$this->helper()->log(sprintf('%s timezone is wrong', $options['timezone']));
|
317 |
+
$options['timezone'] = null;
|
318 |
+
}
|
319 |
+
}
|
320 |
+
|
321 |
+
/**
|
322 |
+
* @param array $options
|
323 |
+
*/
|
324 |
+
public function filterFromDateOption(&$options)
|
325 |
+
{
|
326 |
+
if (!isset($options['timezone'])) {
|
327 |
+
$options['timezone'] = null;
|
328 |
+
}
|
329 |
+
try {
|
330 |
+
$options['from_date'] = new DateTime($options['from_date'], $options['timezone']);
|
331 |
+
} catch (Exception $e) {
|
332 |
+
$this->helper()->log(sprintf('%s from_date is wrong', $options['from_date']));
|
333 |
+
$options['from_date'] = new DateTime();
|
334 |
+
}
|
335 |
+
$options['from_date'] = $options['from_date']->format('Y-m-d H:i:s');
|
336 |
+
}
|
337 |
+
|
338 |
+
/**
|
339 |
+
* @param DataFeedWatch_Connector_Model_Resource_Product_Collection $collection
|
340 |
+
* @return array
|
341 |
+
*/
|
342 |
+
protected function processProducts($collection)
|
343 |
+
{
|
344 |
+
$products = array();
|
345 |
+
foreach ($collection as $product) {
|
346 |
+
$products[] = $product->getDataToImport();
|
347 |
+
}
|
348 |
+
|
349 |
+
return $products;
|
350 |
+
}
|
351 |
+
}
|
app/code/community/DataFeedWatch/Connector/Model/Api/User.php
ADDED
@@ -0,0 +1,112 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
class DataFeedWatch_Connector_Model_Api_User
|
3 |
+
extends Mage_Api_Model_User
|
4 |
+
{
|
5 |
+
const API_KEY_SHUFFLE_STRING = '0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ';
|
6 |
+
const API_KEY_LENGTH = 32;
|
7 |
+
const USER_NAME = 'datafeedwatch';
|
8 |
+
const USER_FIRST_NAME = 'Api Access';
|
9 |
+
const USER_LAST_NAME = 'DataFeedWatch';
|
10 |
+
const USER_EMAIL = 'magento@datafeedwatch.com';
|
11 |
+
const USER_IS_ACTIVE = 1;
|
12 |
+
const ROLE_NAME = 'DataFeedWatch';
|
13 |
+
const ROLE_TYPE = 'G';
|
14 |
+
const ROLE_PID = false;
|
15 |
+
const RULE_RESOURCES = 'all';
|
16 |
+
|
17 |
+
/** @var string $decodedApiKey */
|
18 |
+
private $decodedApiKey;
|
19 |
+
|
20 |
+
public function createDfwUser()
|
21 |
+
{
|
22 |
+
$role = $this->createDfwUserRole();
|
23 |
+
$this->generateApiKey();
|
24 |
+
$this->addUserData();
|
25 |
+
$this->save();
|
26 |
+
$this->setRoleId($role->getId())->setUserId($this->getId());
|
27 |
+
$this->add();
|
28 |
+
$this->sendNewApiKeyToDfw();
|
29 |
+
}
|
30 |
+
|
31 |
+
/**
|
32 |
+
* @return string
|
33 |
+
*/
|
34 |
+
public function getDecodedApiKey()
|
35 |
+
{
|
36 |
+
return $this->decodedApiKey;
|
37 |
+
}
|
38 |
+
|
39 |
+
/**
|
40 |
+
* @return DataFeedWatch_Connector_Model_Api_User
|
41 |
+
*/
|
42 |
+
public function loadDfwUser()
|
43 |
+
{
|
44 |
+
return $this->load(self::USER_EMAIL, 'email');
|
45 |
+
}
|
46 |
+
|
47 |
+
/**
|
48 |
+
* @return Mage_Api_Model_Roles
|
49 |
+
* @throws Exception
|
50 |
+
*/
|
51 |
+
protected function createDfwUserRole()
|
52 |
+
{
|
53 |
+
$role = Mage::getModel('api/roles')->load(self::ROLE_NAME, 'role_name');
|
54 |
+
|
55 |
+
$data = array(
|
56 |
+
'name' => self::ROLE_NAME,
|
57 |
+
'pid' => self::ROLE_PID,
|
58 |
+
'role_type' => self::ROLE_TYPE,
|
59 |
+
);
|
60 |
+
|
61 |
+
$role->addData($data);
|
62 |
+
$role->save();
|
63 |
+
|
64 |
+
Mage::getModel('api/rules')
|
65 |
+
->setRoleId($role->getId())
|
66 |
+
->setResources(array(self::RULE_RESOURCES))
|
67 |
+
->saveRel();
|
68 |
+
|
69 |
+
return $role;
|
70 |
+
}
|
71 |
+
|
72 |
+
protected function generateApiKey()
|
73 |
+
{
|
74 |
+
$this->decodedApiKey = sha1(time() . substr(str_shuffle(self::API_KEY_SHUFFLE_STRING), 0, self::API_KEY_LENGTH));
|
75 |
+
}
|
76 |
+
|
77 |
+
protected function addUserData()
|
78 |
+
{
|
79 |
+
$data = array(
|
80 |
+
'username' => self::USER_NAME,
|
81 |
+
'firstname' => self::USER_FIRST_NAME,
|
82 |
+
'lastname' => self::USER_LAST_NAME,
|
83 |
+
'is_active' => self::USER_IS_ACTIVE,
|
84 |
+
'api_key' => $this->decodedApiKey,
|
85 |
+
'email' => self::USER_EMAIL,
|
86 |
+
'api_key_confirmation' => $this->decodedApiKey,
|
87 |
+
);
|
88 |
+
|
89 |
+
$this->addData($data);
|
90 |
+
}
|
91 |
+
|
92 |
+
protected function sendNewApiKeyToDfw()
|
93 |
+
{
|
94 |
+
file_get_contents($this->getRegisterUrl());
|
95 |
+
}
|
96 |
+
|
97 |
+
public function getRegisterUrl()
|
98 |
+
{
|
99 |
+
$registerUrl = sprintf('%splatforms/magento/sessions/finalize',
|
100 |
+
$this->_helper()->getDataFeedWatchUrl());
|
101 |
+
|
102 |
+
return $registerUrl . '?shop=' . Mage::getBaseUrl() . '&token=' . $this->getDecodedApiKey();
|
103 |
+
}
|
104 |
+
|
105 |
+
/**
|
106 |
+
* @return DataFeedWatch_Connector_Helper_Data
|
107 |
+
*/
|
108 |
+
public function _helper()
|
109 |
+
{
|
110 |
+
return Mage::helper('datafeedwatch_connector');
|
111 |
+
}
|
112 |
+
}
|
app/code/community/DataFeedWatch/Connector/Model/Catalog/Attribute/Info.php
ADDED
@@ -0,0 +1,121 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
|
3 |
+
class DataFeedWatch_Connector_Model_Catalog_Attribute_Info
|
4 |
+
extends Mage_Core_Model_Abstract
|
5 |
+
{
|
6 |
+
public function _construct()
|
7 |
+
{
|
8 |
+
$this->_init('datafeedwatch_connector/catalog_attribute_info');
|
9 |
+
}
|
10 |
+
|
11 |
+
/**
|
12 |
+
* @param string|int $attributeId
|
13 |
+
* @return DataFeedWatch_Connector_Model_Catalog_Attribute_Info
|
14 |
+
*/
|
15 |
+
public function loadByAttributeId($attributeId)
|
16 |
+
{
|
17 |
+
return $this->load($attributeId, 'catalog_attribute_id');
|
18 |
+
}
|
19 |
+
|
20 |
+
/**
|
21 |
+
* @return Mage_Core_Model_Abstract
|
22 |
+
*/
|
23 |
+
protected function _beforeSave()
|
24 |
+
{
|
25 |
+
$this->avoidDuplication();
|
26 |
+
$this->fillDate();
|
27 |
+
$this->avoidHackImportToDfwField();
|
28 |
+
$this->avoidHackInheritanceField();
|
29 |
+
$this->updateInheritanceConfigDate();
|
30 |
+
if (!$this->hasInheritance()) {
|
31 |
+
$this->setInheritance(DataFeedWatch_Connector_Model_System_Config_Source_Inheritance::CHILD_OPTION_ID);
|
32 |
+
}
|
33 |
+
|
34 |
+
return parent::_beforeSave();
|
35 |
+
}
|
36 |
+
|
37 |
+
/**
|
38 |
+
* @return Mage_Core_Model_Abstract
|
39 |
+
*/
|
40 |
+
protected function _beforeDelete()
|
41 |
+
{
|
42 |
+
if ($this->canSaveUpdateDate()) {
|
43 |
+
$this->helper()->updateLastInheritanceUpdateDate();
|
44 |
+
}
|
45 |
+
|
46 |
+
return parent::_beforeDelete();
|
47 |
+
}
|
48 |
+
|
49 |
+
protected function avoidDuplication()
|
50 |
+
{
|
51 |
+
$info = clone $this;
|
52 |
+
$collection = $info->getCollection()
|
53 |
+
->addFieldToFilter('catalog_attribute_id', $this->getCatalogAttributeId());
|
54 |
+
if($collection->count() > 0) {
|
55 |
+
$item = $collection->getFirstItem();
|
56 |
+
$this->setId($item->getId());
|
57 |
+
$this->fillAdditionalData($item);
|
58 |
+
}
|
59 |
+
}
|
60 |
+
|
61 |
+
protected function fillDate()
|
62 |
+
{
|
63 |
+
$date = date('Y-m-d H:i:s', Mage::getModel('core/date')->timestamp(time()));
|
64 |
+
$this->setUpdatedAt($date);
|
65 |
+
}
|
66 |
+
|
67 |
+
protected function avoidHackImportToDfwField()
|
68 |
+
{
|
69 |
+
if (!$this->getCanConfigureImport() && !$this->isObjectNew()) {
|
70 |
+
$this->setImportToDfw($this->getOrigData('import_to_dfw'));
|
71 |
+
}
|
72 |
+
}
|
73 |
+
protected function avoidHackInheritanceField()
|
74 |
+
{
|
75 |
+
if ($this->hasCanConfigureInheritance() && !$this->getCanConfigureInheritance() && !$this->isObjectNew()) {
|
76 |
+
$this->setInheritance($this->getOrigData('inheritance'));
|
77 |
+
}
|
78 |
+
}
|
79 |
+
|
80 |
+
/**
|
81 |
+
* @param DataFeedWatch_Connector_Model_Catalog_Attribute_Info $item
|
82 |
+
*/
|
83 |
+
protected function fillAdditionalData($item)
|
84 |
+
{
|
85 |
+
$this->setOrigData('import_to_dfw', $item->getImportToDfw());
|
86 |
+
$this->setOrigData('inheritance', $item->getInheritance());
|
87 |
+
$this->setCanConfigureImport($item->getCanConfigureImport());
|
88 |
+
$this->setCanConfigureInheritance($item->getCanConfigureInheritance());
|
89 |
+
}
|
90 |
+
|
91 |
+
/**
|
92 |
+
* @return $this
|
93 |
+
*/
|
94 |
+
protected function updateInheritanceConfigDate()
|
95 |
+
{
|
96 |
+
if ($this->canSaveUpdateDate()) {
|
97 |
+
$this->helper()->updateLastInheritanceUpdateDate();
|
98 |
+
}
|
99 |
+
|
100 |
+
return $this;
|
101 |
+
}
|
102 |
+
|
103 |
+
/**
|
104 |
+
* @return bool
|
105 |
+
*/
|
106 |
+
protected function canSaveUpdateDate()
|
107 |
+
{
|
108 |
+
return ($this->dataHasChangedFor('inheritance') && (int)$this->getOrigData('import_to_dfw') === 1)
|
109 |
+
|| $this->dataHasChangedFor('import_to_dfw')
|
110 |
+
|| (int)$this->getData('import_to_dfw') === 1
|
111 |
+
|| $this->isObjectNew();
|
112 |
+
}
|
113 |
+
|
114 |
+
/**
|
115 |
+
* @return DataFeedWatch_Connector_Helper_Data
|
116 |
+
*/
|
117 |
+
public function helper()
|
118 |
+
{
|
119 |
+
return Mage::helper('datafeedwatch_connector');
|
120 |
+
}
|
121 |
+
}
|
app/code/community/DataFeedWatch/Connector/Model/Catalogrule/Info.php
DELETED
@@ -1,8 +0,0 @@
|
|
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
DELETED
@@ -1,8 +0,0 @@
|
|
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/Cron.php
ADDED
@@ -0,0 +1,64 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
|
3 |
+
class DataFeedWatch_Connector_Model_Cron
|
4 |
+
extends Mage_Catalog_Model_Resource_Product_Collection
|
5 |
+
{
|
6 |
+
const CATALOGRULE_DATE_TABLE_ALIAS = 'catalogrule_product_price_date';
|
7 |
+
|
8 |
+
/**
|
9 |
+
* @return $this
|
10 |
+
* @throws Mage_Core_Exception
|
11 |
+
*/
|
12 |
+
public function reindex()
|
13 |
+
{
|
14 |
+
$date = date('Y-m-d H:i:s');
|
15 |
+
$lastPriceId = $this->helper()->getLastCatalogRulePriceId();
|
16 |
+
$resource = Mage::getSingleton('core/resource');
|
17 |
+
$writeConnection = $resource->getConnection('core_write');
|
18 |
+
$select = new Zend_Db_Select($this->getEntity()->getReadConnection());
|
19 |
+
$select->from(
|
20 |
+
array(
|
21 |
+
self::CATALOGRULE_DATE_TABLE_ALIAS => $this->getTable('catalogrule/rule_product_price'),
|
22 |
+
)
|
23 |
+
);
|
24 |
+
|
25 |
+
if (!empty($lastPriceId)) {
|
26 |
+
$select->where('rule_product_price_id > ?', $lastPriceId);
|
27 |
+
}
|
28 |
+
$select->where('customer_group_id = ?', Mage_Customer_Model_Group::NOT_LOGGED_IN_ID);
|
29 |
+
$select->where('rule_date <= ?', $date);
|
30 |
+
|
31 |
+
$priceData = $select->query()->fetchAll();
|
32 |
+
if (count($priceData) < 1) {
|
33 |
+
|
34 |
+
return $this;
|
35 |
+
}
|
36 |
+
|
37 |
+
$this->helper()->cronLog($select->__toString());
|
38 |
+
$this->helper()->cronLog(count($priceData));
|
39 |
+
|
40 |
+
$updatedDataTable = $this->getTable('datafeedwatch_connector/updated_products');
|
41 |
+
foreach ($priceData as $data) {
|
42 |
+
$insertedData = array(
|
43 |
+
'product_id' => $data['product_id'],
|
44 |
+
'updated_at' => $date,
|
45 |
+
);
|
46 |
+
$writeConnection->insertOnDuplicate($updatedDataTable, $insertedData, array('updated_at'));
|
47 |
+
}
|
48 |
+
|
49 |
+
if (!empty($priceData)) {
|
50 |
+
$data = end($priceData);
|
51 |
+
$this->helper()->setLastCatalogRulePriceId($data['rule_product_price_id']);
|
52 |
+
}
|
53 |
+
|
54 |
+
return $this;
|
55 |
+
}
|
56 |
+
|
57 |
+
/**
|
58 |
+
* @return DataFeedWatch_Connector_Helper_Data
|
59 |
+
*/
|
60 |
+
public function helper()
|
61 |
+
{
|
62 |
+
return Mage::helper('datafeedwatch_connector');
|
63 |
+
}
|
64 |
+
}
|
app/code/community/DataFeedWatch/Connector/Model/Datafeedwatch/Api.php
DELETED
@@ -1,532 +0,0 @@
|
|
1 |
-
<?php
|
2 |
-
|
3 |
-
class DataFeedWatch_Connector_Model_Datafeedwatch_Api extends Mage_Catalog_Model_Product_Api
|
4 |
-
{
|
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',
|
21 |
-
'patch' => '2',
|
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(),
|
49 |
-
'Store View' => $store->getName(),
|
50 |
-
);
|
51 |
-
}
|
52 |
-
}
|
53 |
-
}
|
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 |
-
|
242 |
-
//re-setters
|
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();
|
359 |
-
if (isset($visibilityStatuses[$product->getVisibility()])) {
|
360 |
-
$productAttributes['visibility'] = $visibilityStatuses[$product->getVisibility()];
|
361 |
-
} else {
|
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 |
-
|
464 |
-
}
|
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'));
|
474 |
-
$time = new DateTime('now', $timeZone);
|
475 |
-
$offset = (int)($timeZone->getOffset($time) / 3600);
|
476 |
-
|
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
CHANGED
@@ -1,51 +1,226 @@
|
|
1 |
<?php
|
2 |
-
class DataFeedWatch_Connector_Model_Observer extends Mage_Core_Model_Abstract {
|
3 |
|
4 |
-
|
5 |
-
|
6 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
7 |
|
8 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
9 |
|
10 |
-
|
11 |
-
$dfwCatalogRuleInfo
|
12 |
-
->setCatalogruleId($ruleId)
|
13 |
-
->setUpdatedAt(time())
|
14 |
-
->save();
|
15 |
}
|
16 |
|
17 |
-
|
18 |
-
|
19 |
-
|
20 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
21 |
|
22 |
-
|
23 |
-
$dfwSalesRuleInfo
|
24 |
-
->setSalesruleId($object->getRule()->getRuleId())
|
25 |
-
->setUpdatedAt(time())
|
26 |
-
->save();
|
27 |
}
|
28 |
|
29 |
-
|
30 |
-
|
31 |
-
|
32 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
33 |
|
34 |
-
|
35 |
-
|
|
|
|
|
36 |
|
37 |
-
|
38 |
-
|
39 |
-
|
40 |
-
|
41 |
-
|
42 |
-
|
43 |
-
|
44 |
-
|
45 |
-
|
46 |
-
|
|
|
|
|
|
|
47 |
}
|
48 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
49 |
|
|
|
|
|
|
|
|
|
|
|
|
|
50 |
}
|
51 |
}
|
1 |
<?php
|
|
|
2 |
|
3 |
+
class DataFeedWatch_Connector_Model_Observer
|
4 |
+
{
|
5 |
+
/**
|
6 |
+
* @param Varien_Event_Observer $observer
|
7 |
+
* @return $this
|
8 |
+
*/
|
9 |
+
public function addInheritanceFieldToAttributeForm(Varien_Event_Observer $observer)
|
10 |
+
{
|
11 |
+
$form = $observer->getForm();
|
12 |
+
$fieldset = $form->getElement('base_fieldset');
|
13 |
+
$attribute = $observer->getAttribute();
|
14 |
+
$fieldset->addField('import_to_dfw', 'select', array(
|
15 |
+
'name' => 'import_to_dfw',
|
16 |
+
'label' => Mage::helper('datafeedwatch_connector')->__('Import To DataFeedWatch'),
|
17 |
+
'values' => Mage::getModel('adminhtml/system_config_source_yesno')->toOptionArray(),
|
18 |
+
'disabled' => $attribute->hasCanConfigureImport() && !$attribute->getCanConfigureImport(),
|
19 |
+
), 'is_configurable');
|
20 |
+
$fieldset->addField('dfw_inheritance', 'select', array(
|
21 |
+
'name' => 'dfw_inheritance',
|
22 |
+
'label' => Mage::helper('datafeedwatch_connector')->__('DataFeedWatch Inheritance'),
|
23 |
+
'values' => Mage::getModel('datafeedwatch_connector/system_config_source_inheritance')->toOptionArray(),
|
24 |
+
'disabled' => $attribute->hasCanConfigureImport() && !$attribute->getCanConfigureInheritance(),
|
25 |
+
), 'import_to_dfw');
|
26 |
|
27 |
+
return $this;
|
28 |
+
}
|
29 |
+
|
30 |
+
/**
|
31 |
+
* @param Varien_Event_Observer $observer
|
32 |
+
* @return $this
|
33 |
+
*/
|
34 |
+
public function updateLastInheritanceUpdateDateOnCategoryChangeName(Varien_Event_Observer $observer)
|
35 |
+
{
|
36 |
+
$category = $observer->getCategory();
|
37 |
+
if($category instanceof Varien_Object && $category->dataHasChangedFor('name')) {
|
38 |
+
$this->helper()->updateLastInheritanceUpdateDate();
|
39 |
+
}
|
40 |
+
|
41 |
+
return $this;
|
42 |
+
}
|
43 |
+
|
44 |
+
/**
|
45 |
+
* @param Varien_Event_Observer $observer
|
46 |
+
* @return $this
|
47 |
+
*/
|
48 |
+
public function updateLastInheritanceUpdateDate(Varien_Event_Observer $observer)
|
49 |
+
{
|
50 |
+
$this->helper()->updateLastInheritanceUpdateDate();
|
51 |
+
|
52 |
+
return $this;
|
53 |
+
}
|
54 |
+
|
55 |
+
/**
|
56 |
+
* @param Varien_Event_Observer $observer
|
57 |
+
* @return $this
|
58 |
+
*/
|
59 |
+
public function saveInheritanceInAttribute(Varien_Event_Observer $observer)
|
60 |
+
{
|
61 |
+
$attribute = $observer->getAttribute();
|
62 |
+
if ($this->isProductEntityType($attribute)) {
|
63 |
+
Mage::getModel('datafeedwatch_connector/catalog_attribute_info')
|
64 |
+
->setCatalogAttributeId($attribute->getAttributeId())
|
65 |
+
->setInheritance($attribute->getDfwInheritance())
|
66 |
+
->setImportToDfw($attribute->getImportToDfw())
|
67 |
+
->save();
|
68 |
+
}
|
69 |
+
|
70 |
+
return $this;
|
71 |
+
}
|
72 |
+
|
73 |
+
/**
|
74 |
+
* @param Varien_Event_Observer $observer
|
75 |
+
* @return $this
|
76 |
+
*/
|
77 |
+
public function deleteAttribute(Varien_Event_Observer $observer)
|
78 |
+
{
|
79 |
+
$attribute = $observer->getAttribute();
|
80 |
+
$attributeInfo = Mage::getModel('datafeedwatch_connector/catalog_attribute_info')
|
81 |
+
->loadByAttributeId($attribute->getId());
|
82 |
+
if ($attributeInfo instanceof Mage_Core_Model_Abstract && $attributeInfo->hasCatalogAttributeId()) {
|
83 |
+
$attributeInfo->delete();
|
84 |
+
}
|
85 |
+
|
86 |
+
return $this;
|
87 |
+
}
|
88 |
+
|
89 |
+
/**
|
90 |
+
* @param Varien_Event_Observer $observer
|
91 |
+
* @return $this
|
92 |
+
*/
|
93 |
+
public function getInheritanceForAttribute(Varien_Event_Observer $observer)
|
94 |
+
{
|
95 |
+
$attribute = $observer->getAttribute();
|
96 |
+
if ($this->isProductEntityType($attribute)) {
|
97 |
+
$attributeInfo = Mage::getModel('datafeedwatch_connector/catalog_attribute_info')
|
98 |
+
->loadByAttributeId($attribute->getId());
|
99 |
+
$attribute->setCanConfigureInheritance($attributeInfo->getCanConfigureInheritance())
|
100 |
+
->setDfwInheritance($attributeInfo->getInheritance())
|
101 |
+
->setCanConfigureImport($attributeInfo->getCanConfigureImport())
|
102 |
+
->setImportToDfw($attributeInfo->getImportToDfw());
|
103 |
+
}
|
104 |
+
|
105 |
+
return $this;
|
106 |
+
}
|
107 |
+
|
108 |
+
/**
|
109 |
+
* @param Varien_Event_Observer $observer
|
110 |
+
* @return $this
|
111 |
+
*/
|
112 |
+
public function getInheritanceForAttributeCollection(Varien_Event_Observer $observer)
|
113 |
+
{
|
114 |
+
$collection = $observer->getCollection();
|
115 |
+
$newItemObject = $collection->getNewEmptyItem();
|
116 |
+
if ($newItemObject instanceof Mage_Catalog_Model_Resource_Eav_Attribute) {
|
117 |
+
$collection->getSelect()->joinLeft(
|
118 |
+
array('catalog_attribute_info' => Mage::getModel('core/resource')
|
119 |
+
->getTableName('datafeedwatch_connector/catalog_attribute_info')),
|
120 |
+
'catalog_attribute_info.catalog_attribute_id = main_table.attribute_id',
|
121 |
+
array(
|
122 |
+
'dfw_inheritance' => 'inheritance',
|
123 |
+
'import_to_dfw' => 'import_to_dfw',
|
124 |
+
'can_configure_import' => 'can_configure_import',
|
125 |
+
'can_configure_inheritance' => 'can_configure_inheritance',
|
126 |
+
)
|
127 |
+
);
|
128 |
+
}
|
129 |
|
130 |
+
return $this;
|
|
|
|
|
|
|
|
|
131 |
}
|
132 |
|
133 |
+
/**
|
134 |
+
* @param Varien_Event_Observer $observer
|
135 |
+
* @return $this
|
136 |
+
*/
|
137 |
+
public function removeProductFromUpdatedTable(Varien_Event_Observer $observer)
|
138 |
+
{
|
139 |
+
/** @var Mage_Catalog_Model_Product $product */
|
140 |
+
$product = $observer->getProduct();
|
141 |
+
$resource = Mage::getSingleton('core/resource');
|
142 |
+
$connection = $resource->getConnection('core_write');
|
143 |
+
$connection->delete(Mage::getModel('core/resource')->getTableName('datafeedwatch_connector/updated_products'),
|
144 |
+
sprintf('product_id = %s', $product->getId()));
|
145 |
|
146 |
+
return $this;
|
|
|
|
|
|
|
|
|
147 |
}
|
148 |
|
149 |
+
/**
|
150 |
+
* @param Varien_Event_Observer $observer
|
151 |
+
* @return $this
|
152 |
+
*/
|
153 |
+
public function updateInheritanceUpdateDate(Varien_Event_Observer $observer)
|
154 |
+
{
|
155 |
+
/** @var Mage_Adminhtml_Model_Config_Data $configModel */
|
156 |
+
$configModel = $observer->getObject();
|
157 |
+
if ($configModel->getSection() !== 'datafeedwatch_connector') {
|
158 |
+
|
159 |
+
return $this;
|
160 |
+
}
|
161 |
+
|
162 |
+
$productUrlXpath = DataFeedWatch_Connector_Helper_Data::PRODUCT_URL_CUSTOM_INHERITANCE_XPATH;
|
163 |
+
$imageUrlXpath = DataFeedWatch_Connector_Helper_Data::IMAGE_URL_CUSTOM_INHERITANCE_XPATH;
|
164 |
|
165 |
+
if ($this->hasConfigDataChanged($configModel, $productUrlXpath)
|
166 |
+
|| $this->hasConfigDataChanged($configModel, $imageUrlXpath)) {
|
167 |
+
$this->helper()->updateLastInheritanceUpdateDate();
|
168 |
+
}
|
169 |
|
170 |
+
return $this;
|
171 |
+
}
|
172 |
+
|
173 |
+
/**
|
174 |
+
* @param Mage_Adminhtml_Model_Config_Data $configModel
|
175 |
+
* @param string $xpath
|
176 |
+
* @return null
|
177 |
+
*/
|
178 |
+
protected function getConfigDataFromXpath($configModel, $xpath)
|
179 |
+
{
|
180 |
+
$xpath = explode('/', $xpath);
|
181 |
+
if (!is_array($xpath)) {
|
182 |
+
return null;
|
183 |
}
|
184 |
|
185 |
+
if (count($xpath) === 3) {
|
186 |
+
unset($xpath[0]);
|
187 |
+
}
|
188 |
+
|
189 |
+
try {
|
190 |
+
return $configModel->getGroups()[reset($xpath)]['fields'][end($xpath)]['value'];
|
191 |
+
} catch (Exception $e) {
|
192 |
+
$this->helper()->log($e->getMessage());
|
193 |
+
|
194 |
+
return null;
|
195 |
+
}
|
196 |
+
}
|
197 |
+
|
198 |
+
/**
|
199 |
+
* @param Mage_Adminhtml_Model_Config_Data $configModel
|
200 |
+
* @param string $xpath
|
201 |
+
* @return bool
|
202 |
+
*/
|
203 |
+
protected function hasConfigDataChanged($configModel, $xpath)
|
204 |
+
{
|
205 |
+
return $configModel->getConfigDataValue($xpath) !== $this->getConfigDataFromXpath($configModel, $xpath);
|
206 |
+
}
|
207 |
+
|
208 |
+
/**
|
209 |
+
* @param Mage_Catalog_Model_Resource_Eav_Attribute $attribute
|
210 |
+
* @return bool
|
211 |
+
*/
|
212 |
+
protected function isProductEntityType($attribute)
|
213 |
+
{
|
214 |
+
$productEntityType = Mage::getResourceModel('catalog/product')->getEntityType()->getEntityTypeId();
|
215 |
+
|
216 |
+
return $productEntityType === $attribute->getEntityTypeId();
|
217 |
+
}
|
218 |
|
219 |
+
/**
|
220 |
+
* @return DataFeedWatch_Connector_Helper_Data
|
221 |
+
*/
|
222 |
+
public function helper()
|
223 |
+
{
|
224 |
+
return Mage::helper('datafeedwatch_connector');
|
225 |
}
|
226 |
}
|
app/code/community/DataFeedWatch/Connector/Model/Product.php
ADDED
@@ -0,0 +1,415 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
/**
|
3 |
+
* @method DataFeedWatch_Connector_Model_Product getParent()
|
4 |
+
*/
|
5 |
+
|
6 |
+
class DataFeedWatch_Connector_Model_Product
|
7 |
+
extends Mage_Catalog_Model_Product
|
8 |
+
{
|
9 |
+
/** @var array $importData */
|
10 |
+
protected $importData = array();
|
11 |
+
|
12 |
+
protected function _construct()
|
13 |
+
{
|
14 |
+
$this->_init('datafeedwatch_connector/product');
|
15 |
+
}
|
16 |
+
|
17 |
+
/**
|
18 |
+
* @return array
|
19 |
+
*/
|
20 |
+
public function getDataToImport()
|
21 |
+
{
|
22 |
+
$parent = $this->getParent();
|
23 |
+
if ($this->registryHelper()->isStatusAttributeInheritable()) {
|
24 |
+
$this->setStatus($this->getFilterStatus());
|
25 |
+
}
|
26 |
+
$date = $this->getRuleDate();
|
27 |
+
$date = new DateTime($date);
|
28 |
+
$this->setUpdatedAt($date->format('Y-m-d H:i:s'));
|
29 |
+
$this->fillAllAttributesData();
|
30 |
+
$this->importData['product_id'] = $this->getId();
|
31 |
+
$this->importData['sku'] = $this->getSku();
|
32 |
+
$this->importData['product_type'] = $this->getTypeId();
|
33 |
+
$this->importData['quantity'] = (int) $this->getQty();
|
34 |
+
$this->importData['currency_code'] = $this->getStore()->getCurrentCurrencyCode();
|
35 |
+
$this->importData['price'] = $this->getImportPrice(false);
|
36 |
+
$this->importData['price_with_tax'] = $this->getImportPrice(true);
|
37 |
+
$this->importData['special_price'] = $this->getImportSpecialPrice(false);
|
38 |
+
$this->importData['special_price_with_tax'] = $this->getImportSpecialPrice(true);
|
39 |
+
$this->importData['special_from_date'] = $this->getSpecialFromDate();
|
40 |
+
$this->importData['special_to_date'] = $this->getSpecialToDate();
|
41 |
+
$this->importData['image_url'] = $this->getBaseImageUrl();
|
42 |
+
$this->importData['product_url'] = $this->getProductUrl();
|
43 |
+
$this->importData['product_url_rewritten'] = $this->getProductUrlRewritten();
|
44 |
+
|
45 |
+
$this->getCategoryPathToImport();
|
46 |
+
$this->setDataToImport($this->getCategoriesNameToImport(false));
|
47 |
+
|
48 |
+
if (!empty($parent)) {
|
49 |
+
$this->importData['parent_id'] = $parent->getId();
|
50 |
+
$this->importData['parent_sku'] = $parent->getSku();
|
51 |
+
$this->importData['parent_price'] = $parent->getImportPrice(false);
|
52 |
+
$this->importData['parent_price_with_tax'] = $parent->getImportPrice(true);
|
53 |
+
$this->importData['parent_special_price'] = $parent->getImportSpecialPrice(false);
|
54 |
+
$this->importData['parent_special_price_with_tax'] = $parent->getImportSpecialPrice(true);
|
55 |
+
$this->importData['parent_special_from_date'] = $parent->getSpecialFromDate();
|
56 |
+
$this->importData['parent_special_to_date'] = $parent->getSpecialToDate();
|
57 |
+
$this->importData['parent_url'] = $parent->getProductUrl();
|
58 |
+
|
59 |
+
if ($this->helper()->isProductUrlInherited()) {
|
60 |
+
$this->importData['product_url'] = $this->importData['parent_url'];
|
61 |
+
}
|
62 |
+
|
63 |
+
$this->setDataToImport($parent->getCategoriesNameToImport(true));
|
64 |
+
if ($parent->isConfigurable()) {
|
65 |
+
$this->importData['variant_spac_price'] = $parent->getVariantSpacPrice($this, false);
|
66 |
+
$this->importData['variant_spac_price_with_tax'] = $parent->getVariantSpacPrice($this, true);
|
67 |
+
$this->importData['variant_name'] = $this->getName();
|
68 |
+
$this->getDfwDefaultVariant();
|
69 |
+
}
|
70 |
+
}
|
71 |
+
|
72 |
+
$this->getExcludedImages();
|
73 |
+
$this->setDataToImport($this->getAdditionalImages($this->importData['image_url'], false));
|
74 |
+
if (!empty($parent)) {
|
75 |
+
if ($this->helper()->isImageUrlInherited()) {
|
76 |
+
$this->importData['image_url'] = $parent->getBaseImageUrl();
|
77 |
+
}
|
78 |
+
$this->setDataToImport($parent->getAdditionalImages($this->importData['image_url'], true));
|
79 |
+
}
|
80 |
+
|
81 |
+
return $this->importData;
|
82 |
+
}
|
83 |
+
|
84 |
+
/**
|
85 |
+
* @param string $key
|
86 |
+
* @param mixed $data
|
87 |
+
* @return Varien_Object
|
88 |
+
*/
|
89 |
+
public function setOrigData($key = null, $data = null)
|
90 |
+
{
|
91 |
+
if (is_null($key)) {
|
92 |
+
$this->_origData = $this->_data;
|
93 |
+
} else {
|
94 |
+
$this->_origData[$key] = $data;
|
95 |
+
}
|
96 |
+
return $this;
|
97 |
+
}
|
98 |
+
|
99 |
+
/**
|
100 |
+
* @return $this
|
101 |
+
*/
|
102 |
+
protected function fillAllAttributesData()
|
103 |
+
{
|
104 |
+
$attributeCollection = Mage::registry(DataFeedWatch_Connector_Helper_Registry::ALL_IMPORTABLE_ATTRIBUTES_KEY);
|
105 |
+
foreach ($attributeCollection as $attribute) {
|
106 |
+
$attributeCode = $attribute->getAttributeCode();
|
107 |
+
$data = $this->getData($attributeCode);
|
108 |
+
if (empty($attributeCode) || !$this->hasData($attributeCode) || empty($data)) {
|
109 |
+
continue;
|
110 |
+
}
|
111 |
+
$value = $attribute->getFrontend()->getValue($this);
|
112 |
+
if ($attribute->getBackendType() === 'int' && $value === 'N/A') {
|
113 |
+
$value = '';
|
114 |
+
}
|
115 |
+
$this->importData[$attributeCode] = $value;
|
116 |
+
}
|
117 |
+
|
118 |
+
return $this;
|
119 |
+
}
|
120 |
+
|
121 |
+
/**
|
122 |
+
* @param array $data
|
123 |
+
*/
|
124 |
+
protected function setDataToImport($data)
|
125 |
+
{
|
126 |
+
foreach ($data as $key => $value) {
|
127 |
+
$this->importData[$key] = $value;
|
128 |
+
}
|
129 |
+
}
|
130 |
+
|
131 |
+
/**
|
132 |
+
* @param bool $withTax
|
133 |
+
* @return float
|
134 |
+
*/
|
135 |
+
protected function getImportPrice($withTax = false)
|
136 |
+
{
|
137 |
+
$price = $this->getStore()->roundPrice($this->getStore()->convertPrice($this->getFinalPrice()));
|
138 |
+
return $this->getTaxHelper()->getPrice($this, $price, $withTax);
|
139 |
+
}
|
140 |
+
|
141 |
+
/**
|
142 |
+
* @param bool $withTax
|
143 |
+
* @return float
|
144 |
+
*/
|
145 |
+
protected function getImportSpecialPrice($withTax = false)
|
146 |
+
{
|
147 |
+
return $this->getTaxHelper()->getPrice($this, $this->getSpecialPrice(), $withTax);
|
148 |
+
}
|
149 |
+
|
150 |
+
/**
|
151 |
+
* @param DataFeedWatch_Connector_Model_Product $child
|
152 |
+
* @param bool $withTax
|
153 |
+
* @return float
|
154 |
+
*/
|
155 |
+
protected function getVariantSpacPrice($child, $withTax = false)
|
156 |
+
{
|
157 |
+
if (!$this->isConfigurable()) {
|
158 |
+
return null;
|
159 |
+
}
|
160 |
+
$attributes = $this->getTypeInstance(true)->getConfigurableAttributes($this);
|
161 |
+
$pricesByAttributeValues = array();
|
162 |
+
$basePrice = $this->getFinalPrice();
|
163 |
+
foreach ($attributes as $attribute) {
|
164 |
+
$prices = $attribute->getPrices();
|
165 |
+
foreach ($prices as $price) {
|
166 |
+
if ($price['is_percent']) {
|
167 |
+
$pricesByAttributeValues[$price['value_index']] = (float)$price['pricing_value'] * $basePrice / 100;
|
168 |
+
} else {
|
169 |
+
$pricesByAttributeValues[$price['value_index']] = (float)$price['pricing_value'];
|
170 |
+
}
|
171 |
+
}
|
172 |
+
}
|
173 |
+
$totalPrice = $basePrice;
|
174 |
+
foreach ($attributes as $attribute) {
|
175 |
+
$value = $child->getData($attribute->getProductAttribute()->getAttributeCode());
|
176 |
+
if (isset($pricesByAttributeValues[$value])) {
|
177 |
+
$totalPrice += $pricesByAttributeValues[$value];
|
178 |
+
}
|
179 |
+
}
|
180 |
+
|
181 |
+
return $this->getTaxHelper()->getPrice($this, $totalPrice, $withTax);
|
182 |
+
}
|
183 |
+
|
184 |
+
/**
|
185 |
+
* @return $this
|
186 |
+
*/
|
187 |
+
protected function getCategoryPathToImport()
|
188 |
+
{
|
189 |
+
$index = '';
|
190 |
+
$categoriesCollection = Mage::registry(DataFeedWatch_Connector_Helper_Registry::ALL_CATEGORIES_ARRAY_KEY);
|
191 |
+
foreach ($this->getCategoryCollection()->addNameToResult() as $category) {
|
192 |
+
|
193 |
+
$categoryName = array();
|
194 |
+
$path = $category->getPath();
|
195 |
+
foreach (explode('/', $path) as $categoryId) {
|
196 |
+
if (isset($categoriesCollection[$categoryId])) {
|
197 |
+
$categoryName[] = $categoriesCollection[$categoryId]->getName();
|
198 |
+
}
|
199 |
+
}
|
200 |
+
if (!empty($categoryName)) {
|
201 |
+
$key = 'category_path' . $index;
|
202 |
+
$this->importData[$key] = implode(' > ', $categoryName);
|
203 |
+
$index++;
|
204 |
+
}
|
205 |
+
}
|
206 |
+
|
207 |
+
return $this;
|
208 |
+
}
|
209 |
+
|
210 |
+
/**
|
211 |
+
* @param bool $isParent
|
212 |
+
* @return array
|
213 |
+
*/
|
214 |
+
protected function getCategoriesNameToImport($isParent = false)
|
215 |
+
{
|
216 |
+
$index = '';
|
217 |
+
$names = array();
|
218 |
+
foreach ($this->getCategoryCollection()->addNameToResult() as $category) {
|
219 |
+
$key = $isParent ? 'category_parent_name' : 'category_name';
|
220 |
+
$key .= $index++;
|
221 |
+
$names[$key] = $category->getName();
|
222 |
+
}
|
223 |
+
|
224 |
+
return $names;
|
225 |
+
}
|
226 |
+
|
227 |
+
/**
|
228 |
+
* @return string|null
|
229 |
+
*/
|
230 |
+
protected function getBaseImageUrl()
|
231 |
+
{
|
232 |
+
$this->load('image');
|
233 |
+
$image = $this->getImage();
|
234 |
+
if ($image !== 'no_selection' && !empty($image)) {
|
235 |
+
|
236 |
+
return $this->getMediaConfig()->getMediaUrl($image);
|
237 |
+
}
|
238 |
+
|
239 |
+
return null;
|
240 |
+
}
|
241 |
+
|
242 |
+
/**
|
243 |
+
* @param null|string $importedBaseImage
|
244 |
+
* @param bool $isParent
|
245 |
+
* @return array
|
246 |
+
*/
|
247 |
+
protected function getAdditionalImages($importedBaseImage = null, $isParent = false)
|
248 |
+
{
|
249 |
+
if (empty($importedBaseImage)) {
|
250 |
+
$this->getBaseImageUrl();
|
251 |
+
}
|
252 |
+
$this->load('media_gallery');
|
253 |
+
$gallery = $this->getMediaGalleryImages();
|
254 |
+
|
255 |
+
$index = 1;
|
256 |
+
$additionalImages = array();
|
257 |
+
foreach ($gallery as $image) {
|
258 |
+
$imageUrl = $image->getUrl();
|
259 |
+
if ($imageUrl !== $importedBaseImage && $imageUrl !== 'no_selection' && !empty($imageUrl)) {
|
260 |
+
$key = $isParent ? 'parent_additional_image_url' : 'product_additional_image_url';
|
261 |
+
$key .= $index++;
|
262 |
+
$additionalImages[$key] = $imageUrl;
|
263 |
+
}
|
264 |
+
}
|
265 |
+
|
266 |
+
return $additionalImages;
|
267 |
+
}
|
268 |
+
|
269 |
+
/**
|
270 |
+
* @return $this
|
271 |
+
*/
|
272 |
+
protected function getExcludedImages()
|
273 |
+
{
|
274 |
+
$this->load('media_gallery');
|
275 |
+
$gallery = $this->getMediaGallery('images');
|
276 |
+
$index = 1;
|
277 |
+
foreach ($gallery as $image) {
|
278 |
+
if ($image['disabled']) {
|
279 |
+
$imageUrl = $this->getMediaConfig()->getMediaUrl($image['file']);
|
280 |
+
$key = 'image_url_excluded' . $index++;
|
281 |
+
$this->importData[$key] = $imageUrl;
|
282 |
+
}
|
283 |
+
}
|
284 |
+
|
285 |
+
return $this;
|
286 |
+
}
|
287 |
+
|
288 |
+
/**
|
289 |
+
* @param null|Mage_Catalog_Model_Category $category
|
290 |
+
* @return string
|
291 |
+
* @throws Mage_Core_Exception
|
292 |
+
*/
|
293 |
+
public function getProductUrlRewritten($category = null)
|
294 |
+
{
|
295 |
+
if (!empty($category)) {
|
296 |
+
$categoryId = $category->getId();
|
297 |
+
}
|
298 |
+
$productId = $this->getId();
|
299 |
+
$store = $this->getStore();
|
300 |
+
$storeId = $store->getId();
|
301 |
+
$coreUrl = Mage::getModel('core/url_rewrite');
|
302 |
+
$idPath = sprintf('product/%d', $productId);
|
303 |
+
|
304 |
+
if (!empty($categoryId)) {
|
305 |
+
$idPath = sprintf('%s/%d', $idPath, $categoryId);
|
306 |
+
}
|
307 |
+
$coreUrl->setStoreId($storeId);
|
308 |
+
$coreUrl->loadByIdPath($idPath);
|
309 |
+
$requestPath = $coreUrl->getRequestPath();
|
310 |
+
if (empty($requestPath)) {
|
311 |
+
return '';
|
312 |
+
}
|
313 |
+
|
314 |
+
return $store->getBaseUrl() . $requestPath;
|
315 |
+
}
|
316 |
+
|
317 |
+
/**
|
318 |
+
* @return $this
|
319 |
+
*/
|
320 |
+
protected function getDfwDefaultVariant()
|
321 |
+
{
|
322 |
+
$parent = $this->getParent();
|
323 |
+
if (empty($parent)) {
|
324 |
+
return $this;
|
325 |
+
}
|
326 |
+
|
327 |
+
$superAttributes = Mage::registry(DataFeedWatch_Connector_Helper_Registry::ALL_SUPER_ATTRIBUTES_KEY);
|
328 |
+
$parentSuperAttributes = $parent->getData('super_attribute_ids');
|
329 |
+
$parentSuperAttributes = explode(',', $parentSuperAttributes);
|
330 |
+
$this->importData['dfw_default_variant'] = 1;
|
331 |
+
foreach ($parentSuperAttributes as $superAttributeId) {
|
332 |
+
if (!isset($superAttributes[$superAttributeId])) {
|
333 |
+
continue;
|
334 |
+
}
|
335 |
+
$superAttribute = $superAttributes[$superAttributeId];
|
336 |
+
$defaultValue = $superAttribute->getDefaultValue();
|
337 |
+
if (!empty($defaultValue) && $defaultValue !== $this->getData($superAttribute->getAttributeCode())) {
|
338 |
+
$this->importData['dfw_default_variant'] = 0;
|
339 |
+
|
340 |
+
return $this;
|
341 |
+
}
|
342 |
+
}
|
343 |
+
|
344 |
+
return $this;
|
345 |
+
}
|
346 |
+
|
347 |
+
/**
|
348 |
+
* @return $this
|
349 |
+
*/
|
350 |
+
public function getParentAttributes()
|
351 |
+
{
|
352 |
+
$parent = $this->getParent();
|
353 |
+
if (empty($parent)) {
|
354 |
+
|
355 |
+
return $this;
|
356 |
+
}
|
357 |
+
$allAttributes = Mage::registry(DataFeedWatch_Connector_Helper_Registry::ALL_ATTRIBUTE_COLLECTION_KEY);
|
358 |
+
foreach ($allAttributes as $attribute) {
|
359 |
+
$attributeCode = $attribute->getAttributeCode();
|
360 |
+
switch ($attribute->getDfwInheritance()) {
|
361 |
+
case (string) DataFeedWatch_Connector_Model_System_Config_Source_Inheritance::CHILD_THEN_PARENT_OPTION_ID:
|
362 |
+
$productData = $this->getData($attributeCode);
|
363 |
+
if (empty($productData) || $this->shouldChangeVisibilityForProduct($attribute)) {
|
364 |
+
$parentData = $parent->getData($attributeCode);
|
365 |
+
$this->setData($attributeCode, $parentData);
|
366 |
+
}
|
367 |
+
break;
|
368 |
+
case (string) DataFeedWatch_Connector_Model_System_Config_Source_Inheritance::PARENT_OPTION_ID:
|
369 |
+
$parentData = $parent->getData($attributeCode);
|
370 |
+
if ($attributeCode === 'meta_title') {
|
371 |
+
}
|
372 |
+
$this->setData($attributeCode, $parentData);
|
373 |
+
break;
|
374 |
+
}
|
375 |
+
}
|
376 |
+
|
377 |
+
return $this;
|
378 |
+
}
|
379 |
+
|
380 |
+
/**
|
381 |
+
* @param Mage_Catalog_Model_Resource_Eav_Attribute $attribute
|
382 |
+
* @return bool
|
383 |
+
*/
|
384 |
+
public function shouldChangeVisibilityForProduct($attribute)
|
385 |
+
{
|
386 |
+
$attributeCode = $attribute->getAttributeCode();
|
387 |
+
|
388 |
+
return $attributeCode === 'visibility'
|
389 |
+
&& (int)$this->getData($attributeCode) === Mage_Catalog_Model_Product_Visibility::VISIBILITY_NOT_VISIBLE;
|
390 |
+
}
|
391 |
+
|
392 |
+
/**
|
393 |
+
* @return Mage_Tax_Helper_Data
|
394 |
+
*/
|
395 |
+
public function getTaxHelper()
|
396 |
+
{
|
397 |
+
return Mage::helper('tax');
|
398 |
+
}
|
399 |
+
|
400 |
+
/**
|
401 |
+
* @return DataFeedWatch_Connector_Helper_Data
|
402 |
+
*/
|
403 |
+
public function helper()
|
404 |
+
{
|
405 |
+
return Mage::helper('datafeedwatch_connector');
|
406 |
+
}
|
407 |
+
|
408 |
+
/**
|
409 |
+
* @return DataFeedWatch_Connector_Helper_Registry
|
410 |
+
*/
|
411 |
+
public function registryHelper()
|
412 |
+
{
|
413 |
+
return Mage::helper('datafeedwatch_connector/registry');
|
414 |
+
}
|
415 |
+
}
|
app/code/community/DataFeedWatch/Connector/Model/Resource/Catalog/Attribute/Info.php
ADDED
@@ -0,0 +1,10 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
|
3 |
+
class DataFeedWatch_Connector_Model_Resource_Catalog_Attribute_Info
|
4 |
+
extends Mage_Core_Model_Resource_Db_Abstract
|
5 |
+
{
|
6 |
+
public function _construct()
|
7 |
+
{
|
8 |
+
$this->_init('datafeedwatch_connector/catalog_attribute_info', 'catalog_attribute_info_id');
|
9 |
+
}
|
10 |
+
}
|
app/code/community/DataFeedWatch/Connector/Model/Resource/Catalog/Attribute/Info/Collection.php
ADDED
@@ -0,0 +1,10 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
|
3 |
+
class DataFeedWatch_Connector_Model_Resource_Catalog_Attribute_Info_Collection
|
4 |
+
extends Mage_Core_Model_Resource_Db_Collection_Abstract
|
5 |
+
{
|
6 |
+
public function _construct()
|
7 |
+
{
|
8 |
+
$this->_init('datafeedwatch_connector/catalog_attribute_info');
|
9 |
+
}
|
10 |
+
}
|
app/code/community/DataFeedWatch/Connector/Model/Resource/Catalogrule/Info.php
DELETED
@@ -1,8 +0,0 @@
|
|
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
DELETED
@@ -1,8 +0,0 @@
|
|
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/Product.php
ADDED
@@ -0,0 +1,7 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
|
3 |
+
class DataFeedWatch_Connector_Model_Resource_Product
|
4 |
+
extends Mage_Catalog_Model_Resource_Product
|
5 |
+
{
|
6 |
+
|
7 |
+
}
|
app/code/community/DataFeedWatch/Connector/Model/Resource/Product/Collection.php
ADDED
@@ -0,0 +1,222 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
|
3 |
+
class DataFeedWatch_Connector_Model_Resource_Product_Collection
|
4 |
+
extends DataFeedWatch_Connector_Model_Resource_Product_Collection_Db
|
5 |
+
{
|
6 |
+
/**
|
7 |
+
* @return bool
|
8 |
+
*/
|
9 |
+
public function isEnabledFlat()
|
10 |
+
{
|
11 |
+
return false;
|
12 |
+
}
|
13 |
+
|
14 |
+
protected function _construct()
|
15 |
+
{
|
16 |
+
$this->_init('datafeedwatch_connector/product');
|
17 |
+
$this->_initTables();
|
18 |
+
}
|
19 |
+
|
20 |
+
/**
|
21 |
+
* Overwrite to set default $joinLeft value to true.
|
22 |
+
*
|
23 |
+
* @param bool $joinLeft
|
24 |
+
* @return DataFeedWatch_Connector_Model_Resource_Product_Collection $this
|
25 |
+
*/
|
26 |
+
protected function _productLimitationPrice($joinLeft = true)
|
27 |
+
{
|
28 |
+
parent::_productLimitationPrice($joinLeft);
|
29 |
+
|
30 |
+
return $this;
|
31 |
+
}
|
32 |
+
|
33 |
+
/**
|
34 |
+
* @param array $options
|
35 |
+
* @return DataFeedWatch_Connector_Model_Resource_Product_Collection $this
|
36 |
+
*/
|
37 |
+
public function applyFiltersOnCollection($options)
|
38 |
+
{
|
39 |
+
$this->helper()->log($options);
|
40 |
+
$this->optionsFilters = $options;
|
41 |
+
$this->applyStoreFilter();
|
42 |
+
$this->registryHelper()->initImportRegistry($this->getStoreId());
|
43 |
+
$this->addRuleDate();
|
44 |
+
$this->joinRelationsTable();
|
45 |
+
$this->joinVisibilityTable(DataFeedWatch_Connector_Model_Resource_Product_Collection_Db::VISIBILITY_TABLE_ALIAS_DEFAULT_STORE, '0');
|
46 |
+
$this->joinVisibilityTable(DataFeedWatch_Connector_Model_Resource_Product_Collection_Db::ORIGINAL_VISIBILITY_TABLE_ALIAS, $this->getStoreId());
|
47 |
+
$this->applyTypeFilter();
|
48 |
+
$this->joinQty();
|
49 |
+
$this->addFinalPrice();
|
50 |
+
$this->addUrlRewrite();
|
51 |
+
$this->applyStatusFilter();
|
52 |
+
$this->applyUpdatedAtFilter();
|
53 |
+
$this->addAttributeToSelect('ignore_datafeedwatch');
|
54 |
+
$this->addAttributeToFilter('ignore_datafeedwatch', array(array('null' => true),array('neq' => 1)), 'left');
|
55 |
+
|
56 |
+
|
57 |
+
$this->setPage($this->optionsFilters['page'], $this->optionsFilters['per_page']);
|
58 |
+
$this->helper()->sqlLog($this->getSelect()->__toString());
|
59 |
+
|
60 |
+
return $this;
|
61 |
+
}
|
62 |
+
|
63 |
+
/**
|
64 |
+
* @param $store
|
65 |
+
* @return DataFeedWatch_Connector_Model_Resource_Product_Collection $this
|
66 |
+
*/
|
67 |
+
public function applySpecificStore($store)
|
68 |
+
{
|
69 |
+
$store = Mage::app()->getStore($store);
|
70 |
+
$this->optionsFilters['store'] = $store->getId();
|
71 |
+
|
72 |
+
return $this->applyStoreFilter();
|
73 |
+
}
|
74 |
+
|
75 |
+
/**
|
76 |
+
* @return $this
|
77 |
+
*/
|
78 |
+
protected function applyStoreFilter()
|
79 |
+
{
|
80 |
+
if (isset($this->optionsFilters['store'])) {
|
81 |
+
$store = Mage::getModel('core/store')->load($this->optionsFilters['store']);
|
82 |
+
$StoreColumn = sprintf('IFNULL(null, %s) as store_id', $store->getId());
|
83 |
+
$this->setStoreId($store->getId());
|
84 |
+
$this->addStoreFilter($store);
|
85 |
+
$this->getSelect()->columns($StoreColumn);
|
86 |
+
}
|
87 |
+
|
88 |
+
return $this;
|
89 |
+
}
|
90 |
+
|
91 |
+
/**
|
92 |
+
* @return $this
|
93 |
+
*/
|
94 |
+
protected function applyTypeFilter()
|
95 |
+
{
|
96 |
+
if (isset($this->optionsFilters['type'])) {
|
97 |
+
$this->addAttributeToFilter('type_id', array('in' => $this->optionsFilters['type']));
|
98 |
+
}
|
99 |
+
|
100 |
+
return $this;
|
101 |
+
}
|
102 |
+
|
103 |
+
/**
|
104 |
+
* @return $this
|
105 |
+
*/
|
106 |
+
protected function applyUpdatedAtFilter()
|
107 |
+
{
|
108 |
+
if (!isset($this->optionsFilters['from_date'])) {
|
109 |
+
|
110 |
+
return $this;
|
111 |
+
}
|
112 |
+
|
113 |
+
$this->getSelect()->where($this->ruleDateSelect . ' >= ?', $this->optionsFilters['from_date']);
|
114 |
+
|
115 |
+
return $this;
|
116 |
+
}
|
117 |
+
|
118 |
+
/**
|
119 |
+
* @return $this
|
120 |
+
*/
|
121 |
+
protected function applyStatusFilter()
|
122 |
+
{
|
123 |
+
if (!isset($this->optionsFilters['status'])) {
|
124 |
+
|
125 |
+
return $this;
|
126 |
+
}
|
127 |
+
|
128 |
+
if ($this->registryHelper()->isStatusAttributeInheritable()) {
|
129 |
+
$this->buildFilterStatusCondition();
|
130 |
+
$this->joinInheritedStatusTable(self::INHERITED_STATUS_TABLE_ALIAS, $this->getStoreId())
|
131 |
+
->joinInheritedStatusTable(self::INHERITED_STATUS_TABLE_ALIAS_DEFAULT_STORE, '0')
|
132 |
+
->joinOriginalStatusTable(self::ORIGINAL_STATUS_TABLE_ALIAS, $this->getStoreId())
|
133 |
+
->joinOriginalStatusTable(self::ORIGINAL_STATUS_TABLE_ALIAS_DEFAULT_STORE, '0');
|
134 |
+
$this->getSelect()->where($this->filterStatusCondition . ' = ?', $this->optionsFilters['status']);
|
135 |
+
} else {
|
136 |
+
$this->addAttributeToFilter('status', $this->optionsFilters['status']);
|
137 |
+
}
|
138 |
+
|
139 |
+
return $this;
|
140 |
+
}
|
141 |
+
|
142 |
+
/**
|
143 |
+
* @return $this
|
144 |
+
*/
|
145 |
+
protected function addParentData()
|
146 |
+
{
|
147 |
+
$this->joinRelationsTable();
|
148 |
+
$parentCollection = $this->getParentProductsCollection();
|
149 |
+
$parentCollection = $parentCollection->getItems();
|
150 |
+
foreach ($this->getItems() as $product) {
|
151 |
+
$parentId = $product->getParentId();
|
152 |
+
if (empty($parentId) || !isset($parentCollection[$parentId])) {
|
153 |
+
continue;
|
154 |
+
}
|
155 |
+
$product->setParent($parentCollection[$parentId]);
|
156 |
+
}
|
157 |
+
|
158 |
+
return $this;
|
159 |
+
}
|
160 |
+
|
161 |
+
/**
|
162 |
+
* @return Mage_Catalog_Model_Resource_Product_Collection
|
163 |
+
*/
|
164 |
+
protected function getParentProductsCollection()
|
165 |
+
{
|
166 |
+
$parentCollection = Mage::getResourceModel('datafeedwatch_connector/product_collection')
|
167 |
+
->addAttributeToSelect('*')
|
168 |
+
->addUrlRewrite()
|
169 |
+
->addFinalPrice()
|
170 |
+
->applySpecificStore($this->optionsFilters['store']);
|
171 |
+
|
172 |
+
$parentCollection->getSelect()->joinLeft(
|
173 |
+
array(self::PARENT_CONFIGURABLE_ATTRIBUTES_TABLE_ALIAS =>
|
174 |
+
$this->getTable('catalog/product_super_attribute'),
|
175 |
+
),
|
176 |
+
sprintf('%s.product_id = e.entity_id', self::PARENT_CONFIGURABLE_ATTRIBUTES_TABLE_ALIAS),
|
177 |
+
array('super_attribute_ids' =>
|
178 |
+
sprintf('GROUP_CONCAT(DISTINCT %s.attribute_id)', self::PARENT_CONFIGURABLE_ATTRIBUTES_TABLE_ALIAS),
|
179 |
+
)
|
180 |
+
);
|
181 |
+
|
182 |
+
$parentCollection->getSelect()->joinRight(
|
183 |
+
array(self::PARENT_RELATIONS_TABLE_ALIAS => $this->getTable('catalog/product_relation')),
|
184 |
+
sprintf('%s.parent_id = e.entity_id', self::PARENT_RELATIONS_TABLE_ALIAS),
|
185 |
+
array('parent_id' => sprintf('%s.parent_id', self::PARENT_RELATIONS_TABLE_ALIAS))
|
186 |
+
)->group('e.entity_id');
|
187 |
+
|
188 |
+
return $parentCollection;
|
189 |
+
}
|
190 |
+
|
191 |
+
/**
|
192 |
+
* @return $this
|
193 |
+
*/
|
194 |
+
public function applyInheritanceLogic()
|
195 |
+
{
|
196 |
+
$this->addParentData();
|
197 |
+
foreach ($this->getItems() as $product) {
|
198 |
+
$parent = $product->getParent();
|
199 |
+
if (!empty($parent)) {
|
200 |
+
$product->getParentAttributes();
|
201 |
+
}
|
202 |
+
}
|
203 |
+
|
204 |
+
return $this;
|
205 |
+
}
|
206 |
+
|
207 |
+
/**
|
208 |
+
* @return DataFeedWatch_Connector_Helper_Registry
|
209 |
+
*/
|
210 |
+
public function registryHelper()
|
211 |
+
{
|
212 |
+
return Mage::helper('datafeedwatch_connector/registry');
|
213 |
+
}
|
214 |
+
|
215 |
+
/**
|
216 |
+
* @return DataFeedWatch_Connector_Helper_Data
|
217 |
+
*/
|
218 |
+
public function helper()
|
219 |
+
{
|
220 |
+
return Mage::helper('datafeedwatch_connector');
|
221 |
+
}
|
222 |
+
}
|
app/code/community/DataFeedWatch/Connector/Model/Resource/Product/Collection/Db.php
ADDED
@@ -0,0 +1,306 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
|
3 |
+
class DataFeedWatch_Connector_Model_Resource_Product_Collection_Db
|
4 |
+
extends Mage_Catalog_Model_Resource_Product_Collection
|
5 |
+
{
|
6 |
+
const PRODUCT_RELATIONS_TABLE_ALIAS = 'product_relation';
|
7 |
+
const INHERITED_STATUS_TABLE_ALIAS = 'inherited_status';
|
8 |
+
const INHERITED_STATUS_TABLE_ALIAS_DEFAULT_STORE = 'inherited_status_default_store';
|
9 |
+
const ORIGINAL_STATUS_TABLE_ALIAS = 'original_status';
|
10 |
+
const ORIGINAL_STATUS_TABLE_ALIAS_DEFAULT_STORE = 'status_default_store';
|
11 |
+
const ORIGINAL_VISIBILITY_TABLE_ALIAS = 'original_visibility';
|
12 |
+
const VISIBILITY_TABLE_ALIAS_DEFAULT_STORE = 'visibility_default_store';
|
13 |
+
const MIXED_STATUS_COLUMN_ALIAS = 'filter_status';
|
14 |
+
const PARENT_CONFIGURABLE_ATTRIBUTES_TABLE_ALIAS = 'parent_configurable_attributes';
|
15 |
+
const PARENT_RELATIONS_TABLE_ALIAS = 'parent_relation';
|
16 |
+
const UPDATED_AT_TABLE_ALIAS = 'custom_updated_at';
|
17 |
+
const PARENT_UPDATED_AT_TABLE_ALIAS = 'parent_custom_updated_at';
|
18 |
+
const CATALOGRULE_DATE_COLUMN_ALIAS = 'rule_date';
|
19 |
+
|
20 |
+
/** @var string $filterStatusCondition */
|
21 |
+
protected $filterStatusCondition;
|
22 |
+
/** @var array $optionsFilters */
|
23 |
+
protected $optionsFilters;
|
24 |
+
/** @var string $ruleDateSelect */
|
25 |
+
protected $ruleDateSelect;
|
26 |
+
|
27 |
+
/**
|
28 |
+
* @param string $tableAlias
|
29 |
+
* @return bool
|
30 |
+
* @throws Zend_Db_Select_Exception
|
31 |
+
*/
|
32 |
+
protected function isTableAliasAdded($tableAlias)
|
33 |
+
{
|
34 |
+
$tables = $this->getSelect()->getPart(Zend_Db_Select::FROM);
|
35 |
+
$currentAliases = array_keys($tables);
|
36 |
+
|
37 |
+
return in_array($tableAlias, $currentAliases);
|
38 |
+
|
39 |
+
}
|
40 |
+
|
41 |
+
/**
|
42 |
+
* @return $this
|
43 |
+
*/
|
44 |
+
protected function addRuleDate()
|
45 |
+
{
|
46 |
+
/** @var DataFeedWatch_Connector_Model_Cron $cron */
|
47 |
+
$cron = Mage::getModel('datafeedwatch_connector/cron');
|
48 |
+
$cron->reindex();
|
49 |
+
|
50 |
+
$condition = $this->getUpdatedAtCondition();
|
51 |
+
$select = new Zend_Db_Select($this->getEntity()->getReadConnection());
|
52 |
+
$select->from(
|
53 |
+
array(
|
54 |
+
self::UPDATED_AT_TABLE_ALIAS => $this->getTable('datafeedwatch_connector/updated_products'),
|
55 |
+
),
|
56 |
+
array(
|
57 |
+
sprintf('COALESCE(%1$s.updated_at, 0)', self::UPDATED_AT_TABLE_ALIAS),
|
58 |
+
)
|
59 |
+
);
|
60 |
+
$select->where($condition);
|
61 |
+
$select->limit(1);
|
62 |
+
|
63 |
+
$this->ruleDateSelect = sprintf('GREATEST(IFNULL((%s), 0), COALESCE(%2$s.updated_at, 0), COALESCE(%3$s.updated_at, 0))',
|
64 |
+
$select->__toString(), self::MAIN_TABLE_ALIAS, self::PARENT_UPDATED_AT_TABLE_ALIAS);
|
65 |
+
$this->getSelect()->columns(array(self::CATALOGRULE_DATE_COLUMN_ALIAS => new Zend_Db_Expr($this->ruleDateSelect)));
|
66 |
+
|
67 |
+
return $this;
|
68 |
+
}
|
69 |
+
|
70 |
+
/**
|
71 |
+
* @return string
|
72 |
+
* @throws Mage_Core_Exception
|
73 |
+
*/
|
74 |
+
protected function getUpdatedAtCondition()
|
75 |
+
{
|
76 |
+
$condition = '((%3$s.parent_id IS NOT NULL AND %1$s.product_id = %3$s.parent_id) OR %1$s.product_id = %2$s.entity_id)';
|
77 |
+
$condition = sprintf($condition,
|
78 |
+
self::UPDATED_AT_TABLE_ALIAS, self::MAIN_TABLE_ALIAS, self::PRODUCT_RELATIONS_TABLE_ALIAS,
|
79 |
+
Mage_Customer_Model_Group::NOT_LOGGED_IN_ID,
|
80 |
+
Mage::app()->getWebsite()->getId(), Mage::app()->getDefaultStoreView()->getWebsiteId());
|
81 |
+
|
82 |
+
return $condition;
|
83 |
+
}
|
84 |
+
|
85 |
+
/**
|
86 |
+
* @return $this
|
87 |
+
* @throws Mage_Core_Exception
|
88 |
+
*/
|
89 |
+
protected function joinQty()
|
90 |
+
{
|
91 |
+
$this->joinField('qty',
|
92 |
+
'cataloginventory/stock_item',
|
93 |
+
'qty',
|
94 |
+
'product_id=entity_id',
|
95 |
+
'{{table}}.stock_id=1',
|
96 |
+
'left');
|
97 |
+
|
98 |
+
return $this;
|
99 |
+
}
|
100 |
+
/**
|
101 |
+
* @return string
|
102 |
+
* @throws Mage_Core_Exception
|
103 |
+
*/
|
104 |
+
protected function getStatusTable()
|
105 |
+
{
|
106 |
+
return Mage::registry(DataFeedWatch_Connector_Helper_Registry::DFW_STATUS_ATTRIBUTE_KEY)
|
107 |
+
->getBackend()->getTable();
|
108 |
+
}
|
109 |
+
|
110 |
+
/**
|
111 |
+
* @return string
|
112 |
+
* @throws Mage_Core_Exception
|
113 |
+
*/
|
114 |
+
protected function getVisibilityTable()
|
115 |
+
{
|
116 |
+
return Mage::registry(DataFeedWatch_Connector_Helper_Registry::DFW_STATUS_ATTRIBUTE_KEY)
|
117 |
+
->getBackend()->getTable();
|
118 |
+
}
|
119 |
+
|
120 |
+
/**
|
121 |
+
* @return string|int
|
122 |
+
* @throws Mage_Core_Exception
|
123 |
+
*/
|
124 |
+
protected function getVisibilityAttributeId()
|
125 |
+
{
|
126 |
+
return Mage::registry(DataFeedWatch_Connector_Helper_Registry::DFW_STATUS_ATTRIBUTE_KEY)->getAttributeId();
|
127 |
+
}
|
128 |
+
|
129 |
+
/**
|
130 |
+
* @return $this
|
131 |
+
*/
|
132 |
+
protected function joinRelationsTable()
|
133 |
+
{
|
134 |
+
if ($this->isTableAliasAdded(self::PRODUCT_RELATIONS_TABLE_ALIAS)) {
|
135 |
+
|
136 |
+
return $this;
|
137 |
+
}
|
138 |
+
|
139 |
+
$this->getSelect()->joinLeft(
|
140 |
+
array(self::PRODUCT_RELATIONS_TABLE_ALIAS => $this->getTable('catalog/product_relation')),
|
141 |
+
sprintf('%s.child_id = %s.entity_id', self::PRODUCT_RELATIONS_TABLE_ALIAS, self::MAIN_TABLE_ALIAS),
|
142 |
+
array('parent_id' => sprintf('%s.parent_id', self::PRODUCT_RELATIONS_TABLE_ALIAS))
|
143 |
+
)->group(sprintf('%s.entity_id', self::MAIN_TABLE_ALIAS));
|
144 |
+
|
145 |
+
|
146 |
+
$this->getSelect()->joinLeft(
|
147 |
+
array(self::PARENT_UPDATED_AT_TABLE_ALIAS => $this->getTable('catalog/product')),
|
148 |
+
sprintf('%s.parent_id = %s.entity_id', self::PRODUCT_RELATIONS_TABLE_ALIAS, self::PARENT_UPDATED_AT_TABLE_ALIAS),
|
149 |
+
array('parent_updated_at' => sprintf('%s.updated_at', self::PARENT_UPDATED_AT_TABLE_ALIAS))
|
150 |
+
);
|
151 |
+
|
152 |
+
return $this;
|
153 |
+
}
|
154 |
+
|
155 |
+
protected function buildFilterStatusCondition()
|
156 |
+
{
|
157 |
+
$childString = 'IFNULL(%1$s.value, %3$s.value)';
|
158 |
+
$parentString = 'IFNULL(%2$s.value, %4$s.value)';
|
159 |
+
$enable = Mage_Catalog_Model_Product_Status::STATUS_ENABLED;
|
160 |
+
$statusAttribute = Mage::registry(DataFeedWatch_Connector_Helper_Registry::DFW_STATUS_ATTRIBUTE_KEY);
|
161 |
+
switch($statusAttribute->getDfwInheritance()) {
|
162 |
+
case (string) DataFeedWatch_Connector_Model_System_Config_Source_Inheritance::CHILD_THEN_PARENT_OPTION_ID:
|
163 |
+
$inheritString = "IFNULL({$childString}, {$parentString})";
|
164 |
+
// $inheritWithStatusString = 'IFNULL(
|
165 |
+
// IF(' . $childString . ' <> ' . $enable . ', ' . $parentString . ', ' . $childString . '),
|
166 |
+
// ' . $childString
|
167 |
+
// . ')';
|
168 |
+
$notVisibleIndividually = "IF({$childString} <> {$enable}, {$childString}, {$parentString})";
|
169 |
+
$string = 'IF(IFNULL(%5$s.value, %6$s.value) = '. Mage_Catalog_Model_Product_Visibility::VISIBILITY_NOT_VISIBLE
|
170 |
+
. ', ' . $notVisibleIndividually .', '. $inheritString.')';
|
171 |
+
break;
|
172 |
+
case (string) DataFeedWatch_Connector_Model_System_Config_Source_Inheritance::PARENT_OPTION_ID:
|
173 |
+
$string = 'IFNULL(' . $parentString . ', ' . $childString . ')';
|
174 |
+
break;
|
175 |
+
default :
|
176 |
+
$string = $childString;
|
177 |
+
}
|
178 |
+
$this->filterStatusCondition = sprintf($string,
|
179 |
+
self::ORIGINAL_STATUS_TABLE_ALIAS, self::INHERITED_STATUS_TABLE_ALIAS,
|
180 |
+
self::ORIGINAL_STATUS_TABLE_ALIAS_DEFAULT_STORE, self::INHERITED_STATUS_TABLE_ALIAS_DEFAULT_STORE,
|
181 |
+
self::ORIGINAL_VISIBILITY_TABLE_ALIAS, self::VISIBILITY_TABLE_ALIAS_DEFAULT_STORE
|
182 |
+
);
|
183 |
+
}
|
184 |
+
|
185 |
+
/**
|
186 |
+
* @param string $tableAlias
|
187 |
+
* @param string $storeId
|
188 |
+
* @return $this
|
189 |
+
*/
|
190 |
+
protected function joinInheritedStatusTable($tableAlias = self::INHERITED_STATUS_TABLE_ALIAS, $storeId = '0')
|
191 |
+
{
|
192 |
+
if ($this->isTableAliasAdded($tableAlias)) {
|
193 |
+
|
194 |
+
return $this;
|
195 |
+
}
|
196 |
+
|
197 |
+
$this->getSelect()->joinLeft(
|
198 |
+
array($tableAlias => $this->getStatusTable()),
|
199 |
+
$this->getJoinInheritedStatusTableStatement($tableAlias, $storeId),
|
200 |
+
array(self::MIXED_STATUS_COLUMN_ALIAS => $this->filterStatusCondition));
|
201 |
+
|
202 |
+
return $this;
|
203 |
+
}
|
204 |
+
|
205 |
+
/**
|
206 |
+
* @param string $tableAlias
|
207 |
+
* @param string $storeId
|
208 |
+
* @return string
|
209 |
+
*/
|
210 |
+
protected function getJoinInheritedStatusTableStatement($tableAlias, $storeId)
|
211 |
+
{
|
212 |
+
return sprintf('%1$s.entity_id = %2$s.parent_id and %3$s',
|
213 |
+
$tableAlias, self::PRODUCT_RELATIONS_TABLE_ALIAS,
|
214 |
+
$this->getJoinStatusAttributeStatement($tableAlias, $storeId)
|
215 |
+
);
|
216 |
+
}
|
217 |
+
|
218 |
+
/**
|
219 |
+
* @param string $tableAlias
|
220 |
+
* @param string $storeId
|
221 |
+
* @return $this
|
222 |
+
*/
|
223 |
+
protected function joinOriginalStatusTable($tableAlias = self::ORIGINAL_STATUS_TABLE_ALIAS, $storeId = '0')
|
224 |
+
{
|
225 |
+
if ($this->isTableAliasAdded($tableAlias)) {
|
226 |
+
|
227 |
+
return $this;
|
228 |
+
}
|
229 |
+
|
230 |
+
$this->getSelect()->joinLeft(
|
231 |
+
array($tableAlias => $this->getStatusTable()),
|
232 |
+
$this->getJoinOriginalStatusTableStatement($tableAlias, $storeId),
|
233 |
+
array(self::MIXED_STATUS_COLUMN_ALIAS => $this->filterStatusCondition));
|
234 |
+
|
235 |
+
return $this;
|
236 |
+
}
|
237 |
+
|
238 |
+
/**
|
239 |
+
* @param string $tableAlias
|
240 |
+
* @param string $storeId
|
241 |
+
* @return $this
|
242 |
+
*/
|
243 |
+
protected function joinVisibilityTable($tableAlias = self::VISIBILITY_TABLE_ALIAS_DEFAULT_STORE, $storeId = '0')
|
244 |
+
{
|
245 |
+
if ($this->isTableAliasAdded($tableAlias)) {
|
246 |
+
|
247 |
+
return $this;
|
248 |
+
}
|
249 |
+
|
250 |
+
$this->getSelect()->joinLeft(
|
251 |
+
array($tableAlias => $this->getVisibilityTable()),
|
252 |
+
$this->getJoinVisibilityTableStatement($tableAlias, $storeId),
|
253 |
+
array('value'));
|
254 |
+
|
255 |
+
return $this;
|
256 |
+
}
|
257 |
+
|
258 |
+
/**
|
259 |
+
* @param string $tableAlias
|
260 |
+
* @param string $storeId
|
261 |
+
* @return string
|
262 |
+
*/
|
263 |
+
protected function getJoinVisibilityTableStatement($tableAlias, $storeId)
|
264 |
+
{
|
265 |
+
return sprintf('%1$s.entity_id = e.entity_id and %2$s',
|
266 |
+
$tableAlias, $this->getJoinVisibilityAttributeStatement($tableAlias, $storeId)
|
267 |
+
);
|
268 |
+
}
|
269 |
+
|
270 |
+
/**
|
271 |
+
* @param string $tableAlias
|
272 |
+
* @param string $storeId
|
273 |
+
* @return string
|
274 |
+
*/
|
275 |
+
protected function getJoinVisibilityAttributeStatement($tableAlias, $storeId = '0')
|
276 |
+
{
|
277 |
+
$visibilityAttribute = Mage::registry(DataFeedWatch_Connector_Helper_Registry::DFW_VISIBILITY_ATTRIBUTE_KEY);
|
278 |
+
return sprintf('%1$s.attribute_id = %2$s and %1$s.store_id = %3$s',
|
279 |
+
$tableAlias, $visibilityAttribute->getId(), $storeId);
|
280 |
+
}
|
281 |
+
|
282 |
+
/**
|
283 |
+
* @param string $tableAlias
|
284 |
+
* @param string $storeId
|
285 |
+
* @return string
|
286 |
+
*/
|
287 |
+
protected function getJoinOriginalStatusTableStatement($tableAlias, $storeId)
|
288 |
+
{
|
289 |
+
return sprintf('%1$s.entity_id = e.entity_id and %2$s',
|
290 |
+
$tableAlias, $this->getJoinStatusAttributeStatement($tableAlias, $storeId)
|
291 |
+
);
|
292 |
+
}
|
293 |
+
|
294 |
+
/**
|
295 |
+
* @param string $tableAlias
|
296 |
+
* @param string $storeId
|
297 |
+
* @return string
|
298 |
+
*/
|
299 |
+
protected function getJoinStatusAttributeStatement($tableAlias, $storeId = '0')
|
300 |
+
{
|
301 |
+
$statusAttribute = Mage::registry(DataFeedWatch_Connector_Helper_Registry::DFW_STATUS_ATTRIBUTE_KEY);
|
302 |
+
return sprintf('%1$s.attribute_id = %2$s and %1$s.store_id = %3$s',
|
303 |
+
$tableAlias, $statusAttribute->getId(), $storeId);
|
304 |
+
}
|
305 |
+
|
306 |
+
}
|
app/code/community/DataFeedWatch/Connector/Model/Resource/Salesrule/Info.php
DELETED
@@ -1,8 +0,0 @@
|
|
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
DELETED
@@ -1,7 +0,0 @@
|
|
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
DELETED
@@ -1,5 +0,0 @@
|
|
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
DELETED
@@ -1,8 +0,0 @@
|
|
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
DELETED
@@ -1,7 +0,0 @@
|
|
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/System/Config/Source/Inheritance.php
ADDED
@@ -0,0 +1,55 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
|
3 |
+
class DataFeedWatch_Connector_Model_System_Config_Source_Inheritance
|
4 |
+
{
|
5 |
+
const CHILD_OPTION_ID = 1;
|
6 |
+
const CHILD_OPTION_LABEL = 'Child';
|
7 |
+
const PARENT_OPTION_ID = 2;
|
8 |
+
const PARENT_OPTION_LABEL = 'Parent';
|
9 |
+
const CHILD_THEN_PARENT_OPTION_ID = 3;
|
10 |
+
const CHILD_THEN_PARENT_OPTION_LABEL = 'Child Then Parent';
|
11 |
+
|
12 |
+
/**
|
13 |
+
* @return array
|
14 |
+
*/
|
15 |
+
public function toOptionArray()
|
16 |
+
{
|
17 |
+
return array(
|
18 |
+
array(
|
19 |
+
'value' => self::CHILD_OPTION_ID,
|
20 |
+
'label' => $this->_helper()->__(self::CHILD_OPTION_LABEL),
|
21 |
+
),
|
22 |
+
array(
|
23 |
+
'value' => self::PARENT_OPTION_ID,
|
24 |
+
'label' => $this->_helper()->__(self::PARENT_OPTION_LABEL),
|
25 |
+
),
|
26 |
+
array(
|
27 |
+
'value' => self::CHILD_THEN_PARENT_OPTION_ID,
|
28 |
+
'label' => $this->_helper()->__(self::CHILD_THEN_PARENT_OPTION_LABEL),
|
29 |
+
),
|
30 |
+
);
|
31 |
+
}
|
32 |
+
|
33 |
+
/**
|
34 |
+
* @return array
|
35 |
+
*/
|
36 |
+
public function toArray()
|
37 |
+
{
|
38 |
+
return array(
|
39 |
+
self::CHILD_OPTION_ID =>
|
40 |
+
$this->_helper()->__(self::CHILD_OPTION_LABEL),
|
41 |
+
self::PARENT_OPTION_ID =>
|
42 |
+
$this->_helper()->__(self::PARENT_OPTION_LABEL),
|
43 |
+
self::CHILD_THEN_PARENT_OPTION_ID =>
|
44 |
+
$this->_helper()->__(self::CHILD_THEN_PARENT_OPTION_LABEL),
|
45 |
+
);
|
46 |
+
}
|
47 |
+
|
48 |
+
/**
|
49 |
+
* @return DataFeedWatch_Connector_Helper_Data
|
50 |
+
*/
|
51 |
+
public function _helper()
|
52 |
+
{
|
53 |
+
return Mage::helper('datafeedwatch_connector');
|
54 |
+
}
|
55 |
+
}
|
app/code/community/DataFeedWatch/Connector/controllers/Adminhtml/ConnectorsettingsController.php
DELETED
@@ -1,160 +0,0 @@
|
|
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
|
21 |
-
$cacheType = 'config';
|
22 |
-
Mage::app()->getCacheInstance()->cleanType($cacheType);
|
23 |
-
Mage::dispatchEvent('adminhtml_cache_refresh_type', array('type' => $cacheType));
|
24 |
-
|
25 |
-
Mage::getSingleton('adminhtml/session')->addSuccess(Mage::helper('connector')->__('Settings were successfully saved.'));
|
26 |
-
$this->_redirect('*/*/*');
|
27 |
-
return;
|
28 |
-
}
|
29 |
-
$this->loadLayout();
|
30 |
-
$this->renderLayout();
|
31 |
-
}
|
32 |
-
|
33 |
-
protected $username = 'datafeedwatch';
|
34 |
-
protected $firstname = 'Api Access';
|
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 |
-
|
49 |
-
//Create Api Role for datafeedwatch user
|
50 |
-
$role = $this->_createApiRole();
|
51 |
-
|
52 |
-
//Prepare Api Key
|
53 |
-
$api_key = $this->_generateApiKey();
|
54 |
-
|
55 |
-
//send the api key to DFW
|
56 |
-
file_get_contents($this->_registerUrl($api_key));
|
57 |
-
|
58 |
-
//Get Api User
|
59 |
-
$user = $this->getUser();
|
60 |
-
if ($user->getId()) {
|
61 |
-
//Update Api User
|
62 |
-
$user = $this->_updateApiUser($api_key, $user);
|
63 |
-
} else {
|
64 |
-
//Create Api User
|
65 |
-
$user = $this->_createApiUser($api_key);
|
66 |
-
}
|
67 |
-
|
68 |
-
//Assign Api User to the Api Role
|
69 |
-
$user->setRoleId($role->getId())->setUserId($user->getId());
|
70 |
-
$user->add();
|
71 |
-
|
72 |
-
//redirect to register token url in DFW
|
73 |
-
$this->getResponse()->setRedirect($this->_registerUrl($api_key));
|
74 |
-
return;
|
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 |
-
|
86 |
-
public function getUser() {
|
87 |
-
$model = Mage::getModel('api/user');
|
88 |
-
return $model->load($this->email, 'email');
|
89 |
-
}
|
90 |
-
|
91 |
-
private function _generateApiKey() {
|
92 |
-
return sha1(time()+substr(str_shuffle("0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ"), 0, 32));
|
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(){
|
104 |
-
$role = Mage::getModel('api/roles')->load($this->lastname, 'role_name');
|
105 |
-
if ($role->isObjectNew()) {
|
106 |
-
$role = $role
|
107 |
-
->setName($this->lastname)
|
108 |
-
->setPid(false)
|
109 |
-
->setRoleType('G')
|
110 |
-
->save();
|
111 |
-
|
112 |
-
$resource = array("all");
|
113 |
-
|
114 |
-
Mage::getModel("api/rules")
|
115 |
-
->setRoleId($role->getId())
|
116 |
-
->setResources($resource)
|
117 |
-
->saveRel();
|
118 |
-
}
|
119 |
-
return $role;
|
120 |
-
}
|
121 |
-
|
122 |
-
private function _createApiUser($api_key){
|
123 |
-
$data = array(
|
124 |
-
'username' => $this->username,
|
125 |
-
'firstname' => $this->firstname,
|
126 |
-
'lastname' => $this->lastname,
|
127 |
-
'email' => $this->email,
|
128 |
-
'is_active' => 1,
|
129 |
-
'api_key' => $api_key,
|
130 |
-
'api_key_confirmation' => $api_key,
|
131 |
-
);
|
132 |
-
|
133 |
-
$user = Mage::getModel('api/user');
|
134 |
-
$user->setData($data);
|
135 |
-
$user->save();
|
136 |
-
return $user;
|
137 |
-
}
|
138 |
-
|
139 |
-
/**
|
140 |
-
* @param $api_key string
|
141 |
-
* @param $user Mage_Api_Model_User
|
142 |
-
*
|
143 |
-
* @return Mage_Api_Model_User
|
144 |
-
*/
|
145 |
-
|
146 |
-
private function _updateApiUser($api_key, $user) {
|
147 |
-
$data = array(
|
148 |
-
'username' => $this->username,
|
149 |
-
'firstname' => $this->firstname,
|
150 |
-
'lastname' => $this->lastname,
|
151 |
-
'is_active' => 1,
|
152 |
-
'api_key' => $api_key,
|
153 |
-
'api_key_confirmation' => $api_key,
|
154 |
-
);
|
155 |
-
|
156 |
-
$user->setData($data);
|
157 |
-
$user->save();
|
158 |
-
return $user;
|
159 |
-
}
|
160 |
-
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
app/code/community/DataFeedWatch/Connector/controllers/Adminhtml/DatafeedwatchController.php
ADDED
@@ -0,0 +1,121 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
|
3 |
+
class DataFeedWatch_Connector_Adminhtml_DatafeedwatchController
|
4 |
+
extends Mage_Adminhtml_Controller_Action
|
5 |
+
{
|
6 |
+
/**
|
7 |
+
* @return Mage_Core_Controller_Response_Http
|
8 |
+
*/
|
9 |
+
public function openAction()
|
10 |
+
{
|
11 |
+
$apiUser = $this->getApiUserModel();
|
12 |
+
$apiUser->loadDfwUser();
|
13 |
+
/** @var DataFeedWatch_Connector_Helper_Data $helper */
|
14 |
+
$helper = Mage::helper('datafeedwatch_connector');
|
15 |
+
if (!$apiUser->isObjectNew()) {
|
16 |
+
return $this->getResponse()->setRedirect($helper->getDataFeedWatchUrl());
|
17 |
+
}
|
18 |
+
|
19 |
+
$apiUser->createDfwUser();
|
20 |
+
|
21 |
+
return $this->getResponse()->setRedirect($apiUser->getRegisterUrl());
|
22 |
+
}
|
23 |
+
|
24 |
+
/**
|
25 |
+
* @return Mage_Core_Controller_Response_Http
|
26 |
+
*/
|
27 |
+
public function addStoreAction()
|
28 |
+
{
|
29 |
+
$apiUser = $this->getApiUserModel();
|
30 |
+
$apiUser->loadDfwUser();
|
31 |
+
$apiUser->createDfwUser();
|
32 |
+
|
33 |
+
return $this->getResponse()->setRedirect($apiUser->getRegisterUrl());
|
34 |
+
}
|
35 |
+
|
36 |
+
/**
|
37 |
+
* @return Mage_Adminhtml_Controller_Action
|
38 |
+
*/
|
39 |
+
public function extortAction()
|
40 |
+
{
|
41 |
+
Mage::helper('datafeedwatch_connector')->updateLastInheritanceUpdateDate();
|
42 |
+
|
43 |
+
return $this->_redirectReferer();
|
44 |
+
}
|
45 |
+
|
46 |
+
/**
|
47 |
+
* @return Mage_Adminhtml_Controller_Action
|
48 |
+
*/
|
49 |
+
public function refreshAction()
|
50 |
+
{
|
51 |
+
$apiUser = $this->getApiUserModel();
|
52 |
+
$apiUser->loadDfwUser();
|
53 |
+
$apiUser->createDfwUser();
|
54 |
+
|
55 |
+
$this->_getSession()
|
56 |
+
->addSuccess($this->__('%s user has been refreshed.', DataFeedWatch_Connector_Model_Api_User::USER_NAME));
|
57 |
+
|
58 |
+
return $this->_redirectReferer();
|
59 |
+
}
|
60 |
+
|
61 |
+
/**
|
62 |
+
* @return Mage_Adminhtml_Controller_Action
|
63 |
+
*/
|
64 |
+
public function restoreOriginalAttributeConfigAction()
|
65 |
+
{
|
66 |
+
Mage::helper('datafeedwatch_connector')->restoreOriginalAttributesConfig();
|
67 |
+
|
68 |
+
$this->_getSession()
|
69 |
+
->addSuccess($this->__('Original inheritance configuration has been restored.'));
|
70 |
+
|
71 |
+
return $this->_redirectReferer();
|
72 |
+
}
|
73 |
+
|
74 |
+
/**
|
75 |
+
* @return Zend_Controller_Response_Abstract
|
76 |
+
*/
|
77 |
+
public function renderInheritanceGridAction()
|
78 |
+
{
|
79 |
+
$page = $this->getRequest()->getParam('page');
|
80 |
+
$limit = $this->getRequest()->getParam('limit');
|
81 |
+
|
82 |
+
$this->loadLayout();
|
83 |
+
|
84 |
+
$grid = $this->getLayout()
|
85 |
+
->getBlock('datafeedwatch_connector_inheritance_grid_items')
|
86 |
+
->setPage($page)
|
87 |
+
->setLimit($limit)
|
88 |
+
->toHtml();
|
89 |
+
|
90 |
+
return $this->getResponse()->setBody($grid);
|
91 |
+
}
|
92 |
+
|
93 |
+
public function saveAttributeInheritanceAction()
|
94 |
+
{
|
95 |
+
$attributeId = $this->getRequest()->getParam('attribute_id');
|
96 |
+
$value = $this->getRequest()->getParam('value');
|
97 |
+
|
98 |
+
$attribute = Mage::getModel('datafeedwatch_connector/catalog_attribute_info')
|
99 |
+
->loadByAttributeId($attributeId);
|
100 |
+
$attribute->setInheritance($value)->save();
|
101 |
+
}
|
102 |
+
|
103 |
+
public function saveAttributeImportAction()
|
104 |
+
{
|
105 |
+
$attributeId = $this->getRequest()->getParam('attribute_id');
|
106 |
+
$value = $this->getRequest()->getParam('value');
|
107 |
+
|
108 |
+
$attribute = Mage::getModel('datafeedwatch_connector/catalog_attribute_info')
|
109 |
+
->loadByAttributeId($attributeId);
|
110 |
+
$attribute->setImportToDfw($value)->save();
|
111 |
+
|
112 |
+
}
|
113 |
+
|
114 |
+
/**
|
115 |
+
* @return DataFeedWatch_Connector_Model_Api_User
|
116 |
+
*/
|
117 |
+
protected function getApiUserModel()
|
118 |
+
{
|
119 |
+
return Mage::getModel('datafeedwatch_connector/api_user');
|
120 |
+
}
|
121 |
+
}
|
app/code/community/DataFeedWatch/Connector/data/datafeedwatch_connector_setup/data-upgrade-0.2.40-0.2.50.php
ADDED
@@ -0,0 +1,48 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
/** @var DataFeedWatch_Connector_Model_Api_User $apiUser */
|
3 |
+
$apiUser = Mage::getModel('datafeedwatch_connector/api_user');
|
4 |
+
$apiUser->loadDfwUser();
|
5 |
+
$apiUser->createDfwUser();
|
6 |
+
|
7 |
+
|
8 |
+
$installer = Mage::getResourceModel('catalog/setup', 'default_setup');
|
9 |
+
|
10 |
+
$installer->addAttribute(Mage_Catalog_Model_Product::ENTITY, 'ignore_datafeedwatch', array(
|
11 |
+
'group' => 'General',
|
12 |
+
'input' => 'select',
|
13 |
+
'type' => 'int',
|
14 |
+
'label' => 'Ignore In DataFeedWatch',
|
15 |
+
'source' => 'eav/entity_attribute_source_boolean',
|
16 |
+
'global' => Mage_Catalog_Model_Resource_Eav_Attribute::SCOPE_GLOBAL,
|
17 |
+
'visible' => true,
|
18 |
+
'required' => false,
|
19 |
+
'visible_on_front' => false,
|
20 |
+
'is_html_allowed_on_front' => false,
|
21 |
+
'is_configurable' => false,
|
22 |
+
'searchable' => false,
|
23 |
+
'filterable' => false,
|
24 |
+
'comparable' => false,
|
25 |
+
'unique' => false,
|
26 |
+
'user_defined' => true,
|
27 |
+
'default' => '0',
|
28 |
+
'is_user_defined' => false,
|
29 |
+
'used_in_product_listing' => false
|
30 |
+
));
|
31 |
+
$attribute = Mage::getModel('eav/entity_attribute')->loadByCode(Mage_Catalog_Model_Product::ENTITY, 'ignore_datafeedwatch');
|
32 |
+
|
33 |
+
Mage::getModel('datafeedwatch_connector/catalog_attribute_info')
|
34 |
+
->setCatalogAttributeId($attribute->getId())
|
35 |
+
->setImportToDfw(0)
|
36 |
+
->setCanConfigureImport(0)
|
37 |
+
->setCanConfigureInheritance(0)
|
38 |
+
->setInheritance(DataFeedWatch_Connector_Model_System_Config_Source_Inheritance::CHILD_OPTION_ID)
|
39 |
+
->save();
|
40 |
+
|
41 |
+
|
42 |
+
Mage::helper('datafeedwatch_connector')->restoreOriginalAttributesConfig();
|
43 |
+
|
44 |
+
|
45 |
+
/** @var DataFeedWatch_Connector_Model_Cron $cron */
|
46 |
+
$cron = Mage::getModel('datafeedwatch_connector/cron');
|
47 |
+
|
48 |
+
$cron->reindex();
|
app/code/community/DataFeedWatch/Connector/etc/adminhtml.xml
ADDED
@@ -0,0 +1,40 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?xml version="1.0" encoding="utf-8"?>
|
2 |
+
<config>
|
3 |
+
<menu>
|
4 |
+
<system>
|
5 |
+
<children>
|
6 |
+
<connector translate="title" module="datafeedwatch_connector">
|
7 |
+
<title>DataFeedWatch</title>
|
8 |
+
<action>adminhtml/system_config/edit/section/datafeedwatch_connector</action>
|
9 |
+
</connector>
|
10 |
+
</children>
|
11 |
+
</system>
|
12 |
+
</menu>
|
13 |
+
|
14 |
+
<acl>
|
15 |
+
<resources>
|
16 |
+
<admin>
|
17 |
+
<system>
|
18 |
+
<children>
|
19 |
+
<connector translate="title" module="datafeedwatch_connector">
|
20 |
+
<title>DataFeedWatch</title>
|
21 |
+
</connector>
|
22 |
+
</children>
|
23 |
+
</system>
|
24 |
+
<children>
|
25 |
+
<system>
|
26 |
+
<children>
|
27 |
+
<config>
|
28 |
+
<children>
|
29 |
+
<datafeedwatch_connector>
|
30 |
+
<title>DataFeedWatch Connector</title>
|
31 |
+
</datafeedwatch_connector>
|
32 |
+
</children>
|
33 |
+
</config>
|
34 |
+
</children>
|
35 |
+
</system>
|
36 |
+
</children>
|
37 |
+
</admin>
|
38 |
+
</resources>
|
39 |
+
</acl>
|
40 |
+
</config>
|
app/code/community/DataFeedWatch/Connector/etc/api.xml
CHANGED
@@ -1,38 +1,35 @@
|
|
1 |
-
<?xml version="1.0"?>
|
2 |
<config>
|
3 |
<api>
|
4 |
<resources>
|
5 |
-
<datafeedwatch translate="title" module="
|
6 |
<title>DataFeedWatch API</title>
|
7 |
-
<model>
|
8 |
-
<methods>
|
9 |
-
<version translate="title" module="
|
10 |
<title>Retrieve extension version</title>
|
11 |
</version>
|
12 |
-
<
|
|
|
|
|
|
|
|
|
|
|
|
|
13 |
<title>Retrieve products</title>
|
14 |
</products>
|
15 |
-
<product_count translate="title" module="
|
16 |
<title>Retrieve product count</title>
|
17 |
</product_count>
|
18 |
-
<
|
19 |
-
<title>Retrieve stores</title>
|
20 |
-
</stores>
|
21 |
-
<product_ids translate="title" module="connector">
|
22 |
-
<title>Retrieve Product Ids</title>
|
23 |
-
</product_ids>
|
24 |
-
<synced_fields translate="title" module="connector">
|
25 |
-
<title>Retrieve selected attributes</title>
|
26 |
-
</synced_fields>
|
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="
|
34 |
<title>Retrieve product count based on last update</title>
|
35 |
</updated_product_count>
|
|
|
|
|
|
|
36 |
</methods>
|
37 |
</datafeedwatch>
|
38 |
</resources>
|
1 |
+
<?xml version="1.0" encoding="utf-8"?>
|
2 |
<config>
|
3 |
<api>
|
4 |
<resources>
|
5 |
+
<datafeedwatch translate="title" module="datafeedwatch_connector">
|
6 |
<title>DataFeedWatch API</title>
|
7 |
+
<model>datafeedwatch_connector/api</model>
|
8 |
+
<methods>
|
9 |
+
<version translate="title" module="datafeedwatch_connector">
|
10 |
<title>Retrieve extension version</title>
|
11 |
</version>
|
12 |
+
<gmt_offset translate="title" module="datafeedwatch_connector">
|
13 |
+
<title>Retrieve datetime in GMT</title>
|
14 |
+
</gmt_offset>
|
15 |
+
<stores translate="title" module="datafeedwatch_connector">
|
16 |
+
<title>Retrieve stores</title>
|
17 |
+
</stores>
|
18 |
+
<products translate="title" module="datafeedwatch_connector">
|
19 |
<title>Retrieve products</title>
|
20 |
</products>
|
21 |
+
<product_count translate="title" module="datafeedwatch_connector">
|
22 |
<title>Retrieve product count</title>
|
23 |
</product_count>
|
24 |
+
<updated_products translate="title" module="datafeedwatch_connector">
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
25 |
<title>Retrieve products based on last update</title>
|
26 |
</updated_products>
|
27 |
+
<updated_product_count translate="title" module="datafeedwatch_connector">
|
28 |
<title>Retrieve product count based on last update</title>
|
29 |
</updated_product_count>
|
30 |
+
<product_ids translate="title" module="datafeedwatch_connector">
|
31 |
+
<title>Retrieve Product Ids</title>
|
32 |
+
</product_ids>
|
33 |
</methods>
|
34 |
</datafeedwatch>
|
35 |
</resources>
|
app/code/community/DataFeedWatch/Connector/etc/config.xml
CHANGED
@@ -1,82 +1,39 @@
|
|
1 |
-
<?xml version="1.0"?>
|
2 |
<config>
|
3 |
<modules>
|
4 |
<DataFeedWatch_Connector>
|
5 |
-
<version>0.
|
6 |
</DataFeedWatch_Connector>
|
7 |
</modules>
|
8 |
-
|
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>
|
30 |
-
<acl>
|
31 |
-
<resources>
|
32 |
-
<admin>
|
33 |
-
<catalog>
|
34 |
-
<children>
|
35 |
-
<connector translate="title" module="connector">
|
36 |
-
<title>DataFeedWatch</title>
|
37 |
-
</connector>
|
38 |
-
</children>
|
39 |
-
</catalog>
|
40 |
-
</admin>
|
41 |
-
</resources>
|
42 |
-
</acl>
|
43 |
-
<layout>
|
44 |
-
<updates>
|
45 |
-
<connector>
|
46 |
-
<file>connector.xml</file>
|
47 |
-
</connector>
|
48 |
-
</updates>
|
49 |
-
</layout>
|
50 |
-
</adminhtml>
|
51 |
<global>
|
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 |
-
<
|
72 |
<class>DataFeedWatch_Connector_Helper</class>
|
73 |
-
</
|
74 |
</helpers>
|
75 |
<blocks>
|
76 |
-
<
|
77 |
<class>DataFeedWatch_Connector_Block</class>
|
78 |
-
</
|
79 |
</blocks>
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
80 |
<resources>
|
81 |
<datafeedwatch_connector_setup>
|
82 |
<setup>
|
@@ -85,33 +42,152 @@
|
|
85 |
</datafeedwatch_connector_setup>
|
86 |
</resources>
|
87 |
<events>
|
88 |
-
<
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
89 |
<observers>
|
90 |
-
<
|
91 |
-
<
|
92 |
-
<
|
93 |
-
|
94 |
-
</datafeedwatch_connector_save_catalogrule_date>
|
95 |
</observers>
|
96 |
-
</
|
97 |
-
<
|
98 |
<observers>
|
99 |
-
<
|
100 |
-
<
|
101 |
-
<
|
102 |
-
|
103 |
-
</datafeedwatch_connector_save_salesrule_date>
|
104 |
</observers>
|
105 |
-
</
|
106 |
-
<
|
107 |
<observers>
|
108 |
-
<
|
109 |
-
<
|
110 |
-
<
|
111 |
-
|
112 |
-
</datafeedwatch_connector_applyAll_catalogrule_date>
|
113 |
</observers>
|
114 |
-
</
|
115 |
</events>
|
116 |
</global>
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
117 |
</config>
|
1 |
+
<?xml version="1.0" encoding="utf-8"?>
|
2 |
<config>
|
3 |
<modules>
|
4 |
<DataFeedWatch_Connector>
|
5 |
+
<version>0.3.0</version>
|
6 |
</DataFeedWatch_Connector>
|
7 |
</modules>
|
8 |
+
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
9 |
<global>
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
10 |
<helpers>
|
11 |
+
<datafeedwatch_connector>
|
12 |
<class>DataFeedWatch_Connector_Helper</class>
|
13 |
+
</datafeedwatch_connector>
|
14 |
</helpers>
|
15 |
<blocks>
|
16 |
+
<datafeedwatch_connector>
|
17 |
<class>DataFeedWatch_Connector_Block</class>
|
18 |
+
</datafeedwatch_connector>
|
19 |
</blocks>
|
20 |
+
<models>
|
21 |
+
<datafeedwatch_connector>
|
22 |
+
<class>DataFeedWatch_Connector_Model</class>
|
23 |
+
<resourceModel>datafeedwatch_connector_resource</resourceModel>
|
24 |
+
</datafeedwatch_connector>
|
25 |
+
<datafeedwatch_connector_resource>
|
26 |
+
<class>DataFeedWatch_Connector_Model_Resource</class>
|
27 |
+
<entities>
|
28 |
+
<catalog_attribute_info>
|
29 |
+
<table>datafeedwatch_catalog_attribute_info</table>
|
30 |
+
</catalog_attribute_info>
|
31 |
+
<updated_products>
|
32 |
+
<table>datafeedwatch_updated_products</table>
|
33 |
+
</updated_products>
|
34 |
+
</entities>
|
35 |
+
</datafeedwatch_connector_resource>
|
36 |
+
</models>
|
37 |
<resources>
|
38 |
<datafeedwatch_connector_setup>
|
39 |
<setup>
|
42 |
</datafeedwatch_connector_setup>
|
43 |
</resources>
|
44 |
<events>
|
45 |
+
<catalog_entity_attribute_save_before>
|
46 |
+
<observers>
|
47 |
+
<datafeedwatch_connector_attribute_save_before>
|
48 |
+
<class>datafeedwatch_connector/observer</class>
|
49 |
+
<method>saveInheritanceInAttribute</method>
|
50 |
+
</datafeedwatch_connector_attribute_save_before>
|
51 |
+
</observers>
|
52 |
+
</catalog_entity_attribute_save_before>
|
53 |
+
<catalog_entity_attribute_delete_before>
|
54 |
+
<observers>
|
55 |
+
<datafeedwatch_connector_attribute_delete_before>
|
56 |
+
<class>datafeedwatch_connector/observer</class>
|
57 |
+
<method>deleteAttribute</method>
|
58 |
+
</datafeedwatch_connector_attribute_delete_before>
|
59 |
+
</observers>
|
60 |
+
</catalog_entity_attribute_delete_before>
|
61 |
+
<catalog_category_save_after>
|
62 |
+
<observers>
|
63 |
+
<datafeedwatch_connector_catalog_category_save_after>
|
64 |
+
<class>datafeedwatch_connector/observer</class>
|
65 |
+
<method>updateLastInheritanceUpdateDateOnCategoryChangeName</method>
|
66 |
+
</datafeedwatch_connector_catalog_category_save_after>
|
67 |
+
</observers>
|
68 |
+
</catalog_category_save_after>
|
69 |
+
<catalog_category_delete_before>
|
70 |
+
<observers>
|
71 |
+
<datafeedwatch_connector_catalog_category_delete_before>
|
72 |
+
<class>datafeedwatch_connector/observer</class>
|
73 |
+
<method>updateLastInheritanceUpdateDate</method>
|
74 |
+
</datafeedwatch_connector_catalog_category_delete_before>
|
75 |
+
</observers>
|
76 |
+
</catalog_category_delete_before>
|
77 |
+
<catalog_category_change_products>
|
78 |
+
<observers>
|
79 |
+
<datafeedwatch_connector_catalog_category_change_products>
|
80 |
+
<class>datafeedwatch_connector/observer</class>
|
81 |
+
<method>updateLastInheritanceUpdateDate</method>
|
82 |
+
</datafeedwatch_connector_catalog_category_change_products>
|
83 |
+
</observers>
|
84 |
+
</catalog_category_change_products>
|
85 |
+
<catalog_category_tree_move_after>
|
86 |
+
<observers>
|
87 |
+
<datafeedwatch_connector_catalog_category_tree_move_after>
|
88 |
+
<class>datafeedwatch_connector/observer</class>
|
89 |
+
<method>updateLastInheritanceUpdateDate</method>
|
90 |
+
</datafeedwatch_connector_catalog_category_tree_move_after>
|
91 |
+
</observers>
|
92 |
+
</catalog_category_tree_move_after>
|
93 |
+
<catalog_entity_attribute_load_after>
|
94 |
<observers>
|
95 |
+
<datafeedwatch_connector_attribute_load_after>
|
96 |
+
<class>datafeedwatch_connector/observer</class>
|
97 |
+
<method>getInheritanceForAttribute</method>
|
98 |
+
</datafeedwatch_connector_attribute_load_after>
|
|
|
99 |
</observers>
|
100 |
+
</catalog_entity_attribute_load_after>
|
101 |
+
<core_collection_abstract_load_before>
|
102 |
<observers>
|
103 |
+
<datafeedwatch_connector_attribute_collection_load_before>
|
104 |
+
<class>datafeedwatch_connector/observer</class>
|
105 |
+
<method>getInheritanceForAttributeCollection</method>
|
106 |
+
</datafeedwatch_connector_attribute_collection_load_before>
|
|
|
107 |
</observers>
|
108 |
+
</core_collection_abstract_load_before>
|
109 |
+
<catalog_product_delete_before>
|
110 |
<observers>
|
111 |
+
<datafeedwatch_connector_product_delete_before>
|
112 |
+
<class>datafeedwatch_connector/observer</class>
|
113 |
+
<method>removeProductFromUpdatedTable</method>
|
114 |
+
</datafeedwatch_connector_product_delete_before>
|
|
|
115 |
</observers>
|
116 |
+
</catalog_product_delete_before>
|
117 |
</events>
|
118 |
</global>
|
119 |
+
|
120 |
+
<adminhtml>
|
121 |
+
<events>
|
122 |
+
<adminhtml_catalog_product_attribute_edit_prepare_form>
|
123 |
+
<observers>
|
124 |
+
<connector_add_inheritance_field_to_attribute_form>
|
125 |
+
<class>datafeedwatch_connector/observer</class>
|
126 |
+
<method>addInheritanceFieldToAttributeForm</method>
|
127 |
+
</connector_add_inheritance_field_to_attribute_form>
|
128 |
+
</observers>
|
129 |
+
</adminhtml_catalog_product_attribute_edit_prepare_form>
|
130 |
+
<model_config_data_save_before>
|
131 |
+
<observers>
|
132 |
+
<dfw_connector_update_inheritance_date_after_config_save>
|
133 |
+
<class>datafeedwatch_connector/observer</class>
|
134 |
+
<method>updateInheritanceUpdateDate</method>
|
135 |
+
</dfw_connector_update_inheritance_date_after_config_save>
|
136 |
+
</observers>
|
137 |
+
</model_config_data_save_before>
|
138 |
+
</events>
|
139 |
+
<translate>
|
140 |
+
<modules>
|
141 |
+
<DataFeedWatch_Connector>
|
142 |
+
<files>
|
143 |
+
<default>DataFeedWatch_Connector.csv</default>
|
144 |
+
</files>
|
145 |
+
</DataFeedWatch_Connector>
|
146 |
+
</modules>
|
147 |
+
</translate>
|
148 |
+
<layout>
|
149 |
+
<updates>
|
150 |
+
<datafeedwatch_connector>
|
151 |
+
<file>datafeedwatch/connector.xml</file>
|
152 |
+
</datafeedwatch_connector>
|
153 |
+
</updates>
|
154 |
+
</layout>
|
155 |
+
</adminhtml>
|
156 |
+
|
157 |
+
<admin>
|
158 |
+
<routers>
|
159 |
+
<adminhtml>
|
160 |
+
<args>
|
161 |
+
<modules>
|
162 |
+
<datafeedwatch_connector before="Mage_Adminhtml">DataFeedWatch_Connector_Adminhtml</datafeedwatch_connector>
|
163 |
+
</modules>
|
164 |
+
</args>
|
165 |
+
</adminhtml>
|
166 |
+
</routers>
|
167 |
+
</admin>
|
168 |
+
|
169 |
+
<crontab>
|
170 |
+
<jobs>
|
171 |
+
<datafeedwatch_connector_fill_updated_at_table>
|
172 |
+
<schedule>
|
173 |
+
<cron_expr>0 * * * *</cron_expr>
|
174 |
+
</schedule>
|
175 |
+
<run>
|
176 |
+
<model>datafeedwatch_connector/cron::reindex</model>
|
177 |
+
</run>
|
178 |
+
</datafeedwatch_connector_fill_updated_at_table>
|
179 |
+
</jobs>
|
180 |
+
</crontab>
|
181 |
+
|
182 |
+
<default>
|
183 |
+
<datafeedwatch_connector>
|
184 |
+
<general>
|
185 |
+
<debug>0</debug>
|
186 |
+
</general>
|
187 |
+
<custom_inheritance>
|
188 |
+
<product_url>1</product_url>
|
189 |
+
<image_url>0</image_url>
|
190 |
+
</custom_inheritance>
|
191 |
+
</datafeedwatch_connector>
|
192 |
+
</default>
|
193 |
</config>
|
app/code/community/DataFeedWatch/Connector/etc/system.xml
CHANGED
@@ -1,9 +1,106 @@
|
|
1 |
-
<?xml version="1.0"?>
|
2 |
<config>
|
3 |
-
|
4 |
-
|
5 |
-
|
6 |
-
|
7 |
-
|
8 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
9 |
</config>
|
1 |
+
<?xml version="1.0" encoding="utf-8"?>
|
2 |
<config>
|
3 |
+
<tabs>
|
4 |
+
<datafeedwatch translate="label" module="datafeedwatch_connector">
|
5 |
+
<label>DataFeedWatch</label>
|
6 |
+
<sort_order>100</sort_order>
|
7 |
+
</datafeedwatch>
|
8 |
+
</tabs>
|
9 |
+
|
10 |
+
<sections>
|
11 |
+
<datafeedwatch_connector translate="label" module="datafeedwatch_connector">
|
12 |
+
<label>Settings</label>
|
13 |
+
<tab>datafeedwatch</tab>
|
14 |
+
<sort_order>100</sort_order>
|
15 |
+
<show_in_default>1</show_in_default>
|
16 |
+
<groups>
|
17 |
+
<general translate="label" module="datafeedwatch_connector">
|
18 |
+
<label>General Configuration</label>
|
19 |
+
<frontend_type>text</frontend_type>
|
20 |
+
<sort_order>1</sort_order>
|
21 |
+
<show_in_default>1</show_in_default>
|
22 |
+
<expanded>1</expanded>
|
23 |
+
<fields>
|
24 |
+
<connector_open translate="label" module="datafeedwatch_connector">
|
25 |
+
<label>Go To My DataFeedWatch</label>
|
26 |
+
<frontend_type>button</frontend_type>
|
27 |
+
<frontend_model>datafeedwatch_connector/adminhtml_system_config_form_button_open</frontend_model>
|
28 |
+
<sort_order>10</sort_order>
|
29 |
+
<show_in_default>1</show_in_default>
|
30 |
+
</connector_open>
|
31 |
+
<debug translate="label comment" module="datafeedwatch_connector">
|
32 |
+
<label>Debug Mode</label>
|
33 |
+
<comment><![CDATA[Debug data will be written to var/log/DataFeedWatch_Connector/. Please save after change]]></comment>
|
34 |
+
<frontend_type>select</frontend_type>
|
35 |
+
<source_model>adminhtml/system_config_source_enabledisable</source_model>
|
36 |
+
<sort_order>20</sort_order>
|
37 |
+
<show_in_default>1</show_in_default>
|
38 |
+
</debug>
|
39 |
+
<connector_refresh translate="label comment" module="datafeedwatch_connector">
|
40 |
+
<label>Refresh DataFeedWatch Access</label>
|
41 |
+
<comment>Refresh DataFeedWatch access: SOAP user and role</comment>
|
42 |
+
<frontend_type>button</frontend_type>
|
43 |
+
<frontend_model>datafeedwatch_connector/adminhtml_system_config_form_button_refresh</frontend_model>
|
44 |
+
<sort_order>30</sort_order>
|
45 |
+
<show_in_default>1</show_in_default>
|
46 |
+
</connector_refresh>
|
47 |
+
<connector_add_store translate="label" module="datafeedwatch_connector">
|
48 |
+
<label>Add Store To DataFeedWatch</label>
|
49 |
+
<frontend_type>button</frontend_type>
|
50 |
+
<frontend_model>datafeedwatch_connector/adminhtml_system_config_form_button_add</frontend_model>
|
51 |
+
<sort_order>40</sort_order>
|
52 |
+
<show_in_default>1</show_in_default>
|
53 |
+
</connector_add_store>
|
54 |
+
<connector_get_all translate="label" module="datafeedwatch_connector">
|
55 |
+
<label>Get all product data with next download</label>
|
56 |
+
<frontend_type>button</frontend_type>
|
57 |
+
<frontend_model>datafeedwatch_connector/adminhtml_system_config_form_button_extort</frontend_model>
|
58 |
+
<sort_order>50</sort_order>
|
59 |
+
<show_in_default>1</show_in_default>
|
60 |
+
</connector_get_all>
|
61 |
+
</fields>
|
62 |
+
</general>
|
63 |
+
<custom_inheritance translate="label" module="datafeedwatch_connector">
|
64 |
+
<label>Inheritance</label>
|
65 |
+
<frontend_type>text</frontend_type>
|
66 |
+
<sort_order>10</sort_order>
|
67 |
+
<show_in_default>1</show_in_default>
|
68 |
+
<expanded>1</expanded>
|
69 |
+
<fields>
|
70 |
+
<product_url translate="label comment" module="datafeedwatch_connector">
|
71 |
+
<label>Inherit Product Url In Child Products</label>
|
72 |
+
<comment>Please save after change</comment>
|
73 |
+
<frontend_type>select</frontend_type>
|
74 |
+
<source_model>adminhtml/system_config_source_yesno</source_model>
|
75 |
+
<sort_order>1</sort_order>
|
76 |
+
<show_in_default>1</show_in_default>
|
77 |
+
</product_url>
|
78 |
+
<image_url translate="label comment" module="datafeedwatch_connector">
|
79 |
+
<label>Inherit Image Url In Child Products</label>
|
80 |
+
<comment>Please save after change</comment>
|
81 |
+
<frontend_type>select</frontend_type>
|
82 |
+
<source_model>adminhtml/system_config_source_yesno</source_model>
|
83 |
+
<sort_order>10</sort_order>
|
84 |
+
<show_in_default>1</show_in_default>
|
85 |
+
</image_url>
|
86 |
+
<restore_original_config translate="label comment" module="datafeedwatch_connector">
|
87 |
+
<label>Restore Original Config</label>
|
88 |
+
<comment>Reset Inheritance Logic Configuration</comment>
|
89 |
+
<frontend_type>button</frontend_type>
|
90 |
+
<frontend_model>datafeedwatch_connector/adminhtml_system_config_form_button_restore</frontend_model>
|
91 |
+
<sort_order>20</sort_order>
|
92 |
+
<show_in_default>1</show_in_default>
|
93 |
+
</restore_original_config>
|
94 |
+
<inheritance_grid translate="label" module="datafeedwatch_connector">
|
95 |
+
<label>Attributes</label>
|
96 |
+
<frontend_type>label</frontend_type>
|
97 |
+
<frontend_model>datafeedwatch_connector/adminhtml_system_config_form_grid_inheritance</frontend_model>
|
98 |
+
<sort_order>30</sort_order>
|
99 |
+
<show_in_default>1</show_in_default>
|
100 |
+
</inheritance_grid>
|
101 |
+
</fields>
|
102 |
+
</custom_inheritance>
|
103 |
+
</groups>
|
104 |
+
</datafeedwatch_connector>
|
105 |
+
</sections>
|
106 |
</config>
|
app/code/community/DataFeedWatch/Connector/sql/datafeedwatch_connector_setup/install-0.2.9.php
DELETED
@@ -1,13 +0,0 @@
|
|
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()->addColumn($installer->getTable('api/user'), 'dfw_connect_hash', array(
|
8 |
-
'type' => Varien_Db_Ddl_Table::TYPE_TEXT,
|
9 |
-
'length' => 32,
|
10 |
-
'comment' => 'Hash used to update keys'
|
11 |
-
));
|
12 |
-
|
13 |
-
$installer->endSetup();
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
app/code/community/DataFeedWatch/Connector/sql/datafeedwatch_connector_setup/upgrade-0.2.10-0.2.11.ph
DELETED
@@ -1,9 +0,0 @@
|
|
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.10-0.2.11.php
DELETED
@@ -1,9 +0,0 @@
|
|
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
DELETED
@@ -1,72 +0,0 @@
|
|
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
DELETED
@@ -1,72 +0,0 @@
|
|
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.40-0.2.50.php
ADDED
@@ -0,0 +1,84 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
/* @var Mage_Core_Model_Resource_Setup $installer */
|
3 |
+
$installer = $this;
|
4 |
+
/** @var Magento_Db_Adapter_Pdo_Mysql $connection */
|
5 |
+
$connection = $installer->getConnection();
|
6 |
+
/** @var string $table */
|
7 |
+
$table = $installer->getTable('datafeedwatch_connector/updated_products');
|
8 |
+
|
9 |
+
if (!$installer->tableExists(($table))) {
|
10 |
+
$installer->startSetup();
|
11 |
+
$updatedProductsTable = $connection->newTable($table)
|
12 |
+
->addColumn('product_id', Varien_Db_Ddl_Table::TYPE_INTEGER, null, array(
|
13 |
+
'identity' => true,
|
14 |
+
'unsigned' => true,
|
15 |
+
'nullable' => false,
|
16 |
+
'primary' => true,
|
17 |
+
), 'Product ID')
|
18 |
+
->addColumn('updated_at', Varien_Db_Ddl_Table::TYPE_TIMESTAMP, null, array(
|
19 |
+
'nullable' => true,
|
20 |
+
), 'Updated At')
|
21 |
+
->setComment('Updated Products Table');
|
22 |
+
$connection->createTable($updatedProductsTable);
|
23 |
+
|
24 |
+
$installer->endSetup();
|
25 |
+
}
|
26 |
+
|
27 |
+
|
28 |
+
/** @var string $table */
|
29 |
+
$table = $installer->getTable('datafeedwatch_connector/catalog_attribute_info');
|
30 |
+
|
31 |
+
if ($connection->tableColumnExists($installer->getTable('api/user'), 'dfw_connect_hash')) {
|
32 |
+
$installer->startSetup();
|
33 |
+
$connection->dropColumn($installer->getTable('api/user'), 'dfw_connect_hash');
|
34 |
+
$installer->endSetup();
|
35 |
+
}
|
36 |
+
$installer->startSetup();
|
37 |
+
$connection->dropTable($installer->getTable('datafeedwatch_catalogrule_info'));
|
38 |
+
$installer->endSetup();
|
39 |
+
$installer->startSetup();
|
40 |
+
$connection->dropTable($installer->getTable('datafeedwatch_salesrule_info'));
|
41 |
+
$installer->endSetup();
|
42 |
+
|
43 |
+
if (!$installer->tableExists(($table))) {
|
44 |
+
$installer->startSetup();
|
45 |
+
$salesRuleInfoTable = $connection->newTable($table)
|
46 |
+
->addColumn('catalog_attribute_info_id', Varien_Db_Ddl_Table::TYPE_INTEGER, null, array(
|
47 |
+
'identity' => true,
|
48 |
+
'unsigned' => true,
|
49 |
+
'nullable' => false,
|
50 |
+
'primary' => true,
|
51 |
+
), 'Catalog Attribute Info ID')
|
52 |
+
->addColumn('catalog_attribute_id', Varien_Db_Ddl_Table::TYPE_INTEGER, null, array(
|
53 |
+
'unsigned' => true,
|
54 |
+
'nullable' => false,
|
55 |
+
), 'Catalog Attribute ID')
|
56 |
+
->addColumn('can_configure_inheritance', Varien_Db_Ddl_Table::TYPE_SMALLINT, null, array(
|
57 |
+
'unsigned' => true,
|
58 |
+
'nullable' => false,
|
59 |
+
'type' => Varien_Db_Ddl_Table::TYPE_SMALLINT,
|
60 |
+
'default' => 1,
|
61 |
+
), 'Can configure inheritance field? 1 - YES, 0 - NO')
|
62 |
+
->addColumn('inheritance', Varien_Db_Ddl_Table::TYPE_SMALLINT, null, array(
|
63 |
+
'unsigned' => true,
|
64 |
+
'nullable' => false,
|
65 |
+
'default' => 1,
|
66 |
+
), 'Inheritance: 1 - Child, 2 - Parent, 3 - Child Then Parent')
|
67 |
+
->addColumn('can_configure_import', Varien_Db_Ddl_Table::TYPE_SMALLINT, null, array(
|
68 |
+
'unsigned' => true,
|
69 |
+
'nullable' => false,
|
70 |
+
'default' => 1,
|
71 |
+
), 'Can configure import field? 1 - YES, 0 - NO')
|
72 |
+
->addColumn('import_to_dfw', Varien_Db_Ddl_Table::TYPE_SMALLINT, null, array(
|
73 |
+
'unsigned' => true,
|
74 |
+
'nullable' => false,
|
75 |
+
'default' => 1,
|
76 |
+
), 'Should import attribute? 1 - YES, 0 - NO')
|
77 |
+
->addColumn('updated_at', Varien_Db_Ddl_Table::TYPE_TIMESTAMP, null, array(
|
78 |
+
'nullable' => true,
|
79 |
+
), 'Updated At')
|
80 |
+
->setComment('Catalog Attribute Additional Info');
|
81 |
+
$connection->createTable($salesRuleInfoTable);
|
82 |
+
|
83 |
+
$installer->endSetup();
|
84 |
+
}
|
app/code/community/DataFeedWatch/Connector/sql/datafeedwatch_connector_setup/upgrade-0.2.9-0.2.10.ph
DELETED
@@ -1,6 +0,0 @@
|
|
1 |
-
<?php
|
2 |
-
/* @var $installer Mage_Core_Model_Resource_Setup */
|
3 |
-
$installer = $this;
|
4 |
-
$installer->startSetup();
|
5 |
-
|
6 |
-
$installer->endSetup();
|
|
|
|
|
|
|
|
|
|
|
|
app/code/community/DataFeedWatch/Connector/sql/datafeedwatch_connector_setup/upgrade-0.2.9-0.2.10.php
DELETED
@@ -1,6 +0,0 @@
|
|
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
DELETED
@@ -1,18 +0,0 @@
|
|
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>
|
7 |
-
<name>js/connector/connector.js</name>
|
8 |
-
</action>
|
9 |
-
<action method="addItem">
|
10 |
-
<type>skin_css</type>
|
11 |
-
<name>connector.css</name>
|
12 |
-
</action>
|
13 |
-
</reference>
|
14 |
-
<reference name="content">
|
15 |
-
<block type="connector/adminhtml_settings_edit" name="settings"/>
|
16 |
-
</reference>
|
17 |
-
</adminhtml_connectorsettings_index>
|
18 |
-
</layout>
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
app/design/adminhtml/default/default/layout/datafeedwatch/connector.xml
ADDED
@@ -0,0 +1,22 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?xml version="1.0" encoding="utf-8" ?>
|
2 |
+
<layout>
|
3 |
+
<adminhtml_system_config_edit>
|
4 |
+
<reference name="head">
|
5 |
+
<action method="addItem"><type>skin_js</type><name>datafeedwatch/connector/js/grid/inheritance.js</name></action>
|
6 |
+
<action method="addItem"><type>skin_css</type><name>datafeedwatch/connector/css/grid/inheritance.css</name></action>
|
7 |
+
</reference>
|
8 |
+
<block type="datafeedwatch_connector/adminhtml_system_config_grid" name="datafeedwatch_connector_inheritance_grid"
|
9 |
+
as="datafeedwatch_connector_inheritance_grid" template="datafeedwatch/connector/grid.phtml">
|
10 |
+
</block>
|
11 |
+
</adminhtml_system_config_edit>
|
12 |
+
<adminhtml_datafeedwatch_renderinheritancegrid>
|
13 |
+
<block type="datafeedwatch_connector/adminhtml_system_config_grid_items" name="datafeedwatch_connector_inheritance_grid_items"
|
14 |
+
as="datafeedwatch_connector_inheritance_grid_items" template="datafeedwatch/connector/grid/items.phtml">
|
15 |
+
<block type="datafeedwatch_connector/adminhtml_system_config_grid_items_row" name="datafeedwatch_connector_inheritance_grid_items_row"
|
16 |
+
as="datafeedwatch_connector_inheritance_grid_items_row" template="datafeedwatch/connector/grid/items/row.phtml" />
|
17 |
+
|
18 |
+
<block type="datafeedwatch_connector/adminhtml_system_config_grid_pager" name="datafeedwatch_connector_inheritance_grid_pager"
|
19 |
+
as="datafeedwatch_connector_inheritance_grid_pager" template="datafeedwatch/connector/grid/pager.phtml" />
|
20 |
+
</block>
|
21 |
+
</adminhtml_datafeedwatch_renderinheritancegrid>
|
22 |
+
</layout>
|
app/design/adminhtml/default/default/template/datafeedwatch/connector/grid.phtml
ADDED
@@ -0,0 +1,17 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php /** @var DataFeedWatch_Connector_Block_Adminhtml_System_Config_Grid $this */ ?>
|
2 |
+
<input type="hidden" id="inheritance_grid_action_url" value="<?php echo $this->getActionUrl() ?>" />
|
3 |
+
<input type="hidden" id="save_inheritance_action_url" value="<?php echo $this->getSaveInheritanceActionUrl() ?>" />
|
4 |
+
<input type="hidden" id="save_import_action_url" value="<?php echo $this->getSaveImportActionUrl() ?>" />
|
5 |
+
<div id="inheritance_grid">
|
6 |
+
<div class="attribute_inheritance_grid_header">
|
7 |
+
<div class="attribute_name"><?php echo $this->helper('adminhtml')->__('Name')?></div>
|
8 |
+
<div class="attribute_import"><?php echo $this->__('Import')?></div>
|
9 |
+
<div class="attribute_inheritance">
|
10 |
+
<div class="inheritance_child"><?php echo $this->__('Child')?></div>
|
11 |
+
<div class="inheritance_parent"><?php echo $this->__('Parent')?></div>
|
12 |
+
<div class="inheritance_child_then_parent"><?php echo $this->__('Child Then Parent')?></div>
|
13 |
+
</div>
|
14 |
+
</div>
|
15 |
+
<div id="attribute_inheritance_grid_items"></div>
|
16 |
+
<p class="note"><?php echo $this->__('Every change is save automatically') ?></p>
|
17 |
+
</div>
|
app/design/adminhtml/default/default/template/datafeedwatch/connector/grid/items.phtml
ADDED
@@ -0,0 +1,6 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php /** @var DataFeedWatch_Connector_Block_Adminhtml_System_Config_Grid_Items $this */ ?>
|
2 |
+
<?php $attributeCollection = $this->getCollection(); ?>
|
3 |
+
<?php foreach ($attributeCollection as $attribute): ?>
|
4 |
+
<?php echo $this->getItemRow($attribute) ?>
|
5 |
+
<?php endforeach; ?>
|
6 |
+
<?php echo $this->getPagerHtml() ?>
|
app/design/adminhtml/default/default/template/datafeedwatch/connector/grid/items/row.phtml
ADDED
@@ -0,0 +1,57 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
/** @var DataFeedWatch_Connector_Model_System_Config_Source_Inheritance $inheritanceModel */
|
3 |
+
/** @var Mage_Catalog_Model_Resource_Eav_Attribute $attribute */
|
4 |
+
/** @var DataFeedWatch_Connector_Block_Adminhtml_System_Config_Grid_Items_Row $this */
|
5 |
+
/** @var Mage_Catalog_Model_Resource_Eav_Attribute $attribute */
|
6 |
+
|
7 |
+
$attribute = $this->getAttributeItem();
|
8 |
+
$inheritanceModel = Mage::getModel('datafeedwatch_connector/system_config_source_inheritance');
|
9 |
+
$inheritance = (int)$attribute->getDfwInheritance();
|
10 |
+
$import = (int)$attribute->getImportToDfw();
|
11 |
+
$inheritanceStatus = $attribute->getCanConfigureInheritance() === '0' ? ' disabled ' : '';
|
12 |
+
?>
|
13 |
+
<div class="attribute_item">
|
14 |
+
<div class="attribute_name">
|
15 |
+
<a href="<?php echo $this->getAttributeLink() ?>" target="_blank">
|
16 |
+
<?php echo $this->getAttributeLabel() ?>
|
17 |
+
</a>
|
18 |
+
</div>
|
19 |
+
<div class="attribute_import">
|
20 |
+
<select name="import_<?php echo $attribute->getId() ?>"
|
21 |
+
<?php echo $attribute->getCanConfigureImport() === '0' ? ' disabled ' : '' ?>
|
22 |
+
onchange="saveImport(<?php echo $attribute->getId() ?>, this.value)" >
|
23 |
+
<option value="1" <?php echo $import === 1 ? 'selected' : '' ?>>
|
24 |
+
<?php echo $this->helper('adminhtml')->__('Yes') ?>
|
25 |
+
</option>
|
26 |
+
<option value="0" <?php echo $import === 0 ? 'selected' : '' ?>>
|
27 |
+
<?php echo $this->helper('adminhtml')->__('No') ?>
|
28 |
+
</option>
|
29 |
+
</select>
|
30 |
+
</div>
|
31 |
+
<div class="attribute_inheritance">
|
32 |
+
<div class="inheritance_child">
|
33 |
+
<input type="radio" name="inheritance_<?php echo $attribute->getId() ?>"
|
34 |
+
<?php echo $inheritanceStatus ?>
|
35 |
+
<?php echo $inheritanceModel::CHILD_OPTION_ID === $inheritance ? ' checked ' : '' ?>
|
36 |
+
value="<?php echo $inheritanceModel::CHILD_OPTION_ID ?>"
|
37 |
+
onchange="saveInheritance(<?php echo $attribute->getId() ?>, this.value)
|
38 |
+
"/>
|
39 |
+
</div>
|
40 |
+
<div class="inheritance_parent">
|
41 |
+
<input type="radio" name="inheritance_<?php echo $attribute->getId() ?>"
|
42 |
+
<?php echo $inheritanceStatus ?>
|
43 |
+
<?php echo $inheritanceModel::PARENT_OPTION_ID === $inheritance ? ' checked ' : '' ?>
|
44 |
+
value="<?php echo $inheritanceModel::PARENT_OPTION_ID ?>"
|
45 |
+
onchange="saveInheritance(<?php echo $attribute->getId() ?>, this.value)
|
46 |
+
"/>
|
47 |
+
</div>
|
48 |
+
<div class="inheritance_child_then_parent">
|
49 |
+
<input type="radio" name="inheritance_<?php echo $attribute->getId() ?>"
|
50 |
+
<?php echo $inheritanceStatus ?>
|
51 |
+
<?php echo $inheritanceModel::CHILD_THEN_PARENT_OPTION_ID === $inheritance ? ' checked ' : '' ?>
|
52 |
+
value="<?php echo $inheritanceModel::CHILD_THEN_PARENT_OPTION_ID ?>"
|
53 |
+
onchange="saveInheritance(<?php echo $attribute->getId() ?>, this.value)
|
54 |
+
"/>
|
55 |
+
</div>
|
56 |
+
</div>
|
57 |
+
</div>
|
app/design/adminhtml/default/default/template/datafeedwatch/connector/grid/pager.phtml
ADDED
@@ -0,0 +1,54 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php /** @var DataFeedWatch_Connector_Block_Adminhtml_System_Config_Grid_Pager $this */ ?>
|
2 |
+
<span class="inheritance_pager">
|
3 |
+
<span class="page">
|
4 |
+
<?php echo $this->helper('adminhtml')->__('Page') ?>
|
5 |
+
|
6 |
+
<?php $currentPage = $this->getPage() ?>
|
7 |
+
<?php $currentLimit = $this->getLimit() ?>
|
8 |
+
<?php $lastPage = $this->getCollection()->getLastPageNumber() ?>
|
9 |
+
<?php if($currentPage > 1): ?>
|
10 |
+
<a href="#" title="<?php echo Mage::helper('core')->quoteEscape($this->helper('adminhtml')->__('Previous page')) ?>"
|
11 |
+
onclick="getInheritanceGrid(<?php echo sprintf('%d, %d', $currentPage - 1, $currentLimit) ?>);return false;" >
|
12 |
+
<img src="<?php echo $this->getSkinUrl('images/pager_arrow_left.gif') ?>"
|
13 |
+
alt="<?php echo Mage::helper('core')->quoteEscape($this->helper('adminhtml')->__('Go to Previous page')) ?>" class="arrow navigation"/>
|
14 |
+
</a>
|
15 |
+
<?php else: ?>
|
16 |
+
<img src="<?php echo $this->getSkinUrl('images/pager_arrow_left_off.gif') ?>"
|
17 |
+
alt="<?php echo Mage::helper('core')->quoteEscape($this->helper('adminhtml')->__('Go to Previous page')) ?>" class="arrow navigation"/>
|
18 |
+
<?php endif; ?>
|
19 |
+
|
20 |
+
<input type="text" name="page" value="<?php echo $currentPage ?>" class="input-text page"
|
21 |
+
onkeyup="getInheritanceGrid(this.value, <?php echo $currentLimit ?>)" />
|
22 |
+
|
23 |
+
|
24 |
+
<?php if($currentPage < $lastPage): ?>
|
25 |
+
<a href="#" title="<?php echo Mage::helper('core')->quoteEscape($this->helper('adminhtml')->__('Next page')) ?>"
|
26 |
+
onclick="getInheritanceGrid(<?php echo sprintf('%d, %d', $currentPage + 1, $currentLimit) ?>);return false;" >
|
27 |
+
<img src="<?php echo $this->getSkinUrl('images/pager_arrow_right.gif') ?>"
|
28 |
+
alt="<?php echo Mage::helper('core')->quoteEscape($this->helper('adminhtml')->__('Go to Next page')) ?>" class="arrow navigation"/>
|
29 |
+
</a>
|
30 |
+
<?php else: ?>
|
31 |
+
<img src="<?php echo $this->getSkinUrl('images/pager_arrow_right_off.gif') ?>"
|
32 |
+
alt="<?php echo Mage::helper('core')->quoteEscape($this->helper('adminhtml')->__('Go to Next page')) ?>" class="arrow navigation"/>
|
33 |
+
<?php endif; ?>
|
34 |
+
|
35 |
+
<?php echo $this->helper('adminhtml')->__('of %s pages', $this->getCollection()->getLastPageNumber()) ?>
|
36 |
+
</span>
|
37 |
+
<span class="limit">
|
38 |
+
<?php echo $this->helper('adminhtml')->__('View') ?>
|
39 |
+
<select name="limit" onchange="getInheritanceGrid(<?php echo $currentPage ?>, this.value)">
|
40 |
+
<option value="5"<?php if($this->getCollection()->getPageSize()==5): ?> selected="selected"<?php endif; ?>>5</option>
|
41 |
+
<option value="10"<?php if($this->getCollection()->getPageSize()==10): ?> selected="selected"<?php endif; ?>>10</option>
|
42 |
+
<option value="20"<?php if($this->getCollection()->getPageSize()==20): ?> selected="selected"<?php endif; ?>>20</option>
|
43 |
+
<option value="50"<?php if($this->getCollection()->getPageSize()==50): ?> selected="selected"<?php endif; ?>>50</option>
|
44 |
+
<option value="100"<?php if($this->getCollection()->getPageSize()==100): ?> selected="selected"<?php endif; ?>>100</option>
|
45 |
+
<option value="200"<?php if($this->getCollection()->getPageSize()==200): ?> selected="selected"<?php endif; ?>>200</option>
|
46 |
+
<option value="500"<?php if($this->getCollection()->getPageSize()==500): ?> selected="selected"<?php endif; ?>>500</option>
|
47 |
+
</select>
|
48 |
+
<?php echo $this->helper('adminhtml')->__('per page') ?>
|
49 |
+
</span>
|
50 |
+
<span class="total_of">
|
51 |
+
<?php echo $this->helper('adminhtml')->__('Total %d records found', $this->getCollection()->getSize()) ?>
|
52 |
+
<span id="dfw_grid_inheritance_total_count" class="no-display"><?php echo $this->getCollection()->getSize() ?></span>
|
53 |
+
</span>
|
54 |
+
</span>
|
app/etc/modules/DataFeedWatch_Connector.xml
CHANGED
@@ -5,9 +5,8 @@
|
|
5 |
<active>true</active>
|
6 |
<codePool>community</codePool>
|
7 |
<depends>
|
8 |
-
<
|
9 |
-
|
10 |
-
<Mage_SalesRule/>
|
11 |
</depends>
|
12 |
</DataFeedWatch_Connector>
|
13 |
</modules>
|
5 |
<active>true</active>
|
6 |
<codePool>community</codePool>
|
7 |
<depends>
|
8 |
+
<Mage_CatalogRule />
|
9 |
+
<Mage_Catalog />
|
|
|
10 |
</depends>
|
11 |
</DataFeedWatch_Connector>
|
12 |
</modules>
|
app/locale/en_US/DataFeedWatch_Connector.csv
ADDED
@@ -0,0 +1,41 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
"Add Store","Add Store"
|
2 |
+
"Refresh","Refresh"
|
3 |
+
"Open","Open"
|
4 |
+
"%s user has been refreshed.","%s user has been refreshed."
|
5 |
+
"DataFeedWatch","DataFeedWatch"
|
6 |
+
"DataFeedWatch API","DataFeedWatch API"
|
7 |
+
"Retrieve extension version","Retrieve extension version"
|
8 |
+
"Retrieve datetime in GMT","Retrieve datetime in GMT"
|
9 |
+
"Retrieve stores","Retrieve stores"
|
10 |
+
"Retrieve products","Retrieve products"
|
11 |
+
"Retrieve product count","Retrieve product count"
|
12 |
+
"Retrieve products based on last update","Retrieve products based on last update"
|
13 |
+
"Retrieve product count based on last update","Retrieve product count based on last update"
|
14 |
+
"Retrieve Product Ids","Retrieve Product Ids"
|
15 |
+
"Settings","Settings"
|
16 |
+
"General Configuration","General Configuration"
|
17 |
+
"Go To My DataFeedWatch","Go To My DataFeedWatch"
|
18 |
+
"Debug Mode","Debug Mode"
|
19 |
+
"Refresh DataFeedWatch Access","Refresh DataFeedWatch Access"
|
20 |
+
"Refresh DataFeedWatch access: SOAP user and role","Refresh DataFeedWatch access: SOAP user and role"
|
21 |
+
"Add Store To DataFeedWatch","Add Store To DataFeedWatch"
|
22 |
+
"Inheritance","Inheritance"
|
23 |
+
"Inherit Product Url In Child Products","Inherit Product Url In Child Products"
|
24 |
+
"Inherit Image Url In Child Products","Inherit Image Url In Child Products"
|
25 |
+
"Child","Child"
|
26 |
+
"Parent","Parent"
|
27 |
+
"Child Then Parent","Child Then Parent"
|
28 |
+
"Not Defined","Not Defined"
|
29 |
+
"Import To DataFeedWatch","Import To DataFeedWatch"
|
30 |
+
"DataFeedWatch Inheritance","DataFeedWatch Inheritance"
|
31 |
+
"Debug data will be written to var/log/DataFeedWatch_Connector/. Please save after change","Debug data will be written to var/log/DataFeedWatch_Connector/. Please save after change"
|
32 |
+
"Attributes","Attributes"
|
33 |
+
"Import","Import"
|
34 |
+
"Every change is save automatically","Every change is save automatically"
|
35 |
+
"Please save after change","Please save after change"
|
36 |
+
"Restore","Restore"
|
37 |
+
"Restore Original Config","Restore Original Config"
|
38 |
+
"Reset Inheritance Logic Configuration","Reset Inheritance Logic Configuration"
|
39 |
+
"Original inheritance configuration has been restored.","Original inheritance configuration has been restored."
|
40 |
+
"Get all product data with next download","Get all product data with next download"
|
41 |
+
"Get All","Get All"
|
app/locale/pl_PL/DataFeedWatch_Connector.csv
ADDED
@@ -0,0 +1,41 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
"Add Store","Dodaj Sklep"
|
2 |
+
"Refresh","Odśwież"
|
3 |
+
"Open","Otwórz"
|
4 |
+
"%s user has been refreshed.","Użytkownik %s został odświeżony."
|
5 |
+
"DataFeedWatch","DataFeedWatch"
|
6 |
+
"DataFeedWatch API","DataFeedWatch API"
|
7 |
+
"Retrieve extension version","Zwraca wersję modułu"
|
8 |
+
"Retrieve datetime in GMT","Zwraca datetime in GMT"
|
9 |
+
"Retrieve stores","Zwraca sklepy"
|
10 |
+
"Retrieve products","Zwraca produkty"
|
11 |
+
"Retrieve product count","Zwraca ilość produktów"
|
12 |
+
"Retrieve products based on last update","Zwraca produkty bazując na ostatniej aktualizacji produktów"
|
13 |
+
"Retrieve product count based on last update","Zwraca ilość produktów bazując na ostatniej aktualizacji produktów"
|
14 |
+
"Retrieve Product Ids","Zwraca ID produktów"
|
15 |
+
"Settings","Ustawienia"
|
16 |
+
"General Configuration","Ogolna konfiguracja"
|
17 |
+
"Go To My DataFeedWatch","Przejdź do panelu DataFeedWatch"
|
18 |
+
"Debug Mode","Tryb Debugowania"
|
19 |
+
"Refresh DataFeedWatch Access","Odśwież Dostęp Do DataFeedWatch"
|
20 |
+
"Refresh DataFeedWatch access: SOAP user and role","Odśwież Dostęp Do DataFeedWatch: użytkownik i rola SOAP"
|
21 |
+
"Add Store To DataFeedWatch","Dodaj Sklep Do DataFeedWatch"
|
22 |
+
"Inheritance","Dziedziczenie"
|
23 |
+
"Inherit Product Url In Child Products","Dziedzicz URL Produktu W Produktach Potomnych"
|
24 |
+
"Inherit Image Url In Child Products","Dziedzicz URL Głównego Obrazka W Produktach Potomnych"
|
25 |
+
"Child","Produkt Potomny"
|
26 |
+
"Parent","Produkt Nadrzędny"
|
27 |
+
"Child Then Parent","Najpierw Produkt Potomny Później Produkt Nadrzędny"
|
28 |
+
"Not Defined","Niezdefiniowane"
|
29 |
+
"Import To DataFeedWatch","Importuj Do DataFeedWatch"
|
30 |
+
"DataFeedWatch Inheritance","Dziedziczenie DataFeedWatch"
|
31 |
+
"Debug data will be written to var/log/DataFeedWatch_Connector/. Please save after change","Dane do debugowania zostaną zapisane w var/log/DataFeedWatch_Connector/. Proszę zapisać zmianę"
|
32 |
+
"Attributes","Atrybuty"
|
33 |
+
"Import","Import"
|
34 |
+
"Every change is save automatically","Każda zmiana jest automatycznie zapisywana"
|
35 |
+
"Please save after change","Proszę zapisać zmianę"
|
36 |
+
"Restore","Przywróć"
|
37 |
+
"Restore Original Config","Przywróć Oryginalną Konfigurację"
|
38 |
+
"Reset Inheritance Logic Configuration","Zresetuj Konfigurację Logiki Dziedziczenia"
|
39 |
+
"Original inheritance configuration has been restored.","Oryginalna konfiguracja dziedziczenia została przywrócona."
|
40 |
+
"Get all product data with next download","Wymuś pełen import przy następnym imporcie"
|
41 |
+
"Get All","Wymuś"
|
package.xml
CHANGED
@@ -1,19 +1,18 @@
|
|
1 |
<?xml version="1.0"?>
|
2 |
<package>
|
3 |
<name>DataFeedWatch_Connector</name>
|
4 |
-
<version>0.
|
5 |
-
<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 |
-
</
|
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>
|
15 |
-
<time>
|
16 |
-
<contents><target name="magecommunity"><dir name="DataFeedWatch"><dir name="Connector"><dir
|
17 |
<compatible/>
|
18 |
<dependencies><required><php><min>5.3.0</min><max>7.0.0</max></php></required></dependencies>
|
19 |
</package>
|
1 |
<?xml version="1.0"?>
|
2 |
<package>
|
3 |
<name>DataFeedWatch_Connector</name>
|
4 |
+
<version>0.3.0</version>
|
5 |
+
<stability>stable</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</description>
|
11 |
+
<notes>DataFeedWatch - Release version 0.3.0</notes>
|
|
|
12 |
<authors><author><name>DataFeedWatch</name><user>WordWatch</user><email>support@datafeedwatch.com</email></author></authors>
|
13 |
+
<date>2016-05-18</date>
|
14 |
+
<time>12:58:37</time>
|
15 |
+
<contents><target name="mageetc"><dir name="modules"><file name="DataFeedWatch_Connector.xml" hash="df95373d268ebdc76ce48357f220dc15"/></dir></target><target name="magecommunity"><dir name="DataFeedWatch"><dir name="Connector"><dir name="Block"><dir name="Adminhtml"><dir name="System"><dir name="Config"><dir name="Form"><dir name="Button"><file name="Add.php" hash="a658851b480f5a475257be5eef217c16"/><file name="Extort.php" hash="cdf82e240841d96c15d59151571ee79c"/><file name="Open.php" hash="bc9605ba4852057019abc030db0a05a7"/><file name="Refresh.php" hash="913e50a9fb9f86f4c331e65c24e27218"/><file name="Restore.php" hash="571fe89a4514999cee65b65136894a9c"/></dir><dir name="Grid"><file name="Inheritance.php" hash="39f73b43227bc34df5cead15ddc251da"/></dir></dir><dir name="Grid"><dir name="Items"><file name="Row.php" hash="18e05a8d2c7898693256dd07507f94fd"/></dir><file name="Items.php" hash="a01a38ff3e3ae2e998441e1b8797e1d0"/><file name="Pager.php" hash="62a6c5d6b8f539f30954c356a4d16cdb"/></dir><file name="Grid.php" hash="3c4a5eefc0ae7e9638c119433bb93f0f"/></dir></dir></dir></dir><dir name="Helper"><file name="Data.php" hash="0e51191c2ca28beccc8e58da7866607e"/><file name="Registry.php" hash="747a962f7d7ff918c69acf5b084d559e"/></dir><dir name="Model"><dir name="Api"><file name="User.php" hash="2d7fc0477d68f2e9f4febf0e43879a69"/></dir><file name="Api.php" hash="f07b325d90defc0d30450fbb0bbfd75b"/><dir name="Catalog"><dir name="Attribute"><file name="Info.php" hash="cef43aa3d96aa64e019f6046e57f18a6"/></dir></dir><file name="Cron.php" hash="420a2a8b31f8a9194652f3cb4d543819"/><file name="Observer.php" hash="3daf2e2408eddc91b3561ff2974ffe5b"/><file name="Product.php" hash="5aeb0a164a77731a3fb3ffb8c042fa37"/><dir name="Resource"><dir name="Catalog"><dir name="Attribute"><dir name="Info"><file name="Collection.php" hash="957923c2e3d413bcb5c8d00c5d03ad73"/></dir><file name="Info.php" hash="e69e319a3057f1dce9b5f90b2409ce8e"/></dir></dir><dir name="Product"><dir name="Collection"><file name="Db.php" hash="47efd2f8334e2ab212dd7e03b29d37ef"/></dir><file name="Collection.php" hash="5fe21ff1047a6c1bb2abb3d9f1136cf6"/></dir><file name="Product.php" hash="746a8bde3cc3ce8d594ab8d35a78859c"/></dir><dir name="System"><dir name="Config"><dir name="Source"><file name="Inheritance.php" hash="9b8934ffc1943a2557bc1078fd44ad0c"/></dir></dir></dir></dir><dir name="controllers"><dir name="Adminhtml"><file name="DatafeedwatchController.php" hash="a30aa21568b5fd27bfdc086518bc21d2"/></dir></dir><dir name="data"><dir name="datafeedwatch_connector_setup"><file name="data-upgrade-0.2.40-0.2.50.php" hash="884feebb0d53c8df51df358e05e58fef"/></dir></dir><dir name="etc"><file name="adminhtml.xml" hash="0054cf5d1bd7b9bc001c84b5fc8f72c6"/><file name="api.xml" hash="780b354b3fe3e807d16602cbe0a27c5c"/><file name="config.xml" hash="f8535438f60c14e5cc140f8fbace0f15"/><file name="system.xml" hash="35d85a2485f6e8eb63bfc0298bc53470"/></dir><dir name="sql"><dir name="datafeedwatch_connector_setup"><file name="upgrade-0.2.40-0.2.50.php" hash="836706a3140867b327e64f5185d1f5c8"/></dir></dir></dir></dir></target><target name="magedesign"><dir name="adminhtml"><dir name="default"><dir name="default"><dir name="layout"><dir name="datafeedwatch"><file name="connector.xml" hash="4ee1df77504a8ebccff49deab7ce1e49"/></dir></dir><dir name="template"><dir name="datafeedwatch"><dir name="connector"><dir name="grid"><dir name="items"><file name="row.phtml" hash="14846b2faf1c3fd13cab6c9a5696b2c5"/></dir><file name="items.phtml" hash="d5928a0cf756d93eb517da7363563ca8"/><file name="pager.phtml" hash="6f41d682d5e4e9dcf9876f35d24a4651"/></dir><file name="grid.phtml" hash="76e9670e214dc1256b902a4d6ef33a3c"/></dir></dir></dir></dir></dir></dir></target><target name="magelocale"><dir name="pl_PL"><file name="DataFeedWatch_Connector.csv" hash="fb9f9a1dacfc2698ee05abcdd1342b86"/></dir><dir name="en_US"><file name="DataFeedWatch_Connector.csv" hash="fcfdb3ab74add74d704e504161411ef6"/></dir></target><target name="mageskin"><dir name="adminhtml"><dir name="default"><dir name="default"><dir name="datafeedwatch"><dir name="connector"><dir name="css"><dir name="grid"><file name="inheritance.css" hash="3d23c2a5285d6cdc4a514015926a8272"/></dir></dir><dir name="js"><dir name="grid"><file name="inheritance.js" hash="9fc3594f48fa519e11e2e17d0b427668"/></dir></dir></dir></dir></dir></dir></dir></target></contents>
|
16 |
<compatible/>
|
17 |
<dependencies><required><php><min>5.3.0</min><max>7.0.0</max></php></required></dependencies>
|
18 |
</package>
|
skin/adminhtml/default/default/connector.css
DELETED
@@ -1,3 +0,0 @@
|
|
1 |
-
input#additional_attributes_0_all {
|
2 |
-
margin-left: -30px;
|
3 |
-
}
|
|
|
|
|
|
skin/adminhtml/default/default/datafeedwatch/connector/css/grid/inheritance.css
ADDED
@@ -0,0 +1,13 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
#inheritance_grid { width: 950px; }
|
2 |
+
#inheritance_grid .attribute_inheritance_grid_header > div { font-weight: bolder; text-align: center; border-bottom: 1px solid #000; padding-bottom: 10px; }
|
3 |
+
#inheritance_grid > * > div, #inheritance_grid > * > * > div { display: inline-block; }
|
4 |
+
#inheritance_grid > * > .attribute_name, #inheritance_grid > * > * > .attribute_name { width: 310px; }
|
5 |
+
#inheritance_grid > * > .attribute_import, #inheritance_grid > * > * > .attribute_import, #inheritance_grid > * > * > .attribute_import select { width: 100px; text-align: center }
|
6 |
+
#inheritance_grid > * > .attribute_inheritance, #inheritance_grid > * > * > .attribute_inheritance { width: 530px; }
|
7 |
+
#inheritance_grid > * > .attribute_inheritance > div, #inheritance_grid > * > * > .attribute_inheritance > div { width: 173px; display: inline-block; text-align: center; }
|
8 |
+
#inheritance_grid > #attribute_inheritance_grid_items > .attribute_item > div { margin: 5px 0; }
|
9 |
+
#inheritance_grid > #attribute_inheritance_grid_items > .attribute_item:not(:last-of-type) > div { border-bottom: 1px dotted #000; padding-bottom: 5px; }
|
10 |
+
#inheritance_grid .inheritance_pager { display: block; width: 100%; text-align: right; border-top: 1px solid #000; margin-top: 5px; padding-top: 10px; }
|
11 |
+
#inheritance_grid .inheritance_pager > span:not(:last-child):after { content: "|"; margin: 0 10px }
|
12 |
+
#inheritance_grid .inheritance_pager select, #inheritance_grid .inheritance_pager input { width: 50px; }
|
13 |
+
#inheritance_grid .inheritance_pager .page .navigation { vertical-align: middle; }
|
skin/adminhtml/default/default/datafeedwatch/connector/js/grid/inheritance.js
ADDED
@@ -0,0 +1,41 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
document.addEventListener("DOMContentLoaded", function(event) {
|
2 |
+
getInheritanceGrid();
|
3 |
+
});
|
4 |
+
|
5 |
+
function getInheritanceGrid(page, limit) {
|
6 |
+
var urlInput = document.getElementById('inheritance_grid_action_url');
|
7 |
+
if (urlInput != null) {
|
8 |
+
var url = urlInput.value;
|
9 |
+
new Ajax.Request(url, {
|
10 |
+
method: 'get',
|
11 |
+
parameters: {page: page, limit: limit},
|
12 |
+
onSuccess: function(response) {
|
13 |
+
if (response != null && response.responseText != null) {
|
14 |
+
document.getElementById('attribute_inheritance_grid_items').innerHTML = response.responseText;
|
15 |
+
}
|
16 |
+
}
|
17 |
+
});
|
18 |
+
}
|
19 |
+
}
|
20 |
+
|
21 |
+
function saveInheritance(attributeId, value) {
|
22 |
+
var urlInput = document.getElementById('save_inheritance_action_url');
|
23 |
+
if (urlInput != null) {
|
24 |
+
var url = urlInput.value;
|
25 |
+
new Ajax.Request(url, {
|
26 |
+
method: 'get',
|
27 |
+
parameters: {attribute_id: attributeId, value: value}
|
28 |
+
});
|
29 |
+
}
|
30 |
+
}
|
31 |
+
|
32 |
+
function saveImport(attributeId, value) {
|
33 |
+
var urlInput = document.getElementById('save_import_action_url');
|
34 |
+
if (urlInput != null) {
|
35 |
+
var url = urlInput.value;
|
36 |
+
new Ajax.Request(url, {
|
37 |
+
method: 'get',
|
38 |
+
parameters: {attribute_id: attributeId, value: value}
|
39 |
+
});
|
40 |
+
}
|
41 |
+
};
|
skin/adminhtml/default/default/js/connector/connector.js
DELETED
@@ -1,17 +0,0 @@
|
|
1 |
-
document.observe('dom:loaded', function(){
|
2 |
-
|
3 |
-
$('additional_attributes_0_all').observe('click', function toggleChkBox(){
|
4 |
-
|
5 |
-
var attrValue = $('additional_attributes_0_all').checked;
|
6 |
-
// toggle Check Boxes using Prototype Library
|
7 |
-
var form=$('edit_form');
|
8 |
-
var i=form.getElements('checkbox');
|
9 |
-
i.each(function(item)
|
10 |
-
{
|
11 |
-
if(item.id.indexOf('additional_attributes')>-1 && item.id!='additional_attributes_0_all'){
|
12 |
-
item.checked = attrValue;
|
13 |
-
}
|
14 |
-
}
|
15 |
-
);
|
16 |
-
});
|
17 |
-
});
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|