Version Notes
DataFeedWatch - Release version 0.3.1
Download this release
Release Info
Developer | WordWatch |
Extension | DataFeedWatch_Connector |
Version | 0.3.1 |
Comparing to | |
See all releases |
Code changes from version 0.3 to 0.3.1
- .gitignore +0 -1
- app/code/community/DataFeedWatch/Connector/Block/Adminhtml/System/Config/Grid/Pager.php +2 -6
- app/code/community/DataFeedWatch/Connector/Helper/Data.php +10 -4
- app/code/community/DataFeedWatch/Connector/Helper/Registry.php +15 -1
- app/code/community/DataFeedWatch/Connector/Model/Catalog/Attribute/Info.php +0 -121
- app/code/community/DataFeedWatch/Connector/Model/Cron.php +1 -1
- app/code/community/DataFeedWatch/Connector/Model/Observer.php +48 -81
- app/code/community/DataFeedWatch/Connector/Model/Product.php +3 -2
- app/code/community/DataFeedWatch/Connector/Model/Resource/Catalog/Attribute/Info.php +0 -10
- app/code/community/DataFeedWatch/Connector/Model/Resource/Catalog/Attribute/Info/Collection.php +0 -10
- app/code/community/DataFeedWatch/Connector/Model/Resource/Product/Collection.php +29 -5
- app/code/community/DataFeedWatch/Connector/Model/Resource/Product/Collection/Db.php +67 -41
- app/code/community/DataFeedWatch/Connector/controllers/Adminhtml/DatafeedwatchController.php +15 -4
- app/code/community/DataFeedWatch/Connector/data/datafeedwatch_connector_setup/data-upgrade-0.2.40-0.2.50.php +1 -3
- app/code/community/DataFeedWatch/Connector/data/datafeedwatch_connector_setup/data-upgrade-0.3.0-0.3.1.php +26 -0
- app/code/community/DataFeedWatch/Connector/etc/config.xml +24 -35
- app/code/community/DataFeedWatch/Connector/sql/datafeedwatch_connector_setup/upgrade-0.2.40-0.2.50.php +13 -56
- app/code/community/DataFeedWatch/Connector/sql/datafeedwatch_connector_setup/upgrade-0.3.0-0.3.1.php +129 -0
- app/design/adminhtml/default/default/template/datafeedwatch/connector/grid/items/row.phtml +1 -1
- package.xml +5 -5
.gitignore
DELETED
@@ -1 +0,0 @@
|
|
1 |
-
.idea/
|
|
app/code/community/DataFeedWatch/Connector/Block/Adminhtml/System/Config/Grid/Pager.php
CHANGED
@@ -14,12 +14,8 @@ class DataFeedWatch_Connector_Block_Adminhtml_System_Config_Grid_Pager
|
|
14 |
->addVisibleFilter()
|
15 |
->setPageSize($this->limit)
|
16 |
->setCurPage($this->page);
|
17 |
-
$attributeCollection->getSelect()
|
18 |
-
|
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;
|
14 |
->addVisibleFilter()
|
15 |
->setPageSize($this->limit)
|
16 |
->setCurPage($this->page);
|
17 |
+
$attributeCollection->getSelect()
|
18 |
+
->where('additional_table.can_configure_inheritance != 0 and additional_table.import_to_dfw != 0 or additional_table.can_configure_inheritance = 1');
|
|
|
|
|
|
|
|
|
19 |
$attributeCollection->setOrder('frontend_label', 'asc');
|
20 |
|
21 |
return $attributeCollection;
|
app/code/community/DataFeedWatch/Connector/Helper/Data.php
CHANGED
@@ -166,6 +166,7 @@ class DataFeedWatch_Connector_Helper_Data
|
|
166 |
'sku',
|
167 |
'updated_at',
|
168 |
'ignore_datafeedwatch',
|
|
|
169 |
);
|
170 |
|
171 |
$cannotConfigureInheritanceField = array(
|
@@ -180,6 +181,7 @@ class DataFeedWatch_Connector_Helper_Data
|
|
180 |
'thumbnail',
|
181 |
'updated_at',
|
182 |
'ignore_datafeedwatch',
|
|
|
183 |
);
|
184 |
|
185 |
$enableImport = array(
|
@@ -203,9 +205,15 @@ class DataFeedWatch_Connector_Helper_Data
|
|
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('
|
|
|
|
|
|
|
|
|
|
|
209 |
|
210 |
$attributes = Mage::getResourceModel('catalog/product_attribute_collection')->addVisibleFilter();
|
211 |
foreach ($attributes as $attribute) {
|
@@ -214,9 +222,7 @@ class DataFeedWatch_Connector_Helper_Data
|
|
214 |
if (array_key_exists($attributeCode, $inheritanceData)) {
|
215 |
$inheritance = $inheritanceData[$attributeCode];
|
216 |
}
|
217 |
-
|
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)
|
166 |
'sku',
|
167 |
'updated_at',
|
168 |
'ignore_datafeedwatch',
|
169 |
+
'dfw_parent_ids',
|
170 |
);
|
171 |
|
172 |
$cannotConfigureInheritanceField = array(
|
181 |
'thumbnail',
|
182 |
'updated_at',
|
183 |
'ignore_datafeedwatch',
|
184 |
+
'dfw_parent_ids',
|
185 |
);
|
186 |
|
187 |
$enableImport = array(
|
205 |
$inheritanceData = array(
|
206 |
'updated_at' => DataFeedWatch_Connector_Model_System_Config_Source_Inheritance::PARENT_OPTION_ID,
|
207 |
'ignore_datafeedwatch' => DataFeedWatch_Connector_Model_System_Config_Source_Inheritance::CHILD_OPTION_ID,
|
208 |
+
'dfw_parent_ids' => DataFeedWatch_Connector_Model_System_Config_Source_Inheritance::CHILD_OPTION_ID,
|
209 |
);
|
210 |
|
211 |
+
$catalogAttributes = Mage::getResourceModel('catalog/product_attribute_collection');
|
212 |
+
$catalogAttributes->setDataToAll('can_configure_inheritance', null);
|
213 |
+
$catalogAttributes->setDataToAll('inheritance', null);
|
214 |
+
$catalogAttributes->setDataToAll('can_configure_import', null);
|
215 |
+
$catalogAttributes->setDataToAll('import_to_dfw', null);
|
216 |
+
$catalogAttributes->save();
|
217 |
|
218 |
$attributes = Mage::getResourceModel('catalog/product_attribute_collection')->addVisibleFilter();
|
219 |
foreach ($attributes as $attribute) {
|
222 |
if (array_key_exists($attributeCode, $inheritanceData)) {
|
223 |
$inheritance = $inheritanceData[$attributeCode];
|
224 |
}
|
225 |
+
$attribute->setImportToDfw(in_array($attributeCode, $enableImport))
|
|
|
|
|
226 |
->setCanConfigureImport(!in_array($attributeCode, $cannotConfigureImportField))
|
227 |
->setCanConfigureInheritance(!in_array($attributeCode, $cannotConfigureInheritanceField))
|
228 |
->setInheritance($inheritance)
|
app/code/community/DataFeedWatch/Connector/Helper/Registry.php
CHANGED
@@ -10,6 +10,7 @@ class DataFeedWatch_Connector_Helper_Registry
|
|
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
|
@@ -20,6 +21,7 @@ class DataFeedWatch_Connector_Helper_Registry
|
|
20 |
$this->registerStatusAttribute();
|
21 |
$this->registerUpdatedAtAttribute();
|
22 |
$this->registerVisibilityAttribute();
|
|
|
23 |
$this->registerSuperAttributes();
|
24 |
$this->registerInheritableAttributes();
|
25 |
$this->registerAttributeCollection();
|
@@ -121,6 +123,18 @@ class DataFeedWatch_Connector_Helper_Registry
|
|
121 |
}
|
122 |
}
|
123 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
124 |
/**
|
125 |
* @return bool
|
126 |
*/
|
@@ -135,7 +149,7 @@ class DataFeedWatch_Connector_Helper_Registry
|
|
135 |
*/
|
136 |
public function isAttributeInheritable($attribute)
|
137 |
{
|
138 |
-
return in_array($attribute->
|
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,
|
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 |
+
const DFW_PARENT_ID_ATTRIBUTE_KEY = 'dfw_parent_id_attribute';
|
14 |
|
15 |
/**
|
16 |
* @param string $storeId
|
21 |
$this->registerStatusAttribute();
|
22 |
$this->registerUpdatedAtAttribute();
|
23 |
$this->registerVisibilityAttribute();
|
24 |
+
$this->registerParentIdAttribute();
|
25 |
$this->registerSuperAttributes();
|
26 |
$this->registerInheritableAttributes();
|
27 |
$this->registerAttributeCollection();
|
123 |
}
|
124 |
}
|
125 |
|
126 |
+
protected function registerParentIdAttribute()
|
127 |
+
{
|
128 |
+
$registry = Mage::registry(self::DFW_PARENT_ID_ATTRIBUTE_KEY);
|
129 |
+
if (empty($registry)) {
|
130 |
+
/** @var Mage_Catalog_Model_Resource_Eav_Attribute $statusAttribute */
|
131 |
+
$attribute = Mage::getResourceModel('catalog/product_attribute_collection')
|
132 |
+
->addVisibleFilter()
|
133 |
+
->addFieldToFilter('attribute_code', 'dfw_parent_ids')->getFirstItem();
|
134 |
+
Mage::register(self::DFW_PARENT_ID_ATTRIBUTE_KEY, $attribute);
|
135 |
+
}
|
136 |
+
}
|
137 |
+
|
138 |
/**
|
139 |
* @return bool
|
140 |
*/
|
149 |
*/
|
150 |
public function isAttributeInheritable($attribute)
|
151 |
{
|
152 |
+
return in_array($attribute->getInheritance(),
|
153 |
array(
|
154 |
(string) DataFeedWatch_Connector_Model_System_Config_Source_Inheritance::PARENT_OPTION_ID,
|
155 |
(string) DataFeedWatch_Connector_Model_System_Config_Source_Inheritance::CHILD_THEN_PARENT_OPTION_ID,
|
app/code/community/DataFeedWatch/Connector/Model/Catalog/Attribute/Info.php
DELETED
@@ -1,121 +0,0 @@
|
|
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/Cron.php
CHANGED
@@ -40,7 +40,7 @@ class DataFeedWatch_Connector_Model_Cron
|
|
40 |
$updatedDataTable = $this->getTable('datafeedwatch_connector/updated_products');
|
41 |
foreach ($priceData as $data) {
|
42 |
$insertedData = array(
|
43 |
-
'
|
44 |
'updated_at' => $date,
|
45 |
);
|
46 |
$writeConnection->insertOnDuplicate($updatedDataTable, $insertedData, array('updated_at'));
|
40 |
$updatedDataTable = $this->getTable('datafeedwatch_connector/updated_products');
|
41 |
foreach ($priceData as $data) {
|
42 |
$insertedData = array(
|
43 |
+
'dfw_prod_id' => $data['product_id'],
|
44 |
'updated_at' => $date,
|
45 |
);
|
46 |
$writeConnection->insertOnDuplicate($updatedDataTable, $insertedData, array('updated_at'));
|
app/code/community/DataFeedWatch/Connector/Model/Observer.php
CHANGED
@@ -17,8 +17,8 @@ class DataFeedWatch_Connector_Model_Observer
|
|
17 |
'values' => Mage::getModel('adminhtml/system_config_source_yesno')->toOptionArray(),
|
18 |
'disabled' => $attribute->hasCanConfigureImport() && !$attribute->getCanConfigureImport(),
|
19 |
), 'is_configurable');
|
20 |
-
$fieldset->addField('
|
21 |
-
'name' => '
|
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(),
|
@@ -52,84 +52,6 @@ class DataFeedWatch_Connector_Model_Observer
|
|
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
|
@@ -141,7 +63,7 @@ class DataFeedWatch_Connector_Model_Observer
|
|
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('
|
145 |
|
146 |
return $this;
|
147 |
}
|
@@ -195,6 +117,51 @@ class DataFeedWatch_Connector_Model_Observer
|
|
195 |
}
|
196 |
}
|
197 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
198 |
/**
|
199 |
* @param Mage_Adminhtml_Model_Config_Data $configModel
|
200 |
* @param string $xpath
|
17 |
'values' => Mage::getModel('adminhtml/system_config_source_yesno')->toOptionArray(),
|
18 |
'disabled' => $attribute->hasCanConfigureImport() && !$attribute->getCanConfigureImport(),
|
19 |
), 'is_configurable');
|
20 |
+
$fieldset->addField('inheritance', 'select', array(
|
21 |
+
'name' => '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(),
|
52 |
return $this;
|
53 |
}
|
54 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
55 |
/**
|
56 |
* @param Varien_Event_Observer $observer
|
57 |
* @return $this
|
63 |
$resource = Mage::getSingleton('core/resource');
|
64 |
$connection = $resource->getConnection('core_write');
|
65 |
$connection->delete(Mage::getModel('core/resource')->getTableName('datafeedwatch_connector/updated_products'),
|
66 |
+
sprintf('dfw_prod_id = %s', $product->getId()));
|
67 |
|
68 |
return $this;
|
69 |
}
|
117 |
}
|
118 |
}
|
119 |
|
120 |
+
public function checkAndUpdateAttributeInheritance(Varien_Event_Observer $observer)
|
121 |
+
{
|
122 |
+
$attribute = $observer->getAttribute();
|
123 |
+
if (!$attribute->getCanConfigureImport() && !$attribute->isObjectNew()) {
|
124 |
+
$attribute->setImportToDfw($attribute->getOrigData('import_to_dfw'));
|
125 |
+
}
|
126 |
+
if ($attribute->hasCanConfigureInheritance() && !$attribute->getCanConfigureInheritance() && !$attribute->isObjectNew()) {
|
127 |
+
$attribute->setInheritance($attribute->getOrigData('inheritance'));
|
128 |
+
}
|
129 |
+
|
130 |
+
if ($this->canSaveUpdateDate($attribute)) {
|
131 |
+
$this->helper()->updateLastInheritanceUpdateDate();
|
132 |
+
}
|
133 |
+
|
134 |
+
return $this;
|
135 |
+
}
|
136 |
+
|
137 |
+
/**
|
138 |
+
* @param $attribute
|
139 |
+
*
|
140 |
+
* @return bool
|
141 |
+
*/
|
142 |
+
protected function canSaveUpdateDate($attribute)
|
143 |
+
{
|
144 |
+
return ($attribute->dataHasChangedFor('inheritance') && (int)$attribute->getOrigData('import_to_dfw') === 1)
|
145 |
+
|| $attribute->dataHasChangedFor('import_to_dfw')
|
146 |
+
|| (int)$attribute->getData('import_to_dfw') === 1
|
147 |
+
|| $attribute->isObjectNew();
|
148 |
+
}
|
149 |
+
|
150 |
+
public function changeChildProductUpdatedAt(Varien_Event_Observer $observer)
|
151 |
+
{
|
152 |
+
/** @var Mage_Catalog_Model_Product $product */
|
153 |
+
$product = $observer->getProduct();
|
154 |
+
|
155 |
+
if ($product->isConfigurable()) {
|
156 |
+
$childProducts = $product->getTypeInstance(true)->getUsedProducts(null, $product);
|
157 |
+
foreach ($childProducts as $child) {
|
158 |
+
$child->setUpdatedAt($product->getUpdatedAt())->save();
|
159 |
+
}
|
160 |
+
}
|
161 |
+
|
162 |
+
return $this;
|
163 |
+
}
|
164 |
+
|
165 |
/**
|
166 |
* @param Mage_Adminhtml_Model_Config_Data $configModel
|
167 |
* @param string $xpath
|
app/code/community/DataFeedWatch/Connector/Model/Product.php
CHANGED
@@ -101,11 +101,12 @@ class DataFeedWatch_Connector_Model_Product
|
|
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) ||
|
109 |
continue;
|
110 |
}
|
111 |
$value = $attribute->getFrontend()->getValue($this);
|
@@ -357,7 +358,7 @@ class DataFeedWatch_Connector_Model_Product
|
|
357 |
$allAttributes = Mage::registry(DataFeedWatch_Connector_Helper_Registry::ALL_ATTRIBUTE_COLLECTION_KEY);
|
358 |
foreach ($allAttributes as $attribute) {
|
359 |
$attributeCode = $attribute->getAttributeCode();
|
360 |
-
switch ($attribute->
|
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)) {
|
101 |
*/
|
102 |
protected function fillAllAttributesData()
|
103 |
{
|
104 |
+
$productAttributes = array_keys($this->getAttributes());
|
105 |
$attributeCollection = Mage::registry(DataFeedWatch_Connector_Helper_Registry::ALL_IMPORTABLE_ATTRIBUTES_KEY);
|
106 |
foreach ($attributeCollection as $attribute) {
|
107 |
$attributeCode = $attribute->getAttributeCode();
|
108 |
$data = $this->getData($attributeCode);
|
109 |
+
if (empty($attributeCode) || !in_array($attributeCode, $productAttributes)) {
|
110 |
continue;
|
111 |
}
|
112 |
$value = $attribute->getFrontend()->getValue($this);
|
358 |
$allAttributes = Mage::registry(DataFeedWatch_Connector_Helper_Registry::ALL_ATTRIBUTE_COLLECTION_KEY);
|
359 |
foreach ($allAttributes as $attribute) {
|
360 |
$attributeCode = $attribute->getAttributeCode();
|
361 |
+
switch ($attribute->getInheritance()) {
|
362 |
case (string) DataFeedWatch_Connector_Model_System_Config_Source_Inheritance::CHILD_THEN_PARENT_OPTION_ID:
|
363 |
$productData = $this->getData($attributeCode);
|
364 |
if (empty($productData) || $this->shouldChangeVisibilityForProduct($attribute)) {
|
app/code/community/DataFeedWatch/Connector/Model/Resource/Catalog/Attribute/Info.php
DELETED
@@ -1,10 +0,0 @@
|
|
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
DELETED
@@ -1,10 +0,0 @@
|
|
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/Product/Collection.php
CHANGED
@@ -40,10 +40,13 @@ class DataFeedWatch_Connector_Model_Resource_Product_Collection
|
|
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();
|
@@ -51,14 +54,31 @@ class DataFeedWatch_Connector_Model_Resource_Product_Collection
|
|
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
|
@@ -144,11 +164,15 @@ class DataFeedWatch_Connector_Model_Resource_Product_Collection
|
|
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 |
}
|
40 |
$this->optionsFilters = $options;
|
41 |
$this->applyStoreFilter();
|
42 |
$this->registryHelper()->initImportRegistry($this->getStoreId());
|
|
|
|
|
43 |
$this->joinVisibilityTable(DataFeedWatch_Connector_Model_Resource_Product_Collection_Db::VISIBILITY_TABLE_ALIAS_DEFAULT_STORE, '0');
|
44 |
$this->joinVisibilityTable(DataFeedWatch_Connector_Model_Resource_Product_Collection_Db::ORIGINAL_VISIBILITY_TABLE_ALIAS, $this->getStoreId());
|
45 |
+
$this->fillParentIds();
|
46 |
+
$this->addAttributeToSelect('dfw_parent_ids');
|
47 |
+
$this->joinParentIdsTable(DataFeedWatch_Connector_Model_Resource_Product_Collection_Db::PARENT_IDS_TABLE_ALIAS_DEFAULT_STORE, '0');
|
48 |
+
$this->joinParentIdsTable(DataFeedWatch_Connector_Model_Resource_Product_Collection_Db::ORIGINAL_PARENT_IDS_TABLE_ALIAS, $this->getStoreId());
|
49 |
+
$this->addRuleDate();
|
50 |
$this->applyTypeFilter();
|
51 |
$this->joinQty();
|
52 |
$this->addFinalPrice();
|
54 |
$this->applyStatusFilter();
|
55 |
$this->applyUpdatedAtFilter();
|
56 |
$this->addAttributeToSelect('ignore_datafeedwatch');
|
57 |
+
$this->addAttributeToFilter('ignore_datafeedwatch', array(array('null' => true), array('neq' => 1)), 'left');
|
|
|
58 |
|
59 |
$this->setPage($this->optionsFilters['page'], $this->optionsFilters['per_page']);
|
60 |
$this->helper()->sqlLog($this->getSelect()->__toString());
|
61 |
|
62 |
return $this;
|
63 |
}
|
64 |
+
|
65 |
+
public function fillParentIds()
|
66 |
+
{
|
67 |
+
Mage::app()->setCurrentStore(Mage_Core_Model_App::ADMIN_STORE_ID);
|
68 |
+
|
69 |
+
$collection = Mage::getResourceModel('catalog/product_collection');
|
70 |
+
foreach($collection as $product) {
|
71 |
+
$parentIds = Mage::getModel('catalog/product_type_configurable')->getParentIdsByChild($product->getId());
|
72 |
+
if (!empty($parentIds)) {
|
73 |
+
// $product->setDfwParentIds(implode(',', $parentIds));
|
74 |
+
$product->setDfwParentIds(current($parentIds));
|
75 |
+
$product->getResource()->saveAttribute($product, 'dfw_parent_ids');
|
76 |
+
}
|
77 |
+
}
|
78 |
+
Mage::app()->setCurrentStore($this->getStoreId());
|
79 |
+
|
80 |
+
return $this;
|
81 |
+
}
|
82 |
|
83 |
/**
|
84 |
* @param $store
|
164 |
*/
|
165 |
protected function addParentData()
|
166 |
{
|
|
|
167 |
$parentCollection = $this->getParentProductsCollection();
|
168 |
$parentCollection = $parentCollection->getItems();
|
169 |
foreach ($this->getItems() as $product) {
|
170 |
$parentId = $product->getParentId();
|
171 |
+
$parentId = explode(',', $parentId);
|
172 |
+
if (is_array($parentId)) {
|
173 |
+
$parentId = current($parentId);
|
174 |
+
}
|
175 |
+
|
176 |
if (empty($parentId) || !isset($parentCollection[$parentId])) {
|
177 |
continue;
|
178 |
}
|
app/code/community/DataFeedWatch/Connector/Model/Resource/Product/Collection/Db.php
CHANGED
@@ -3,18 +3,18 @@
|
|
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 */
|
@@ -51,7 +51,7 @@ class DataFeedWatch_Connector_Model_Resource_Product_Collection_Db
|
|
51 |
$select = new Zend_Db_Select($this->getEntity()->getReadConnection());
|
52 |
$select->from(
|
53 |
array(
|
54 |
-
|
55 |
),
|
56 |
array(
|
57 |
sprintf('COALESCE(%1$s.updated_at, 0)', self::UPDATED_AT_TABLE_ALIAS),
|
@@ -60,10 +60,10 @@ class DataFeedWatch_Connector_Model_Resource_Product_Collection_Db
|
|
60 |
$select->where($condition);
|
61 |
$select->limit(1);
|
62 |
|
63 |
-
$this->ruleDateSelect = sprintf('GREATEST(IFNULL((%s), 0), COALESCE(%2$s.updated_at, 0)
|
64 |
-
$select->__toString(), self::MAIN_TABLE_ALIAS
|
65 |
$this->getSelect()->columns(array(self::CATALOGRULE_DATE_COLUMN_ALIAS => new Zend_Db_Expr($this->ruleDateSelect)));
|
66 |
-
|
67 |
return $this;
|
68 |
}
|
69 |
|
@@ -73,11 +73,9 @@ class DataFeedWatch_Connector_Model_Resource_Product_Collection_Db
|
|
73 |
*/
|
74 |
protected function getUpdatedAtCondition()
|
75 |
{
|
76 |
-
$condition = '((%3$s.
|
77 |
$condition = sprintf($condition,
|
78 |
-
self::UPDATED_AT_TABLE_ALIAS, self::MAIN_TABLE_ALIAS, self::
|
79 |
-
Mage_Customer_Model_Group::NOT_LOGGED_IN_ID,
|
80 |
-
Mage::app()->getWebsite()->getId(), Mage::app()->getDefaultStoreView()->getWebsiteId());
|
81 |
|
82 |
return $condition;
|
83 |
}
|
@@ -104,7 +102,7 @@ class DataFeedWatch_Connector_Model_Resource_Product_Collection_Db
|
|
104 |
protected function getStatusTable()
|
105 |
{
|
106 |
return Mage::registry(DataFeedWatch_Connector_Helper_Registry::DFW_STATUS_ATTRIBUTE_KEY)
|
107 |
-
|
108 |
}
|
109 |
|
110 |
/**
|
@@ -114,7 +112,7 @@ class DataFeedWatch_Connector_Model_Resource_Product_Collection_Db
|
|
114 |
protected function getVisibilityTable()
|
115 |
{
|
116 |
return Mage::registry(DataFeedWatch_Connector_Helper_Registry::DFW_STATUS_ATTRIBUTE_KEY)
|
117 |
-
|
118 |
}
|
119 |
|
120 |
/**
|
@@ -126,39 +124,13 @@ class DataFeedWatch_Connector_Model_Resource_Product_Collection_Db
|
|
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->
|
162 |
case (string) DataFeedWatch_Connector_Model_System_Config_Source_Inheritance::CHILD_THEN_PARENT_OPTION_ID:
|
163 |
$inheritString = "IFNULL({$childString}, {$parentString})";
|
164 |
// $inheritWithStatusString = 'IFNULL(
|
@@ -209,8 +181,8 @@ class DataFeedWatch_Connector_Model_Resource_Product_Collection_Db
|
|
209 |
*/
|
210 |
protected function getJoinInheritedStatusTableStatement($tableAlias, $storeId)
|
211 |
{
|
212 |
-
return sprintf('%1$s.entity_id
|
213 |
-
$tableAlias, self::
|
214 |
$this->getJoinStatusAttributeStatement($tableAlias, $storeId)
|
215 |
);
|
216 |
}
|
@@ -303,4 +275,58 @@ class DataFeedWatch_Connector_Model_Resource_Product_Collection_Db
|
|
303 |
$tableAlias, $statusAttribute->getId(), $storeId);
|
304 |
}
|
305 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
306 |
}
|
3 |
class DataFeedWatch_Connector_Model_Resource_Product_Collection_Db
|
4 |
extends Mage_Catalog_Model_Resource_Product_Collection
|
5 |
{
|
|
|
6 |
const INHERITED_STATUS_TABLE_ALIAS = 'inherited_status';
|
7 |
const INHERITED_STATUS_TABLE_ALIAS_DEFAULT_STORE = 'inherited_status_default_store';
|
8 |
const ORIGINAL_STATUS_TABLE_ALIAS = 'original_status';
|
9 |
const ORIGINAL_STATUS_TABLE_ALIAS_DEFAULT_STORE = 'status_default_store';
|
10 |
const ORIGINAL_VISIBILITY_TABLE_ALIAS = 'original_visibility';
|
11 |
const VISIBILITY_TABLE_ALIAS_DEFAULT_STORE = 'visibility_default_store';
|
12 |
+
const PARENT_IDS_TABLE_ALIAS_DEFAULT_STORE = 'dfw_parent_ids_default_store';
|
13 |
+
const ORIGINAL_PARENT_IDS_TABLE_ALIAS = 'original_dfw_parent_ids';
|
14 |
const MIXED_STATUS_COLUMN_ALIAS = 'filter_status';
|
15 |
const PARENT_CONFIGURABLE_ATTRIBUTES_TABLE_ALIAS = 'parent_configurable_attributes';
|
16 |
const PARENT_RELATIONS_TABLE_ALIAS = 'parent_relation';
|
17 |
const UPDATED_AT_TABLE_ALIAS = 'custom_updated_at';
|
|
|
18 |
const CATALOGRULE_DATE_COLUMN_ALIAS = 'rule_date';
|
19 |
|
20 |
/** @var string $filterStatusCondition */
|
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),
|
60 |
$select->where($condition);
|
61 |
$select->limit(1);
|
62 |
|
63 |
+
$this->ruleDateSelect = sprintf('GREATEST(IFNULL((%s), 0), COALESCE(%2$s.updated_at, 0))',
|
64 |
+
$select->__toString(), self::MAIN_TABLE_ALIAS);
|
65 |
$this->getSelect()->columns(array(self::CATALOGRULE_DATE_COLUMN_ALIAS => new Zend_Db_Expr($this->ruleDateSelect)));
|
66 |
+
|
67 |
return $this;
|
68 |
}
|
69 |
|
73 |
*/
|
74 |
protected function getUpdatedAtCondition()
|
75 |
{
|
76 |
+
$condition = '(IFNULL(%3$s.value, %4$s.value) IS NOT NULL AND %1$s.dfw_prod_id IN (IFNULL(%3$s.value, %4$s.value)) OR %1$s.dfw_prod_id = %2$s.entity_id)';
|
77 |
$condition = sprintf($condition,
|
78 |
+
self::UPDATED_AT_TABLE_ALIAS, self::MAIN_TABLE_ALIAS, self::ORIGINAL_PARENT_IDS_TABLE_ALIAS, self::PARENT_IDS_TABLE_ALIAS_DEFAULT_STORE);
|
|
|
|
|
79 |
|
80 |
return $condition;
|
81 |
}
|
102 |
protected function getStatusTable()
|
103 |
{
|
104 |
return Mage::registry(DataFeedWatch_Connector_Helper_Registry::DFW_STATUS_ATTRIBUTE_KEY)
|
105 |
+
->getBackend()->getTable();
|
106 |
}
|
107 |
|
108 |
/**
|
112 |
protected function getVisibilityTable()
|
113 |
{
|
114 |
return Mage::registry(DataFeedWatch_Connector_Helper_Registry::DFW_STATUS_ATTRIBUTE_KEY)
|
115 |
+
->getBackend()->getTable();
|
116 |
}
|
117 |
|
118 |
/**
|
124 |
return Mage::registry(DataFeedWatch_Connector_Helper_Registry::DFW_STATUS_ATTRIBUTE_KEY)->getAttributeId();
|
125 |
}
|
126 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
127 |
protected function buildFilterStatusCondition()
|
128 |
{
|
129 |
$childString = 'IFNULL(%1$s.value, %3$s.value)';
|
130 |
$parentString = 'IFNULL(%2$s.value, %4$s.value)';
|
131 |
$enable = Mage_Catalog_Model_Product_Status::STATUS_ENABLED;
|
132 |
$statusAttribute = Mage::registry(DataFeedWatch_Connector_Helper_Registry::DFW_STATUS_ATTRIBUTE_KEY);
|
133 |
+
switch($statusAttribute->getInheritance()) {
|
134 |
case (string) DataFeedWatch_Connector_Model_System_Config_Source_Inheritance::CHILD_THEN_PARENT_OPTION_ID:
|
135 |
$inheritString = "IFNULL({$childString}, {$parentString})";
|
136 |
// $inheritWithStatusString = 'IFNULL(
|
181 |
*/
|
182 |
protected function getJoinInheritedStatusTableStatement($tableAlias, $storeId)
|
183 |
{
|
184 |
+
return sprintf('%1$s.entity_id IN (IFNULL(%2$s.value, %3$s.value)) and %4$s',
|
185 |
+
$tableAlias, self::ORIGINAL_PARENT_IDS_TABLE_ALIAS, self::PARENT_IDS_TABLE_ALIAS_DEFAULT_STORE,
|
186 |
$this->getJoinStatusAttributeStatement($tableAlias, $storeId)
|
187 |
);
|
188 |
}
|
275 |
$tableAlias, $statusAttribute->getId(), $storeId);
|
276 |
}
|
277 |
|
278 |
+
/**
|
279 |
+
* @param string $tableAlias
|
280 |
+
* @param string $storeId
|
281 |
+
* @return $this
|
282 |
+
*/
|
283 |
+
protected function joinParentIdsTable($tableAlias = self::PARENT_IDS_TABLE_ALIAS_DEFAULT_STORE, $storeId = '0')
|
284 |
+
{
|
285 |
+
if ($this->isTableAliasAdded($tableAlias)) {
|
286 |
+
|
287 |
+
return $this;
|
288 |
+
}
|
289 |
+
|
290 |
+
$this->getSelect()->joinLeft(
|
291 |
+
array($tableAlias => $this->getParentIdsTable()),
|
292 |
+
$this->getJoinParentIdsTableStatement($tableAlias, $storeId),
|
293 |
+
array('value'));
|
294 |
+
$this->getSelect()->columns(sprintf('IFNULL(%1$s.value, %2$s.value) as parent_id', self::ORIGINAL_PARENT_IDS_TABLE_ALIAS, self::PARENT_IDS_TABLE_ALIAS_DEFAULT_STORE));
|
295 |
+
|
296 |
+
return $this;
|
297 |
+
}
|
298 |
+
|
299 |
+
/**
|
300 |
+
* @param string $tableAlias
|
301 |
+
* @param string $storeId
|
302 |
+
* @return string
|
303 |
+
*/
|
304 |
+
protected function getJoinParentIdsTableStatement($tableAlias, $storeId)
|
305 |
+
{
|
306 |
+
return sprintf('%1$s.entity_id = e.entity_id and %2$s',
|
307 |
+
$tableAlias, $this->getJoinParentIdsAttributeStatement($tableAlias, $storeId)
|
308 |
+
);
|
309 |
+
}
|
310 |
+
|
311 |
+
/**
|
312 |
+
* @param string $tableAlias
|
313 |
+
* @param string $storeId
|
314 |
+
* @return string
|
315 |
+
*/
|
316 |
+
protected function getJoinParentIdsAttributeStatement($tableAlias, $storeId = '0')
|
317 |
+
{
|
318 |
+
$attribute = Mage::registry(DataFeedWatch_Connector_Helper_Registry::DFW_PARENT_ID_ATTRIBUTE_KEY);
|
319 |
+
return sprintf('%1$s.attribute_id = %2$s and %1$s.store_id = %3$s',
|
320 |
+
$tableAlias, $attribute->getId(), $storeId);
|
321 |
+
}
|
322 |
+
|
323 |
+
/**
|
324 |
+
* @return string
|
325 |
+
* @throws Mage_Core_Exception
|
326 |
+
*/
|
327 |
+
protected function getParentIdsTable()
|
328 |
+
{
|
329 |
+
return Mage::registry(DataFeedWatch_Connector_Helper_Registry::DFW_PARENT_ID_ATTRIBUTE_KEY)
|
330 |
+
->getBackend()->getTable();
|
331 |
+
}
|
332 |
}
|
app/code/community/DataFeedWatch/Connector/controllers/Adminhtml/DatafeedwatchController.php
CHANGED
@@ -95,9 +95,11 @@ class DataFeedWatch_Connector_Adminhtml_DatafeedwatchController
|
|
95 |
$attributeId = $this->getRequest()->getParam('attribute_id');
|
96 |
$value = $this->getRequest()->getParam('value');
|
97 |
|
98 |
-
$attribute
|
99 |
-
|
|
|
100 |
$attribute->setInheritance($value)->save();
|
|
|
101 |
}
|
102 |
|
103 |
public function saveAttributeImportAction()
|
@@ -105,9 +107,10 @@ class DataFeedWatch_Connector_Adminhtml_DatafeedwatchController
|
|
105 |
$attributeId = $this->getRequest()->getParam('attribute_id');
|
106 |
$value = $this->getRequest()->getParam('value');
|
107 |
|
108 |
-
$attribute
|
109 |
-
|
110 |
$attribute->setImportToDfw($value)->save();
|
|
|
111 |
|
112 |
}
|
113 |
|
@@ -118,4 +121,12 @@ class DataFeedWatch_Connector_Adminhtml_DatafeedwatchController
|
|
118 |
{
|
119 |
return Mage::getModel('datafeedwatch_connector/api_user');
|
120 |
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
121 |
}
|
95 |
$attributeId = $this->getRequest()->getParam('attribute_id');
|
96 |
$value = $this->getRequest()->getParam('value');
|
97 |
|
98 |
+
/* @var $attribute Mage_Catalog_Model_Entity_Attribute */
|
99 |
+
$attribute = Mage::getModel('catalog/resource_eav_attribute')->load($attributeId);
|
100 |
+
/* @var $helper Mage_Catalog_Helper_Product */
|
101 |
$attribute->setInheritance($value)->save();
|
102 |
+
$this->helper()->updateLastInheritanceUpdateDate();
|
103 |
}
|
104 |
|
105 |
public function saveAttributeImportAction()
|
107 |
$attributeId = $this->getRequest()->getParam('attribute_id');
|
108 |
$value = $this->getRequest()->getParam('value');
|
109 |
|
110 |
+
/* @var $attribute Mage_Catalog_Model_Entity_Attribute */
|
111 |
+
$attribute = Mage::getModel('catalog/resource_eav_attribute')->load($attributeId);
|
112 |
$attribute->setImportToDfw($value)->save();
|
113 |
+
$this->helper()->updateLastInheritanceUpdateDate();
|
114 |
|
115 |
}
|
116 |
|
121 |
{
|
122 |
return Mage::getModel('datafeedwatch_connector/api_user');
|
123 |
}
|
124 |
+
|
125 |
+
/**
|
126 |
+
* @return DataFeedWatch_Connector_Helper_Data
|
127 |
+
*/
|
128 |
+
public function helper()
|
129 |
+
{
|
130 |
+
return Mage::helper('datafeedwatch_connector');
|
131 |
+
}
|
132 |
}
|
app/code/community/DataFeedWatch/Connector/data/datafeedwatch_connector_setup/data-upgrade-0.2.40-0.2.50.php
CHANGED
@@ -30,9 +30,7 @@ $installer->addAttribute(Mage_Catalog_Model_Product::ENTITY, 'ignore_datafeedwat
|
|
30 |
));
|
31 |
$attribute = Mage::getModel('eav/entity_attribute')->loadByCode(Mage_Catalog_Model_Product::ENTITY, 'ignore_datafeedwatch');
|
32 |
|
33 |
-
|
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)
|
30 |
));
|
31 |
$attribute = Mage::getModel('eav/entity_attribute')->loadByCode(Mage_Catalog_Model_Product::ENTITY, 'ignore_datafeedwatch');
|
32 |
|
33 |
+
$attribute->setImportToDfw(0)
|
|
|
|
|
34 |
->setCanConfigureImport(0)
|
35 |
->setCanConfigureInheritance(0)
|
36 |
->setInheritance(DataFeedWatch_Connector_Model_System_Config_Source_Inheritance::CHILD_OPTION_ID)
|
app/code/community/DataFeedWatch/Connector/data/datafeedwatch_connector_setup/data-upgrade-0.3.0-0.3.1.php
ADDED
@@ -0,0 +1,26 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
$attribute = Mage::getResourceModel('catalog/product_attribute_collection')
|
3 |
+
->addVisibleFilter()
|
4 |
+
->addFieldToFilter('attribute_code', 'dfw_parent_ids')->getFirstItem();
|
5 |
+
|
6 |
+
$attribute->setImportToDfw(0)
|
7 |
+
->setCanConfigureImport(0)
|
8 |
+
->setCanConfigureInheritance(0)
|
9 |
+
->setInheritance(DataFeedWatch_Connector_Model_System_Config_Source_Inheritance::CHILD_OPTION_ID)
|
10 |
+
->save();
|
11 |
+
|
12 |
+
$currentStoreId = Mage::app()->getStore()->getId();
|
13 |
+
|
14 |
+
Mage::app()->setCurrentStore(Mage_Core_Model_App::ADMIN_STORE_ID);
|
15 |
+
|
16 |
+
$collection = Mage::getResourceModel('catalog/product_collection');
|
17 |
+
foreach($collection as $product) {
|
18 |
+
$parentIds = Mage::getModel('catalog/product_type_configurable')->getParentIdsByChild($product->getId());
|
19 |
+
if (!empty($parentIds)) {
|
20 |
+
// $product->setDfwParentIds(implode(',', $parentIds));
|
21 |
+
$product->setDfwParentIds(current($parentIds));
|
22 |
+
$product->getResource()->saveAttribute($product, 'dfw_parent_ids');
|
23 |
+
}
|
24 |
+
}
|
25 |
+
|
26 |
+
Mage::app()->setCurrentStore($currentStoreId);
|
app/code/community/DataFeedWatch/Connector/etc/config.xml
CHANGED
@@ -2,7 +2,7 @@
|
|
2 |
<config>
|
3 |
<modules>
|
4 |
<DataFeedWatch_Connector>
|
5 |
-
<version>0.3.
|
6 |
</DataFeedWatch_Connector>
|
7 |
</modules>
|
8 |
|
@@ -25,9 +25,6 @@
|
|
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>
|
@@ -42,22 +39,6 @@
|
|
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>
|
@@ -90,30 +71,38 @@
|
|
90 |
</datafeedwatch_connector_catalog_category_tree_move_after>
|
91 |
</observers>
|
92 |
</catalog_category_tree_move_after>
|
93 |
-
<
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
94 |
<observers>
|
95 |
-
<
|
96 |
<class>datafeedwatch_connector/observer</class>
|
97 |
-
<method>
|
98 |
-
</
|
99 |
</observers>
|
100 |
-
</
|
101 |
-
<
|
102 |
<observers>
|
103 |
-
<
|
104 |
<class>datafeedwatch_connector/observer</class>
|
105 |
-
<method>
|
106 |
-
</
|
107 |
</observers>
|
108 |
-
</
|
109 |
-
<
|
110 |
<observers>
|
111 |
-
<
|
112 |
<class>datafeedwatch_connector/observer</class>
|
113 |
-
<method>
|
114 |
-
</
|
115 |
</observers>
|
116 |
-
</
|
117 |
</events>
|
118 |
</global>
|
119 |
|
2 |
<config>
|
3 |
<modules>
|
4 |
<DataFeedWatch_Connector>
|
5 |
+
<version>0.3.1</version>
|
6 |
</DataFeedWatch_Connector>
|
7 |
</modules>
|
8 |
|
25 |
<datafeedwatch_connector_resource>
|
26 |
<class>DataFeedWatch_Connector_Model_Resource</class>
|
27 |
<entities>
|
|
|
|
|
|
|
28 |
<updated_products>
|
29 |
<table>datafeedwatch_updated_products</table>
|
30 |
</updated_products>
|
39 |
</datafeedwatch_connector_setup>
|
40 |
</resources>
|
41 |
<events>
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
42 |
<catalog_category_save_after>
|
43 |
<observers>
|
44 |
<datafeedwatch_connector_catalog_category_save_after>
|
71 |
</datafeedwatch_connector_catalog_category_tree_move_after>
|
72 |
</observers>
|
73 |
</catalog_category_tree_move_after>
|
74 |
+
<catalog_product_delete_before>
|
75 |
+
<observers>
|
76 |
+
<datafeedwatch_connector_product_delete_before>
|
77 |
+
<class>datafeedwatch_connector/observer</class>
|
78 |
+
<method>removeProductFromUpdatedTable</method>
|
79 |
+
</datafeedwatch_connector_product_delete_before>
|
80 |
+
</observers>
|
81 |
+
</catalog_product_delete_before>
|
82 |
+
<catalog_product_save_after>
|
83 |
<observers>
|
84 |
+
<datafeedwatch_connector_product_delete_before>
|
85 |
<class>datafeedwatch_connector/observer</class>
|
86 |
+
<method>changeChildProductUpdatedAt</method>
|
87 |
+
</datafeedwatch_connector_product_delete_before>
|
88 |
</observers>
|
89 |
+
</catalog_product_save_after>
|
90 |
+
<catalog_entity_attribute_save_before>
|
91 |
<observers>
|
92 |
+
<datafeedwatch_connector_attribute_save_before>
|
93 |
<class>datafeedwatch_connector/observer</class>
|
94 |
+
<method>checkAndUpdateAttributeInheritance</method>
|
95 |
+
</datafeedwatch_connector_attribute_save_before>
|
96 |
</observers>
|
97 |
+
</catalog_entity_attribute_save_before>
|
98 |
+
<catalog_entity_attribute_delete_before>
|
99 |
<observers>
|
100 |
+
<datafeedwatch_connector_attribute_delete_before>
|
101 |
<class>datafeedwatch_connector/observer</class>
|
102 |
+
<method>updateLastInheritanceUpdateDate</method>
|
103 |
+
</datafeedwatch_connector_attribute_delete_before>
|
104 |
</observers>
|
105 |
+
</catalog_entity_attribute_delete_before>
|
106 |
</events>
|
107 |
</global>
|
108 |
|
app/code/community/DataFeedWatch/Connector/sql/datafeedwatch_connector_setup/upgrade-0.2.40-0.2.50.php
CHANGED
@@ -3,30 +3,30 @@
|
|
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 |
-
|
13 |
-
|
14 |
-
|
15 |
-
|
16 |
-
|
17 |
-
|
18 |
-
|
19 |
-
|
20 |
-
|
21 |
-
|
22 |
$connection->createTable($updatedProductsTable);
|
23 |
|
24 |
$installer->endSetup();
|
25 |
}
|
26 |
|
27 |
-
|
28 |
/** @var string $table */
|
29 |
-
$table = $installer->getTable('
|
30 |
|
31 |
if ($connection->tableColumnExists($installer->getTable('api/user'), 'dfw_connect_hash')) {
|
32 |
$installer->startSetup();
|
@@ -38,47 +38,4 @@ $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 |
-
}
|
3 |
$installer = $this;
|
4 |
/** @var Magento_Db_Adapter_Pdo_Mysql $connection */
|
5 |
$connection = $installer->getConnection();
|
6 |
+
|
7 |
/** @var string $table */
|
8 |
$table = $installer->getTable('datafeedwatch_connector/updated_products');
|
9 |
|
10 |
if (!$installer->tableExists(($table))) {
|
11 |
$installer->startSetup();
|
12 |
$updatedProductsTable = $connection->newTable($table)
|
13 |
+
->addColumn('product_id', Varien_Db_Ddl_Table::TYPE_INTEGER, null, array(
|
14 |
+
'identity' => true,
|
15 |
+
'unsigned' => true,
|
16 |
+
'nullable' => false,
|
17 |
+
'primary' => true,
|
18 |
+
), 'Product ID')
|
19 |
+
->addColumn('updated_at', Varien_Db_Ddl_Table::TYPE_TIMESTAMP, null, array(
|
20 |
+
'nullable' => true,
|
21 |
+
), 'Updated At')
|
22 |
+
->setComment('Updated Products Table');
|
23 |
$connection->createTable($updatedProductsTable);
|
24 |
|
25 |
$installer->endSetup();
|
26 |
}
|
27 |
|
|
|
28 |
/** @var string $table */
|
29 |
+
$table = $installer->getTable('datafeedwatch_catalog_attribute_info');
|
30 |
|
31 |
if ($connection->tableColumnExists($installer->getTable('api/user'), 'dfw_connect_hash')) {
|
32 |
$installer->startSetup();
|
38 |
$installer->endSetup();
|
39 |
$installer->startSetup();
|
40 |
$connection->dropTable($installer->getTable('datafeedwatch_salesrule_info'));
|
41 |
+
$installer->endSetup();
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
app/code/community/DataFeedWatch/Connector/sql/datafeedwatch_connector_setup/upgrade-0.3.0-0.3.1.php
ADDED
@@ -0,0 +1,129 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
/* @var Mage_Core_Model_Resource_Setup $installer */
|
3 |
+
$installer = $this;
|
4 |
+
/** @var Magento_Db_Adapter_Pdo_Mysql|Varien_Db_Adapter_Pdo_Mysql $connection */
|
5 |
+
$connection = $installer->getConnection();
|
6 |
+
/** @var string $table */
|
7 |
+
$table = $installer->getTable('datafeedwatch_catalog_attribute_info');
|
8 |
+
/** @var string $catalogTable */
|
9 |
+
$catalogTable = $installer->getTable('catalog/eav_attribute');
|
10 |
+
|
11 |
+
if (!$connection->tableColumnExists($catalogTable, 'can_configure_inheritance')) {
|
12 |
+
$installer->startSetup();
|
13 |
+
$connection->addColumn($catalogTable,
|
14 |
+
'can_configure_inheritance',
|
15 |
+
array(
|
16 |
+
'unsigned' => true,
|
17 |
+
'nullable' => false,
|
18 |
+
'type' => Varien_Db_Ddl_Table::TYPE_SMALLINT,
|
19 |
+
'default' => 1,
|
20 |
+
'comment' => 'Can configure inheritance field? 1 - YES, 0 - NO',
|
21 |
+
)
|
22 |
+
);
|
23 |
+
$installer->endSetup();
|
24 |
+
}
|
25 |
+
if (!$connection->tableColumnExists($catalogTable, 'inheritance')) {
|
26 |
+
$installer->startSetup();
|
27 |
+
$connection->addColumn($catalogTable,
|
28 |
+
'inheritance',
|
29 |
+
array(
|
30 |
+
'unsigned' => true,
|
31 |
+
'nullable' => false,
|
32 |
+
'type' => Varien_Db_Ddl_Table::TYPE_SMALLINT,
|
33 |
+
'default' => 1,
|
34 |
+
'comment' => 'Inheritance: 1 - Child, 2 - Parent, 3 - Child Then Parent',
|
35 |
+
)
|
36 |
+
);
|
37 |
+
$installer->endSetup();
|
38 |
+
}
|
39 |
+
if (!$connection->tableColumnExists($catalogTable, 'can_configure_import')) {
|
40 |
+
$installer->startSetup();
|
41 |
+
$connection->addColumn($catalogTable,
|
42 |
+
'can_configure_import',
|
43 |
+
array(
|
44 |
+
'unsigned' => true,
|
45 |
+
'nullable' => false,
|
46 |
+
'type' => Varien_Db_Ddl_Table::TYPE_SMALLINT,
|
47 |
+
'default' => 1,
|
48 |
+
'comment' => 'Can configure import field? 1 - YES, 0 - NO',
|
49 |
+
)
|
50 |
+
);
|
51 |
+
$installer->endSetup();
|
52 |
+
}
|
53 |
+
if (!$connection->tableColumnExists($catalogTable, 'import_to_dfw')) {
|
54 |
+
$installer->startSetup();
|
55 |
+
$connection->addColumn($catalogTable,
|
56 |
+
'import_to_dfw',
|
57 |
+
array(
|
58 |
+
'unsigned' => true,
|
59 |
+
'nullable' => false,
|
60 |
+
'type' => Varien_Db_Ddl_Table::TYPE_SMALLINT,
|
61 |
+
'default' => 1,
|
62 |
+
'comment' => 'Should import attribute? 1 - YES, 0 - NO',
|
63 |
+
)
|
64 |
+
);
|
65 |
+
$installer->endSetup();
|
66 |
+
}
|
67 |
+
|
68 |
+
if ($installer->tableExists(($table))) {
|
69 |
+
$installer->startSetup();
|
70 |
+
$dataToImport = $connection->select()->from($table);
|
71 |
+
$dataToImport = $connection->query($dataToImport);
|
72 |
+
$dataToImport = $dataToImport->fetchAll();
|
73 |
+
|
74 |
+
if (is_array($dataToImport)) {
|
75 |
+
foreach ($dataToImport as $oldData) {
|
76 |
+
$connection->update($catalogTable, array(
|
77 |
+
'can_configure_inheritance' => $oldData['can_configure_inheritance'],
|
78 |
+
'inheritance' => $oldData['inheritance'],
|
79 |
+
'can_configure_import' => $oldData['can_configure_import'],
|
80 |
+
'import_to_dfw' => $oldData['import_to_dfw'],
|
81 |
+
), sprintf('attribute_id = %s', $oldData['catalog_attribute_id']));
|
82 |
+
}
|
83 |
+
}
|
84 |
+
$connection->dropTable($table);
|
85 |
+
$installer->endSetup();
|
86 |
+
}
|
87 |
+
|
88 |
+
/** @var string $table */
|
89 |
+
$table = $installer->getTable('datafeedwatch_connector/updated_products');
|
90 |
+
if ($connection->tableColumnExists($table, 'product_id')) {
|
91 |
+
$connection->changeColumn($table, 'product_id', 'dfw_prod_id', array(
|
92 |
+
'identity' => true,
|
93 |
+
'unsigned' => true,
|
94 |
+
'nullable' => false,
|
95 |
+
'primary' => true,
|
96 |
+
'type' => Varien_Db_Ddl_Table::TYPE_INTEGER,
|
97 |
+
));
|
98 |
+
}
|
99 |
+
|
100 |
+
/** @var Mage_Catalog_Model_Resource_Setup $attributeInstaller */
|
101 |
+
$attributeInstaller = Mage::getResourceModel('catalog/setup','catalog_setup');
|
102 |
+
$attributeId = $attributeInstaller->getAttribute(Mage_Catalog_Model_Product::ENTITY, 'dfw_parent_ids', 'attribute_id');
|
103 |
+
if (empty($attributeId)) {
|
104 |
+
$attributeInstaller->addAttribute(
|
105 |
+
Mage_Catalog_Model_Product::ENTITY,
|
106 |
+
'dfw_parent_ids',
|
107 |
+
array(
|
108 |
+
'type' => 'varchar',
|
109 |
+
'backend' => '',
|
110 |
+
'frontend' => '',
|
111 |
+
'input' => 'text',
|
112 |
+
'class' => '',
|
113 |
+
'global' => Mage_Catalog_Model_Resource_Eav_Attribute::SCOPE_STORE,
|
114 |
+
'visible' => true,
|
115 |
+
'required' => false,
|
116 |
+
'user_defined' => true,
|
117 |
+
'default' => '',
|
118 |
+
'searchable' => false,
|
119 |
+
'filterable' => false,
|
120 |
+
'comparable' => false,
|
121 |
+
'visible_on_front' => false,
|
122 |
+
'unique' => false,
|
123 |
+
'group' => 'General',
|
124 |
+
'can_configure_inheritance' => 0,
|
125 |
+
'inheritance' => DataFeedWatch_Connector_Model_System_Config_Source_Inheritance::CHILD_OPTION_ID,
|
126 |
+
'can_configure_import' => 0,
|
127 |
+
'import_to_dfw' => 0,
|
128 |
+
));
|
129 |
+
}
|
app/design/adminhtml/default/default/template/datafeedwatch/connector/grid/items/row.phtml
CHANGED
@@ -6,7 +6,7 @@
|
|
6 |
|
7 |
$attribute = $this->getAttributeItem();
|
8 |
$inheritanceModel = Mage::getModel('datafeedwatch_connector/system_config_source_inheritance');
|
9 |
-
$inheritance = (int)$attribute->
|
10 |
$import = (int)$attribute->getImportToDfw();
|
11 |
$inheritanceStatus = $attribute->getCanConfigureInheritance() === '0' ? ' disabled ' : '';
|
12 |
?>
|
6 |
|
7 |
$attribute = $this->getAttributeItem();
|
8 |
$inheritanceModel = Mage::getModel('datafeedwatch_connector/system_config_source_inheritance');
|
9 |
+
$inheritance = (int)$attribute->getInheritance();
|
10 |
$import = (int)$attribute->getImportToDfw();
|
11 |
$inheritanceStatus = $attribute->getCanConfigureInheritance() === '0' ? ' disabled ' : '';
|
12 |
?>
|
package.xml
CHANGED
@@ -1,18 +1,18 @@
|
|
1 |
<?xml version="1.0"?>
|
2 |
<package>
|
3 |
<name>DataFeedWatch_Connector</name>
|
4 |
-
<version>0.3.
|
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.
|
12 |
<authors><author><name>DataFeedWatch</name><user>WordWatch</user><email>support@datafeedwatch.com</email></author></authors>
|
13 |
-
<date>2016-
|
14 |
-
<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="
|
16 |
<compatible/>
|
17 |
<dependencies><required><php><min>5.3.0</min><max>7.0.0</max></php></required></dependencies>
|
18 |
</package>
|
1 |
<?xml version="1.0"?>
|
2 |
<package>
|
3 |
<name>DataFeedWatch_Connector</name>
|
4 |
+
<version>0.3.1</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.1</notes>
|
12 |
<authors><author><name>DataFeedWatch</name><user>WordWatch</user><email>support@datafeedwatch.com</email></author></authors>
|
13 |
+
<date>2016-06-09</date>
|
14 |
+
<time>09:34:17</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="9ae5979b8e1ce7eafa6b2e7e429b8247"/></dir><file name="Grid.php" hash="3c4a5eefc0ae7e9638c119433bb93f0f"/></dir></dir></dir></dir><dir name="Helper"><file name="Data.php" hash="4d50db3e47a6107815e888e74a232bd3"/><file name="Registry.php" hash="514c4be14a4203dd568a2b77df83900b"/></dir><dir name="Model"><dir name="Api"><file name="User.php" hash="2d7fc0477d68f2e9f4febf0e43879a69"/></dir><file name="Api.php" hash="f07b325d90defc0d30450fbb0bbfd75b"/><file name="Cron.php" hash="2c85e3d5809b25fe6dd14a80991197d1"/><file name="Observer.php" hash="6cf196c18ad428cef48a9b46845d0a6d"/><file name="Product.php" hash="b35d3506ca6cc2025a5013e9c2f3cad4"/><dir name="Resource"><dir name="Product"><dir name="Collection"><file name="Db.php" hash="2a417751e524398f90b99cc7556ff182"/></dir><file name="Collection.php" hash="ce250ddc545aba36d9f2afd2ae319da2"/></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="f3d364f4d0b3aa64478bdd783f807b95"/></dir></dir><dir name="data"><dir name="datafeedwatch_connector_setup"><file name="data-upgrade-0.2.40-0.2.50.php" hash="f999c30c7f3031e1ead8f83a966c1bb7"/><file name="data-upgrade-0.3.0-0.3.1.php" hash="7a242695a5c78801d84d81b1da99f18c"/></dir></dir><dir name="etc"><file name="adminhtml.xml" hash="0054cf5d1bd7b9bc001c84b5fc8f72c6"/><file name="api.xml" hash="780b354b3fe3e807d16602cbe0a27c5c"/><file name="config.xml" hash="8f691eaabd193fa72130a9ee913e9fa0"/><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="21f170857128d15b708386635715fae9"/><file name="upgrade-0.3.0-0.3.1.php" hash="1799d8fd2cf18b77b4736d51b99d023d"/></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="ada54a40e55899c3262f30c3de55d5c6"/></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>
|