Version Notes
Channable Connect
Download this release
Release Info
Developer | Magmodules |
Extension | Magmodules_Channable |
Version | 1.5.1 |
Comparing to | |
See all releases |
Code changes from version 1.5.0 to 1.5.1
- app/code/community/Magmodules/Channable/Helper/Data.php +65 -19
- app/code/community/Magmodules/Channable/Model/Channable.php +243 -246
- app/code/community/Magmodules/Channable/Model/Common.php +44 -20
- app/code/community/Magmodules/Channable/controllers/FeedController.php +2 -9
- app/code/community/Magmodules/Channable/etc/config.xml +1 -1
- package.xml +4 -4
app/code/community/Magmodules/Channable/Helper/Data.php
CHANGED
@@ -40,9 +40,10 @@ class Magmodules_Channable_Helper_Data extends Mage_Core_Helper_Abstract
|
|
40 |
* @param $product
|
41 |
* @param $config
|
42 |
* @param $parent
|
|
|
43 |
* @return array|bool
|
44 |
*/
|
45 |
-
public function getProductDataRow($product, $config, $parent)
|
46 |
{
|
47 |
$fields = $config['field'];
|
48 |
$data = array();
|
@@ -56,7 +57,7 @@ class Magmodules_Channable_Helper_Data extends Mage_Core_Helper_Abstract
|
|
56 |
}
|
57 |
|
58 |
foreach ($fields as $key => $field) {
|
59 |
-
$rows = $this->getAttributeValue($key, $product, $config, $field['action'], $parent);
|
60 |
if (is_array($rows)) {
|
61 |
$data = array_merge($data, $rows);
|
62 |
}
|
@@ -117,7 +118,7 @@ class Magmodules_Channable_Helper_Data extends Mage_Core_Helper_Abstract
|
|
117 |
}
|
118 |
|
119 |
if ($manageStock) {
|
120 |
-
if (!$product['
|
121 |
return false;
|
122 |
}
|
123 |
}
|
@@ -141,7 +142,7 @@ class Magmodules_Channable_Helper_Data extends Mage_Core_Helper_Abstract
|
|
141 |
* @param $parent
|
142 |
* @return bool
|
143 |
*/
|
144 |
-
public function getAttributeValue($field, $product, $config, $actions = '', $parent)
|
145 |
{
|
146 |
$data = $config['field'][$field];
|
147 |
$productData = $product;
|
@@ -154,7 +155,7 @@ class Magmodules_Channable_Helper_Data extends Mage_Core_Helper_Abstract
|
|
154 |
|
155 |
switch ($field) {
|
156 |
case 'product_url':
|
157 |
-
$value = $this->getProductUrl($product, $config, $parent);
|
158 |
break;
|
159 |
case 'image_link':
|
160 |
$value = $this->getProductImage($productData, $config);
|
@@ -174,6 +175,9 @@ class Magmodules_Channable_Helper_Data extends Mage_Core_Helper_Abstract
|
|
174 |
case 'bundle':
|
175 |
$value = $this->getProductBundle($productData);
|
176 |
break;
|
|
|
|
|
|
|
177 |
case 'parent_id':
|
178 |
$value = $this->getProductData($parent, $data);
|
179 |
break;
|
@@ -227,13 +231,33 @@ class Magmodules_Channable_Helper_Data extends Mage_Core_Helper_Abstract
|
|
227 |
return false;
|
228 |
}
|
229 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
230 |
/**
|
231 |
* @param $product
|
232 |
* @param $config
|
233 |
* @param $parent
|
234 |
* @return string
|
235 |
*/
|
236 |
-
public function getProductUrl($product, $config, $parent)
|
237 |
{
|
238 |
$url = '';
|
239 |
if (!empty($parent)) {
|
@@ -264,16 +288,12 @@ class Magmodules_Channable_Helper_Data extends Mage_Core_Helper_Abstract
|
|
264 |
}
|
265 |
}
|
266 |
|
267 |
-
if (!empty($parent) && !empty($
|
268 |
-
if ($parent->
|
269 |
-
$productAttributeOptions = $parent->
|
270 |
$urlExtra = '';
|
271 |
foreach ($productAttributeOptions as $productAttribute) {
|
272 |
-
if ($id = Mage::getResourceModel('catalog/product')->getAttributeRawValue(
|
273 |
-
$product->getId(),
|
274 |
-
$productAttribute['attribute_code'], $config['store_id']
|
275 |
-
)
|
276 |
-
) {
|
277 |
$urlExtra .= $productAttribute['attribute_id'] . '=' . $id . '&';
|
278 |
}
|
279 |
}
|
@@ -287,6 +307,21 @@ class Magmodules_Channable_Helper_Data extends Mage_Core_Helper_Abstract
|
|
287 |
return $url;
|
288 |
}
|
289 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
290 |
/**
|
291 |
* @param $product
|
292 |
* @param $config
|
@@ -297,7 +332,10 @@ class Magmodules_Channable_Helper_Data extends Mage_Core_Helper_Abstract
|
|
297 |
$imageData = array();
|
298 |
if (!empty($config['image_resize']) && !empty($config['image_size'])) {
|
299 |
$imageFile = $product->getData($config['image_source']);
|
300 |
-
$imageModel = Mage::getModel('catalog/product_image')
|
|
|
|
|
|
|
301 |
if (!$imageModel->isCached()) {
|
302 |
$imageModel->resize()->saveFile();
|
303 |
}
|
@@ -346,7 +384,10 @@ class Magmodules_Channable_Helper_Data extends Mage_Core_Helper_Abstract
|
|
346 |
|
347 |
if (!empty($config['images'])) {
|
348 |
$imageData['image_link'] = $image;
|
349 |
-
$container = new Varien_Object(
|
|
|
|
|
|
|
350 |
$imgProduct = new Varien_Object(array('id' => $product->getId(), 'store_id' => $config['store_id']));
|
351 |
$gallery = Mage::getResourceModel('catalog/product_attribute_backend_media')->loadGallery(
|
352 |
$imgProduct,
|
@@ -873,7 +914,11 @@ class Magmodules_Channable_Helper_Data extends Mage_Core_Helper_Abstract
|
|
873 |
|
874 |
// CHECK IF NEW ATTRIBUTES ARE AVAILABLE
|
875 |
try {
|
876 |
-
Mage::getModel('catalog/category')
|
|
|
|
|
|
|
|
|
877 |
} catch (Exception $e) {
|
878 |
}
|
879 |
|
@@ -978,7 +1023,8 @@ class Magmodules_Channable_Helper_Data extends Mage_Core_Helper_Abstract
|
|
978 |
{
|
979 |
if (!empty($config['conf_enabled'])) {
|
980 |
if (($product['type_id'] == 'simple')) {
|
981 |
-
$configIds = Mage::getModel('catalog/product_type_configurable')
|
|
|
982 |
$groupIds = Mage::getResourceSingleton('catalog/product_link')->getParentIdsByChild(
|
983 |
$product->getId(),
|
984 |
Mage_Catalog_Model_Product_Link::LINK_TYPE_GROUPED
|
@@ -1179,4 +1225,4 @@ class Magmodules_Channable_Helper_Data extends Mage_Core_Helper_Abstract
|
|
1179 |
|
1180 |
return $suffix;
|
1181 |
}
|
1182 |
-
}
|
40 |
* @param $product
|
41 |
* @param $config
|
42 |
* @param $parent
|
43 |
+
* @param $parentAttributes
|
44 |
* @return array|bool
|
45 |
*/
|
46 |
+
public function getProductDataRow($product, $config, $parent, $parentAttributes)
|
47 |
{
|
48 |
$fields = $config['field'];
|
49 |
$data = array();
|
57 |
}
|
58 |
|
59 |
foreach ($fields as $key => $field) {
|
60 |
+
$rows = $this->getAttributeValue($key, $product, $config, $field['action'], $parent, $parentAttributes);
|
61 |
if (is_array($rows)) {
|
62 |
$data = array_merge($data, $rows);
|
63 |
}
|
118 |
}
|
119 |
|
120 |
if ($manageStock) {
|
121 |
+
if (!$product['is_in_stock']) {
|
122 |
return false;
|
123 |
}
|
124 |
}
|
142 |
* @param $parent
|
143 |
* @return bool
|
144 |
*/
|
145 |
+
public function getAttributeValue($field, $product, $config, $actions = '', $parent, $parentAttributes)
|
146 |
{
|
147 |
$data = $config['field'][$field];
|
148 |
$productData = $product;
|
155 |
|
156 |
switch ($field) {
|
157 |
case 'product_url':
|
158 |
+
$value = $this->getProductUrl($product, $config, $parent, $parentAttributes);
|
159 |
break;
|
160 |
case 'image_link':
|
161 |
$value = $this->getProductImage($productData, $config);
|
175 |
case 'bundle':
|
176 |
$value = $this->getProductBundle($productData);
|
177 |
break;
|
178 |
+
case 'is_in_stock':
|
179 |
+
$value = $this->getIsInStock($productData, $config);
|
180 |
+
break;
|
181 |
case 'parent_id':
|
182 |
$value = $this->getProductData($parent, $data);
|
183 |
break;
|
231 |
return false;
|
232 |
}
|
233 |
|
234 |
+
/**
|
235 |
+
* @param $product
|
236 |
+
* @param $config
|
237 |
+
* @return string
|
238 |
+
*/
|
239 |
+
public function getIsInStock($product, $config)
|
240 |
+
{
|
241 |
+
if ($product->getUseConfigManageStock()) {
|
242 |
+
$manageStock = $config['stock_manage'];
|
243 |
+
} else {
|
244 |
+
$manageStock = $product->getManageStock();
|
245 |
+
}
|
246 |
+
|
247 |
+
if ($manageStock) {
|
248 |
+
return $product->getIsInStock();
|
249 |
+
} else {
|
250 |
+
return "1";
|
251 |
+
}
|
252 |
+
}
|
253 |
+
|
254 |
/**
|
255 |
* @param $product
|
256 |
* @param $config
|
257 |
* @param $parent
|
258 |
* @return string
|
259 |
*/
|
260 |
+
public function getProductUrl($product, $config, $parent, $parentAttributes)
|
261 |
{
|
262 |
$url = '';
|
263 |
if (!empty($parent)) {
|
288 |
}
|
289 |
}
|
290 |
|
291 |
+
if (!empty($parent) && !empty($url)) {
|
292 |
+
if (!empty($parentAttributes[$parent->getEntityId()])) {
|
293 |
+
$productAttributeOptions = $parentAttributes[$parent->getEntityId()];
|
294 |
$urlExtra = '';
|
295 |
foreach ($productAttributeOptions as $productAttribute) {
|
296 |
+
if ($id = Mage::getResourceModel('catalog/product')->getAttributeRawValue($product->getId(), $productAttribute['attribute_code'], $config['store_id'])) {
|
|
|
|
|
|
|
|
|
297 |
$urlExtra .= $productAttribute['attribute_id'] . '=' . $id . '&';
|
298 |
}
|
299 |
}
|
307 |
return $url;
|
308 |
}
|
309 |
|
310 |
+
public function getConfigurableAttributesAsArray($parents, $config)
|
311 |
+
{
|
312 |
+
$configurableAttributes = array();
|
313 |
+
if (!empty($config['conf_switch_urls'])) {
|
314 |
+
foreach ($parents as $parent) {
|
315 |
+
if ($parent->getTypeId() == 'configurable') {
|
316 |
+
$configurableAttributes[$parent->getEntityId()] = $parent->getTypeInstance(true)
|
317 |
+
->getConfigurableAttributesAsArray($parent);
|
318 |
+
}
|
319 |
+
}
|
320 |
+
}
|
321 |
+
|
322 |
+
return $configurableAttributes;
|
323 |
+
}
|
324 |
+
|
325 |
/**
|
326 |
* @param $product
|
327 |
* @param $config
|
332 |
$imageData = array();
|
333 |
if (!empty($config['image_resize']) && !empty($config['image_size'])) {
|
334 |
$imageFile = $product->getData($config['image_source']);
|
335 |
+
$imageModel = Mage::getModel('catalog/product_image')
|
336 |
+
->setSize($config['image_size'])
|
337 |
+
->setDestinationSubdir($config['image_source'])
|
338 |
+
->setBaseFile($imageFile);
|
339 |
if (!$imageModel->isCached()) {
|
340 |
$imageModel->resize()->saveFile();
|
341 |
}
|
384 |
|
385 |
if (!empty($config['images'])) {
|
386 |
$imageData['image_link'] = $image;
|
387 |
+
$container = new Varien_Object(
|
388 |
+
array(
|
389 |
+
'attribute' => new Varien_Object(array('id' => $config['media_gallery_id'])))
|
390 |
+
);
|
391 |
$imgProduct = new Varien_Object(array('id' => $product->getId(), 'store_id' => $config['store_id']));
|
392 |
$gallery = Mage::getResourceModel('catalog/product_attribute_backend_media')->loadGallery(
|
393 |
$imgProduct,
|
914 |
|
915 |
// CHECK IF NEW ATTRIBUTES ARE AVAILABLE
|
916 |
try {
|
917 |
+
Mage::getModel('catalog/category')
|
918 |
+
->setStoreId($storeId)
|
919 |
+
->getCollection()
|
920 |
+
->addAttributeToSelect($attributes)
|
921 |
+
->getFirstItem();
|
922 |
} catch (Exception $e) {
|
923 |
}
|
924 |
|
1023 |
{
|
1024 |
if (!empty($config['conf_enabled'])) {
|
1025 |
if (($product['type_id'] == 'simple')) {
|
1026 |
+
$configIds = Mage::getModel('catalog/product_type_configurable')
|
1027 |
+
->getParentIdsByChild($product->getId());
|
1028 |
$groupIds = Mage::getResourceSingleton('catalog/product_link')->getParentIdsByChild(
|
1029 |
$product->getId(),
|
1030 |
Mage_Catalog_Model_Product_Link::LINK_TYPE_GROUPED
|
1225 |
|
1226 |
return $suffix;
|
1227 |
}
|
1228 |
+
}
|
app/code/community/Magmodules/Channable/Model/Channable.php
CHANGED
@@ -25,252 +25,20 @@ class Magmodules_Channable_Model_Channable extends Magmodules_Channable_Model_Co
|
|
25 |
* @param $timeStart
|
26 |
* @return array
|
27 |
*/
|
28 |
-
public function generateFeed($storeId, $limit = '', $page = 1
|
29 |
{
|
30 |
$this->setMemoryLimit($storeId);
|
31 |
$config = $this->getFeedConfig($storeId);
|
32 |
$this->cleanItemUpdates($storeId, $page);
|
33 |
$products = $this->getProducts($config, $limit, $page);
|
34 |
-
$
|
35 |
-
|
|
|
|
|
36 |
return $feed;
|
37 |
}
|
38 |
}
|
39 |
|
40 |
-
/**
|
41 |
-
* @param $storeId
|
42 |
-
*/
|
43 |
-
protected function setMemoryLimit($storeId)
|
44 |
-
{
|
45 |
-
if (Mage::getStoreConfig('channable/server/overwrite', $storeId)) {
|
46 |
-
if ($memory_limit = Mage::getStoreConfig('channable/server/memory_limit', $storeId)) {
|
47 |
-
ini_set('memory_limit', $memory_limit);
|
48 |
-
}
|
49 |
-
|
50 |
-
if ($max_execution_time = Mage::getStoreConfig('channable/server/max_execution_time', $storeId)) {
|
51 |
-
ini_set('max_execution_time', $max_execution_time);
|
52 |
-
}
|
53 |
-
}
|
54 |
-
}
|
55 |
-
|
56 |
-
/**
|
57 |
-
* @param $storeId
|
58 |
-
* @return array
|
59 |
-
*/
|
60 |
-
public function getFeedConfig($storeId)
|
61 |
-
{
|
62 |
-
|
63 |
-
$config = array();
|
64 |
-
$feed = Mage::helper('channable');
|
65 |
-
$websiteId = Mage::app()->getStore($storeId)->getWebsiteId();
|
66 |
-
|
67 |
-
// DEFAULTS
|
68 |
-
$config['store_id'] = $storeId;
|
69 |
-
$config['website_name'] = $feed->cleanData(
|
70 |
-
Mage::getModel('core/website')->load($websiteId)->getName(),
|
71 |
-
'striptags'
|
72 |
-
);
|
73 |
-
$config['website_url'] = Mage::app()->getStore($storeId)->getBaseUrl(Mage_Core_Model_Store::URL_TYPE_LINK);
|
74 |
-
$config['media_url'] = Mage::app()->getStore($storeId)->getBaseUrl(Mage_Core_Model_Store::URL_TYPE_MEDIA);
|
75 |
-
$config['media_image_url'] = $config['media_url'] . 'catalog' . DS . 'product';
|
76 |
-
$config['media_attributes'] = $feed->getMediaAttributes();
|
77 |
-
$config['limit'] = Mage::getStoreConfig('channable/connect/max_products', $storeId);
|
78 |
-
$config['version'] = (string)Mage::getConfig()->getNode()->modules->Magmodules_Channable->version;
|
79 |
-
$config['media_gallery_id'] = Mage::getResourceModel('eav/entity_attribute')->getIdByCode(
|
80 |
-
'catalog_product',
|
81 |
-
'media_gallery'
|
82 |
-
);
|
83 |
-
$config['filters'] = @unserialize(Mage::getStoreConfig('channable/filter/advanced', $storeId));
|
84 |
-
$config['product_url_suffix'] = $feed->getProductUrlSuffix($storeId);
|
85 |
-
$config['filter_enabled'] = Mage::getStoreConfig('channable/filter/category_enabled', $storeId);
|
86 |
-
$config['filter_cat'] = Mage::getStoreConfig('channable/filter/categories', $storeId);
|
87 |
-
$config['filter_type'] = Mage::getStoreConfig('channable/filter/category_type', $storeId);
|
88 |
-
$config['filter_status'] = Mage::getStoreConfig('channable/filter/visibility_inc', $storeId);
|
89 |
-
$config['hide_no_stock'] = Mage::getStoreConfig('channable/filter/stock', $storeId);
|
90 |
-
$config['conf_enabled'] = Mage::getStoreConfig('channable/data/conf_enabled', $storeId);
|
91 |
-
$config['conf_fields'] = Mage::getStoreConfig('channable/data/conf_fields', $storeId);
|
92 |
-
$config['parent_att'] = $this->getParentAttributeSelection($config['conf_fields']);
|
93 |
-
$config['conf_switch_urls'] = Mage::getStoreConfig('channable/data/conf_switch_urls', $storeId);
|
94 |
-
$config['stock_manage'] = Mage::getStoreConfig('cataloginventory/item_options/manage_stock');
|
95 |
-
$config['use_qty_increments'] = Mage::getStoreConfig('cataloginventory/item_options/enable_qty_increments');
|
96 |
-
$config['qty_increments'] = Mage::getStoreConfig('cataloginventory/item_options/qty_increments');
|
97 |
-
$config['delivery'] = Mage::getStoreConfig('channable/data/delivery', $storeId);
|
98 |
-
$config['delivery_be'] = Mage::getStoreConfig('channable/data/delivery_be', $storeId);
|
99 |
-
$config['delivery_att'] = Mage::getStoreConfig('channable/data/delivery_att', $storeId);
|
100 |
-
$config['delivery_att_be'] = Mage::getStoreConfig('channable/data/delivery_att_be', $storeId);
|
101 |
-
$config['delivery_in'] = Mage::getStoreConfig('channable/data/delivery_in', $storeId);
|
102 |
-
$config['delivery_in_be'] = Mage::getStoreConfig('channable/data/delivery_in_be', $storeId);
|
103 |
-
$config['delivery_out'] = Mage::getStoreConfig('channable/data/delivery_out', $storeId);
|
104 |
-
$config['delivery_out_be'] = Mage::getStoreConfig('channable/data/delivery_out_be', $storeId);
|
105 |
-
$config['images'] = Mage::getStoreConfig('channable/data/images', $storeId);
|
106 |
-
$config['default_image'] = Mage::getStoreConfig('channable/data/default_image', $storeId);
|
107 |
-
$config['skip_validation'] = false;
|
108 |
-
$config['weight'] = Mage::getStoreConfig('channable/data/weight', $storeId);
|
109 |
-
$config['weight_units'] = Mage::getStoreConfig('channable/data/weight_units', $storeId);
|
110 |
-
$config['price_scope'] = Mage::getStoreConfig('catalog/price/scope');
|
111 |
-
$config['price_add_tax'] = Mage::getStoreConfig('channable/data/add_tax', $storeId);
|
112 |
-
$config['price_add_tax_perc'] = Mage::getStoreConfig('channable/data/tax_percentage', $storeId);
|
113 |
-
$config['force_tax'] = Mage::getStoreConfig('channable/data/force_tax', $storeId);
|
114 |
-
$config['currency'] = Mage::app()->getStore($storeId)->getCurrentCurrencyCode();
|
115 |
-
$config['base_currency_code'] = Mage::app()->getStore($storeId)->getBaseCurrencyCode();
|
116 |
-
$config['markup'] = Mage::helper('channable')->getPriceMarkup($config);
|
117 |
-
$config['use_tax'] = Mage::helper('channable')->getTaxUsage($config);
|
118 |
-
|
119 |
-
if (Mage::helper('core')->isModuleEnabled('Magmodules_Channableapi')) {
|
120 |
-
$config['item_updates'] = Mage::getStoreConfig('channable_api/item/enabled', $storeId);
|
121 |
-
} else {
|
122 |
-
$config['item_updates'] = '';
|
123 |
-
}
|
124 |
-
|
125 |
-
$config['shipping_prices'] = @unserialize(Mage::getStoreConfig('channable/advanced/shipping_price', $storeId));
|
126 |
-
$config['shipping_method'] = Mage::getStoreConfig('channable/advanced/shipping_method', $storeId);
|
127 |
-
$config['field'] = $this->getFeedAttributes($config, $storeId);
|
128 |
-
$config['category_exclude'] = 'channable_exclude';
|
129 |
-
$config['category_data'] = $feed->getCategoryData($config, $storeId);
|
130 |
-
|
131 |
-
return $config;
|
132 |
-
}
|
133 |
-
|
134 |
-
/**
|
135 |
-
* @param string $config
|
136 |
-
* @param int $storeId
|
137 |
-
* @return mixed
|
138 |
-
*/
|
139 |
-
public function getFeedAttributes($config = '', $storeId = 0)
|
140 |
-
{
|
141 |
-
$attributes = array();
|
142 |
-
$attributes['id'] = array(
|
143 |
-
'label' => 'id',
|
144 |
-
'source' => 'entity_id'
|
145 |
-
);
|
146 |
-
$attributes['name'] = array(
|
147 |
-
'label' => 'name',
|
148 |
-
'source' => Mage::getStoreConfig('channable/data/name', $storeId)
|
149 |
-
);
|
150 |
-
$attributes['description'] = array(
|
151 |
-
'label' => 'description',
|
152 |
-
'source' => Mage::getStoreConfig('channable/data/description', $storeId)
|
153 |
-
);
|
154 |
-
$attributes['product_url'] = array(
|
155 |
-
'label' => 'url',
|
156 |
-
'source' => ''
|
157 |
-
);
|
158 |
-
$attributes['image_link'] = array(
|
159 |
-
'label' => 'image',
|
160 |
-
'source' => Mage::getStoreConfig('channable/data/default_image', $storeId)
|
161 |
-
);
|
162 |
-
$attributes['price'] = array(
|
163 |
-
'label' => 'price',
|
164 |
-
'source' => ''
|
165 |
-
);
|
166 |
-
$attributes['sku'] = array(
|
167 |
-
'label' => 'sku',
|
168 |
-
'source' => Mage::getStoreConfig('channable/data/sku', $storeId)
|
169 |
-
);
|
170 |
-
$attributes['brand'] = array(
|
171 |
-
'label' => 'brand',
|
172 |
-
'source' => Mage::getStoreConfig('channable/data/brand', $storeId)
|
173 |
-
);
|
174 |
-
$attributes['size'] = array(
|
175 |
-
'label' => 'size',
|
176 |
-
'source' => Mage::getStoreConfig('channable/data/size', $storeId)
|
177 |
-
);
|
178 |
-
$attributes['color'] = array(
|
179 |
-
'label' => 'color',
|
180 |
-
'source' => Mage::getStoreConfig('channable/data/color', $storeId)
|
181 |
-
);
|
182 |
-
$attributes['material'] = array(
|
183 |
-
'label' => 'material',
|
184 |
-
'source' => Mage::getStoreConfig('channable/data/material', $storeId)
|
185 |
-
);
|
186 |
-
$attributes['gender'] = array(
|
187 |
-
'label' => 'gender',
|
188 |
-
'source' => Mage::getStoreConfig('channable/data/gender', $storeId)
|
189 |
-
);
|
190 |
-
$attributes['ean'] = array(
|
191 |
-
'label' => 'ean',
|
192 |
-
'source' => Mage::getStoreConfig('channable/data/ean', $storeId)
|
193 |
-
);
|
194 |
-
$attributes['categories'] = array(
|
195 |
-
'label' => 'categories',
|
196 |
-
'source' => '',
|
197 |
-
'parent' => 1
|
198 |
-
);
|
199 |
-
$attributes['type'] = array(
|
200 |
-
'label' => 'type',
|
201 |
-
'source' => 'type_id'
|
202 |
-
);
|
203 |
-
$attributes['status'] = array(
|
204 |
-
'label' => 'status',
|
205 |
-
'source' => 'status',
|
206 |
-
'parent' => 1
|
207 |
-
);
|
208 |
-
$attributes['visibility'] = array(
|
209 |
-
'label' => 'visibility',
|
210 |
-
'source' => 'visibility'
|
211 |
-
);
|
212 |
-
$attributes['parent_id'] = array(
|
213 |
-
'label' => 'item_group_id',
|
214 |
-
'source' => 'entity_id',
|
215 |
-
'parent' => 1
|
216 |
-
);
|
217 |
-
$attributes['weight'] = array(
|
218 |
-
'label' => 'weight',
|
219 |
-
'source' => ''
|
220 |
-
);
|
221 |
-
$attributes['is_in_stock'] = array(
|
222 |
-
'label' => 'is_in_stock',
|
223 |
-
'source' => 'is_in_stock'
|
224 |
-
);
|
225 |
-
|
226 |
-
if (Mage::getStoreConfig('channable/data/stock', $storeId)) {
|
227 |
-
$attributes['stock'] = array(
|
228 |
-
'label' => 'qty',
|
229 |
-
'source' => 'qty',
|
230 |
-
'action' => 'round'
|
231 |
-
);
|
232 |
-
}
|
233 |
-
|
234 |
-
if (Mage::getStoreConfig('channable/data/delivery', $storeId) == 'attribute') {
|
235 |
-
$attributes['delivery'] = array(
|
236 |
-
'label' => 'delivery',
|
237 |
-
'source' => Mage::getStoreConfig('channable/data/delivery_att', $storeId)
|
238 |
-
);
|
239 |
-
}
|
240 |
-
|
241 |
-
if (Mage::getStoreConfig('channable/data/delivery_be', $storeId) == 'attribute') {
|
242 |
-
$attributes['delivery_be'] = array(
|
243 |
-
'label' => 'delivery_be',
|
244 |
-
'source' => Mage::getStoreConfig('channable/data/delivery_att_be', $storeId)
|
245 |
-
);
|
246 |
-
}
|
247 |
-
|
248 |
-
if ($extraFields = @unserialize(Mage::getStoreConfig('channable/advanced/extra', $storeId))) {
|
249 |
-
foreach ($extraFields as $extraField) {
|
250 |
-
$attributes[$extraField['attribute']] = array(
|
251 |
-
'label' => $extraField['label'],
|
252 |
-
'source' => $extraField['attribute'],
|
253 |
-
'action' => ''
|
254 |
-
);
|
255 |
-
}
|
256 |
-
}
|
257 |
-
|
258 |
-
return Mage::helper('channable')->addAttributeData($attributes, $config);
|
259 |
-
}
|
260 |
-
|
261 |
-
/**
|
262 |
-
* @param $storeId
|
263 |
-
* @param $page
|
264 |
-
*/
|
265 |
-
protected function cleanItemUpdates($storeId, $page)
|
266 |
-
{
|
267 |
-
if (empty($page)) {
|
268 |
-
if (Mage::helper('core')->isModuleEnabled('Magmodules_Channableapi')) {
|
269 |
-
Mage::getModel('channableapi/items')->cleanItemStore($storeId);
|
270 |
-
}
|
271 |
-
}
|
272 |
-
}
|
273 |
-
|
274 |
/**
|
275 |
* @param $products
|
276 |
* @param $config
|
@@ -279,17 +47,19 @@ class Magmodules_Channable_Model_Channable extends Magmodules_Channable_Model_Co
|
|
279 |
* @param $page
|
280 |
* @return array
|
281 |
*/
|
282 |
-
public function getFeedData($products, $config, $timeStart, $prices, $page)
|
283 |
{
|
284 |
$count = $this->getProducts($config, '', '', 'count');
|
285 |
foreach ($products as $product) {
|
286 |
if ($parentId = Mage::helper('channable')->getParentData($product, $config)) {
|
287 |
-
$parent = $
|
288 |
} else {
|
289 |
$parent = '';
|
290 |
}
|
291 |
|
292 |
-
|
|
|
|
|
293 |
foreach ($productData as $key => $value) {
|
294 |
if (!is_array($value)) {
|
295 |
$productRow[$key] = $value;
|
@@ -313,12 +83,10 @@ class Magmodules_Channable_Model_Channable extends Magmodules_Channable_Model_Co
|
|
313 |
$returnFeed = array();
|
314 |
$returnFeed['config'] = $this->getFeedHeader($config, $count, $timeStart, count($feed['products']), $page);
|
315 |
$returnFeed['products'] = $feed['products'];
|
316 |
-
|
317 |
return $returnFeed;
|
318 |
} else {
|
319 |
$returnFeed = array();
|
320 |
-
$returnFeed['config'] = $this->getFeedHeader($config, $count, $timeStart);
|
321 |
-
|
322 |
return $returnFeed;
|
323 |
}
|
324 |
}
|
@@ -413,11 +181,10 @@ class Magmodules_Channable_Model_Channable extends Magmodules_Channable_Model_Co
|
|
413 |
* @param $data
|
414 |
* @param $config
|
415 |
* @param $weight
|
416 |
-
* @param $product
|
417 |
* @param $stock
|
418 |
* @return array
|
419 |
*/
|
420 |
-
public function getShipping($data, $config, $weight, $
|
421 |
{
|
422 |
$shippingArray = array();
|
423 |
|
@@ -462,6 +229,8 @@ class Magmodules_Channable_Model_Channable extends Magmodules_Channable_Model_Co
|
|
462 |
} else {
|
463 |
if (isset($data['price']['final_price_clean'])) {
|
464 |
$calValue = $data['price']['final_price_clean'];
|
|
|
|
|
465 |
}
|
466 |
}
|
467 |
|
@@ -469,7 +238,6 @@ class Magmodules_Channable_Model_Channable extends Magmodules_Channable_Model_Co
|
|
469 |
foreach ($config['shipping_prices'] as $shippingPrice) {
|
470 |
if (($calValue >= $shippingPrice['price_from']) && ($calValue <= $shippingPrice['price_to'])) {
|
471 |
$shippingCost = $shippingPrice['cost'];
|
472 |
-
|
473 |
$shippingCost = number_format($shippingCost, 2, '.', '') . ' ' . $config['currency'];
|
474 |
if (empty($shippingPrice['country'])) {
|
475 |
$shippingArray['shipping'] = $shippingCost;
|
@@ -643,4 +411,233 @@ class Magmodules_Channable_Model_Channable extends Magmodules_Channable_Model_Co
|
|
643 |
|
644 |
return $header;
|
645 |
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
646 |
}
|
25 |
* @param $timeStart
|
26 |
* @return array
|
27 |
*/
|
28 |
+
public function generateFeed($storeId, $limit = '', $timeStart, $page = 1)
|
29 |
{
|
30 |
$this->setMemoryLimit($storeId);
|
31 |
$config = $this->getFeedConfig($storeId);
|
32 |
$this->cleanItemUpdates($storeId, $page);
|
33 |
$products = $this->getProducts($config, $limit, $page);
|
34 |
+
$parents = $this->getParents($products, $config);
|
35 |
+
$prices = Mage::helper('channable')->getTypePrices($config, $parents);
|
36 |
+
$parentAttributes = Mage::helper('channable')->getConfigurableAttributesAsArray($parents, $config);
|
37 |
+
if ($feed = $this->getFeedData($products, $parents, $config, $parentAttributes, $timeStart, $prices, $page)) {
|
38 |
return $feed;
|
39 |
}
|
40 |
}
|
41 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
42 |
/**
|
43 |
* @param $products
|
44 |
* @param $config
|
47 |
* @param $page
|
48 |
* @return array
|
49 |
*/
|
50 |
+
public function getFeedData($products, $parents, $config, $parentAttributes, $timeStart, $prices, $page)
|
51 |
{
|
52 |
$count = $this->getProducts($config, '', '', 'count');
|
53 |
foreach ($products as $product) {
|
54 |
if ($parentId = Mage::helper('channable')->getParentData($product, $config)) {
|
55 |
+
$parent = $parents->getItemById($parentId);
|
56 |
} else {
|
57 |
$parent = '';
|
58 |
}
|
59 |
|
60 |
+
$productData = Mage::helper('channable')->getProductDataRow($product, $config, $parent, $parentAttributes);
|
61 |
+
|
62 |
+
if ($productData) {
|
63 |
foreach ($productData as $key => $value) {
|
64 |
if (!is_array($value)) {
|
65 |
$productRow[$key] = $value;
|
83 |
$returnFeed = array();
|
84 |
$returnFeed['config'] = $this->getFeedHeader($config, $count, $timeStart, count($feed['products']), $page);
|
85 |
$returnFeed['products'] = $feed['products'];
|
|
|
86 |
return $returnFeed;
|
87 |
} else {
|
88 |
$returnFeed = array();
|
89 |
+
$returnFeed['config'] = $this->getFeedHeader($config, $count, $timeStart, '', $page);
|
|
|
90 |
return $returnFeed;
|
91 |
}
|
92 |
}
|
181 |
* @param $data
|
182 |
* @param $config
|
183 |
* @param $weight
|
|
|
184 |
* @param $stock
|
185 |
* @return array
|
186 |
*/
|
187 |
+
public function getShipping($data, $config, $weight, $stock)
|
188 |
{
|
189 |
$shippingArray = array();
|
190 |
|
229 |
} else {
|
230 |
if (isset($data['price']['final_price_clean'])) {
|
231 |
$calValue = $data['price']['final_price_clean'];
|
232 |
+
} else {
|
233 |
+
$calValue = '0.00';
|
234 |
}
|
235 |
}
|
236 |
|
238 |
foreach ($config['shipping_prices'] as $shippingPrice) {
|
239 |
if (($calValue >= $shippingPrice['price_from']) && ($calValue <= $shippingPrice['price_to'])) {
|
240 |
$shippingCost = $shippingPrice['cost'];
|
|
|
241 |
$shippingCost = number_format($shippingCost, 2, '.', '') . ' ' . $config['currency'];
|
242 |
if (empty($shippingPrice['country'])) {
|
243 |
$shippingArray['shipping'] = $shippingCost;
|
411 |
|
412 |
return $header;
|
413 |
}
|
414 |
+
|
415 |
+
/**
|
416 |
+
* @param $storeId
|
417 |
+
*/
|
418 |
+
protected function setMemoryLimit($storeId)
|
419 |
+
{
|
420 |
+
if (Mage::getStoreConfig('channable/server/overwrite', $storeId)) {
|
421 |
+
if ($memory_limit = Mage::getStoreConfig('channable/server/memory_limit', $storeId)) {
|
422 |
+
ini_set('memory_limit', $memory_limit);
|
423 |
+
}
|
424 |
+
|
425 |
+
if ($max_execution_time = Mage::getStoreConfig('channable/server/max_execution_time', $storeId)) {
|
426 |
+
ini_set('max_execution_time', $max_execution_time);
|
427 |
+
}
|
428 |
+
}
|
429 |
+
}
|
430 |
+
|
431 |
+
/**
|
432 |
+
* @param $storeId
|
433 |
+
* @param $page
|
434 |
+
*/
|
435 |
+
protected function cleanItemUpdates($storeId, $page)
|
436 |
+
{
|
437 |
+
if (empty($page)) {
|
438 |
+
if (Mage::helper('core')->isModuleEnabled('Magmodules_Channableapi')) {
|
439 |
+
Mage::getModel('channableapi/items')->cleanItemStore($storeId);
|
440 |
+
}
|
441 |
+
}
|
442 |
+
}
|
443 |
+
|
444 |
+
|
445 |
+
/**
|
446 |
+
* @param $storeId
|
447 |
+
* @return array
|
448 |
+
*/
|
449 |
+
public function getFeedConfig($storeId)
|
450 |
+
{
|
451 |
+
|
452 |
+
$config = array();
|
453 |
+
$feed = Mage::helper('channable');
|
454 |
+
$websiteId = Mage::app()->getStore($storeId)->getWebsiteId();
|
455 |
+
|
456 |
+
// DEFAULTS
|
457 |
+
$config['store_id'] = $storeId;
|
458 |
+
$config['website_name'] = $feed->cleanData(Mage::getModel('core/website')->load($websiteId)->getName(), 'striptags');
|
459 |
+
$config['website_url'] = Mage::app()->getStore($storeId)->getBaseUrl(Mage_Core_Model_Store::URL_TYPE_LINK);
|
460 |
+
$config['media_url'] = Mage::app()->getStore($storeId)->getBaseUrl(Mage_Core_Model_Store::URL_TYPE_MEDIA);
|
461 |
+
$config['media_image_url'] = $config['media_url'] . 'catalog' . DS . 'product';
|
462 |
+
$config['media_attributes'] = $feed->getMediaAttributes();
|
463 |
+
$config['limit'] = Mage::getStoreConfig('channable/connect/max_products', $storeId);
|
464 |
+
$config['version'] = (string)Mage::getConfig()->getNode()->modules->Magmodules_Channable->version;
|
465 |
+
$config['media_gallery_id'] = Mage::getResourceModel('eav/entity_attribute')->getIdByCode('catalog_product', 'media_gallery');
|
466 |
+
$config['filters'] = @unserialize(Mage::getStoreConfig('channable/filter/advanced', $storeId));
|
467 |
+
$config['product_url_suffix'] = $feed->getProductUrlSuffix($storeId);
|
468 |
+
$config['filter_enabled'] = Mage::getStoreConfig('channable/filter/category_enabled', $storeId);
|
469 |
+
$config['filter_cat'] = Mage::getStoreConfig('channable/filter/categories', $storeId);
|
470 |
+
$config['filter_type'] = Mage::getStoreConfig('channable/filter/category_type', $storeId);
|
471 |
+
$config['filter_status'] = Mage::getStoreConfig('channable/filter/visibility_inc', $storeId);
|
472 |
+
$config['hide_no_stock'] = Mage::getStoreConfig('channable/filter/stock', $storeId);
|
473 |
+
$config['conf_enabled'] = Mage::getStoreConfig('channable/data/conf_enabled', $storeId);
|
474 |
+
$config['conf_fields'] = Mage::getStoreConfig('channable/data/conf_fields', $storeId);
|
475 |
+
$config['parent_att'] = $this->getParentAttributeSelection($config['conf_fields']);
|
476 |
+
$config['conf_switch_urls'] = Mage::getStoreConfig('channable/data/conf_switch_urls', $storeId);
|
477 |
+
$config['stock_manage'] = Mage::getStoreConfig('cataloginventory/item_options/manage_stock');
|
478 |
+
$config['use_qty_increments'] = Mage::getStoreConfig('cataloginventory/item_options/enable_qty_increments');
|
479 |
+
$config['qty_increments'] = Mage::getStoreConfig('cataloginventory/item_options/qty_increments');
|
480 |
+
$config['delivery'] = Mage::getStoreConfig('channable/data/delivery', $storeId);
|
481 |
+
$config['delivery_be'] = Mage::getStoreConfig('channable/data/delivery_be', $storeId);
|
482 |
+
$config['delivery_att'] = Mage::getStoreConfig('channable/data/delivery_att', $storeId);
|
483 |
+
$config['delivery_att_be'] = Mage::getStoreConfig('channable/data/delivery_att_be', $storeId);
|
484 |
+
$config['delivery_in'] = Mage::getStoreConfig('channable/data/delivery_in', $storeId);
|
485 |
+
$config['delivery_in_be'] = Mage::getStoreConfig('channable/data/delivery_in_be', $storeId);
|
486 |
+
$config['delivery_out'] = Mage::getStoreConfig('channable/data/delivery_out', $storeId);
|
487 |
+
$config['delivery_out_be'] = Mage::getStoreConfig('channable/data/delivery_out_be', $storeId);
|
488 |
+
$config['images'] = Mage::getStoreConfig('channable/data/images', $storeId);
|
489 |
+
$config['default_image'] = Mage::getStoreConfig('channable/data/default_image', $storeId);
|
490 |
+
$config['skip_validation'] = false;
|
491 |
+
$config['weight'] = Mage::getStoreConfig('channable/data/weight', $storeId);
|
492 |
+
$config['weight_units'] = Mage::getStoreConfig('channable/data/weight_units', $storeId);
|
493 |
+
$config['price_scope'] = Mage::getStoreConfig('catalog/price/scope');
|
494 |
+
$config['price_add_tax'] = Mage::getStoreConfig('channable/data/add_tax', $storeId);
|
495 |
+
$config['price_add_tax_perc'] = Mage::getStoreConfig('channable/data/tax_percentage', $storeId);
|
496 |
+
$config['force_tax'] = Mage::getStoreConfig('channable/data/force_tax', $storeId);
|
497 |
+
$config['currency'] = Mage::app()->getStore($storeId)->getCurrentCurrencyCode();
|
498 |
+
$config['base_currency_code'] = Mage::app()->getStore($storeId)->getBaseCurrencyCode();
|
499 |
+
$config['markup'] = Mage::helper('channable')->getPriceMarkup($config);
|
500 |
+
$config['use_tax'] = Mage::helper('channable')->getTaxUsage($config);
|
501 |
+
|
502 |
+
if (Mage::helper('core')->isModuleEnabled('Magmodules_Channableapi')) {
|
503 |
+
$config['item_updates'] = Mage::getStoreConfig('channable_api/item/enabled', $storeId);
|
504 |
+
} else {
|
505 |
+
$config['item_updates'] = '';
|
506 |
+
}
|
507 |
+
|
508 |
+
$config['shipping_prices'] = @unserialize(Mage::getStoreConfig('channable/advanced/shipping_price', $storeId));
|
509 |
+
$config['shipping_method'] = Mage::getStoreConfig('channable/advanced/shipping_method', $storeId);
|
510 |
+
$config['field'] = $this->getFeedAttributes($config, $storeId);
|
511 |
+
$config['category_exclude'] = 'channable_exclude';
|
512 |
+
$config['category_data'] = $feed->getCategoryData($config, $storeId);
|
513 |
+
|
514 |
+
return $config;
|
515 |
+
}
|
516 |
+
|
517 |
+
/**
|
518 |
+
* @param string $config
|
519 |
+
* @param int $storeId
|
520 |
+
* @return mixed
|
521 |
+
*/
|
522 |
+
public function getFeedAttributes($config = '', $storeId = 0)
|
523 |
+
{
|
524 |
+
$attributes = array();
|
525 |
+
$attributes['id'] = array(
|
526 |
+
'label' => 'id',
|
527 |
+
'source' => 'entity_id'
|
528 |
+
);
|
529 |
+
$attributes['name'] = array(
|
530 |
+
'label' => 'name',
|
531 |
+
'source' => Mage::getStoreConfig('channable/data/name', $storeId)
|
532 |
+
);
|
533 |
+
$attributes['description'] = array(
|
534 |
+
'label' => 'description',
|
535 |
+
'source' => Mage::getStoreConfig('channable/data/description', $storeId)
|
536 |
+
);
|
537 |
+
$attributes['product_url'] = array(
|
538 |
+
'label' => 'url',
|
539 |
+
'source' => ''
|
540 |
+
);
|
541 |
+
$attributes['image_link'] = array(
|
542 |
+
'label' => 'image',
|
543 |
+
'source' => Mage::getStoreConfig('channable/data/default_image', $storeId)
|
544 |
+
);
|
545 |
+
$attributes['price'] = array(
|
546 |
+
'label' => 'price',
|
547 |
+
'source' => ''
|
548 |
+
);
|
549 |
+
$attributes['sku'] = array(
|
550 |
+
'label' => 'sku',
|
551 |
+
'source' => Mage::getStoreConfig('channable/data/sku', $storeId)
|
552 |
+
);
|
553 |
+
$attributes['brand'] = array(
|
554 |
+
'label' => 'brand',
|
555 |
+
'source' => Mage::getStoreConfig('channable/data/brand', $storeId)
|
556 |
+
);
|
557 |
+
$attributes['size'] = array(
|
558 |
+
'label' => 'size',
|
559 |
+
'source' => Mage::getStoreConfig('channable/data/size', $storeId)
|
560 |
+
);
|
561 |
+
$attributes['color'] = array(
|
562 |
+
'label' => 'color',
|
563 |
+
'source' => Mage::getStoreConfig('channable/data/color', $storeId)
|
564 |
+
);
|
565 |
+
$attributes['material'] = array(
|
566 |
+
'label' => 'material',
|
567 |
+
'source' => Mage::getStoreConfig('channable/data/material', $storeId)
|
568 |
+
);
|
569 |
+
$attributes['gender'] = array(
|
570 |
+
'label' => 'gender',
|
571 |
+
'source' => Mage::getStoreConfig('channable/data/gender', $storeId)
|
572 |
+
);
|
573 |
+
$attributes['ean'] = array(
|
574 |
+
'label' => 'ean',
|
575 |
+
'source' => Mage::getStoreConfig('channable/data/ean', $storeId)
|
576 |
+
);
|
577 |
+
$attributes['categories'] = array(
|
578 |
+
'label' => 'categories',
|
579 |
+
'source' => '',
|
580 |
+
'parent' => 1
|
581 |
+
);
|
582 |
+
$attributes['type'] = array(
|
583 |
+
'label' => 'type',
|
584 |
+
'source' => 'type_id'
|
585 |
+
);
|
586 |
+
$attributes['status'] = array(
|
587 |
+
'label' => 'status',
|
588 |
+
'source' => 'status',
|
589 |
+
'parent' => 1
|
590 |
+
);
|
591 |
+
$attributes['visibility'] = array(
|
592 |
+
'label' => 'visibility',
|
593 |
+
'source' => 'visibility'
|
594 |
+
);
|
595 |
+
$attributes['parent_id'] = array(
|
596 |
+
'label' => 'item_group_id',
|
597 |
+
'source' => 'entity_id',
|
598 |
+
'parent' => 1
|
599 |
+
);
|
600 |
+
$attributes['weight'] = array(
|
601 |
+
'label' => 'weight',
|
602 |
+
'source' => ''
|
603 |
+
);
|
604 |
+
$attributes['is_in_stock'] = array(
|
605 |
+
'label' => 'is_in_stock',
|
606 |
+
'source' => 'is_in_stock'
|
607 |
+
);
|
608 |
+
|
609 |
+
if (Mage::getStoreConfig('channable/data/stock', $storeId)) {
|
610 |
+
$attributes['stock'] = array(
|
611 |
+
'label' => 'qty',
|
612 |
+
'source' => 'qty',
|
613 |
+
'action' => 'round'
|
614 |
+
);
|
615 |
+
}
|
616 |
+
|
617 |
+
if (Mage::getStoreConfig('channable/data/delivery', $storeId) == 'attribute') {
|
618 |
+
$attributes['delivery'] = array(
|
619 |
+
'label' => 'delivery',
|
620 |
+
'source' => Mage::getStoreConfig('channable/data/delivery_att', $storeId)
|
621 |
+
);
|
622 |
+
}
|
623 |
+
|
624 |
+
if (Mage::getStoreConfig('channable/data/delivery_be', $storeId) == 'attribute') {
|
625 |
+
$attributes['delivery_be'] = array(
|
626 |
+
'label' => 'delivery_be',
|
627 |
+
'source' => Mage::getStoreConfig('channable/data/delivery_att_be', $storeId)
|
628 |
+
);
|
629 |
+
}
|
630 |
+
|
631 |
+
if ($extraFields = @unserialize(Mage::getStoreConfig('channable/advanced/extra', $storeId))) {
|
632 |
+
foreach ($extraFields as $extraField) {
|
633 |
+
$attributes[$extraField['attribute']] = array(
|
634 |
+
'label' => $extraField['label'],
|
635 |
+
'source' => $extraField['attribute'],
|
636 |
+
'action' => ''
|
637 |
+
);
|
638 |
+
}
|
639 |
+
}
|
640 |
+
|
641 |
+
return Mage::helper('channable')->addAttributeData($attributes, $config);
|
642 |
+
}
|
643 |
}
|
app/code/community/Magmodules/Channable/Model/Common.php
CHANGED
@@ -14,6 +14,7 @@
|
|
14 |
* @license http://www.magmodules.eu/license-agreement/
|
15 |
* =============================================================
|
16 |
*/
|
|
|
17 |
class Magmodules_Channable_Model_Common extends Mage_Core_Helper_Abstract
|
18 |
{
|
19 |
|
@@ -52,6 +53,9 @@ class Magmodules_Channable_Model_Common extends Mage_Core_Helper_Abstract
|
|
52 |
|
53 |
if (($limit) && ($type != 'count')) {
|
54 |
$collection->setPage($page, $limit)->getCurPage();
|
|
|
|
|
|
|
55 |
}
|
56 |
|
57 |
if (empty($config['conf_enabled'])) {
|
@@ -142,11 +146,9 @@ class Magmodules_Channable_Model_Common extends Mage_Core_Helper_Abstract
|
|
142 |
'use_config_qty_increments'
|
143 |
)
|
144 |
);
|
|
|
145 |
$collection->getSelect()->group('e.entity_id');
|
146 |
-
|
147 |
-
Mage::getSingleton('cataloginventory/stock')->addInStockFilterToCollection($collection);
|
148 |
-
}
|
149 |
-
|
150 |
$products = $collection->load();
|
151 |
} else {
|
152 |
$products = $collection->getSize();
|
@@ -156,6 +158,7 @@ class Magmodules_Channable_Model_Common extends Mage_Core_Helper_Abstract
|
|
156 |
}
|
157 |
|
158 |
/**
|
|
|
159 |
* @return array
|
160 |
*/
|
161 |
public function getDefaultAttributes()
|
@@ -185,18 +188,40 @@ class Magmodules_Channable_Model_Common extends Mage_Core_Helper_Abstract
|
|
185 |
return $attributes;
|
186 |
}
|
187 |
|
188 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
189 |
{
|
190 |
-
|
191 |
-
|
192 |
-
|
193 |
-
|
194 |
-
|
195 |
-
|
196 |
-
|
197 |
-
|
198 |
-
|
199 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
200 |
}
|
201 |
|
202 |
/**
|
@@ -227,9 +252,9 @@ class Magmodules_Channable_Model_Common extends Mage_Core_Helper_Abstract
|
|
227 |
$value = $filter['value'];
|
228 |
|
229 |
if ($attribute == 'final_price') {
|
230 |
-
$
|
231 |
-
if (isset($
|
232 |
-
$collection->getSelect()->where('price_index.final_price ' . $
|
233 |
}
|
234 |
|
235 |
continue;
|
@@ -278,5 +303,4 @@ class Magmodules_Channable_Model_Common extends Mage_Core_Helper_Abstract
|
|
278 |
}
|
279 |
}
|
280 |
}
|
281 |
-
|
282 |
-
}
|
14 |
* @license http://www.magmodules.eu/license-agreement/
|
15 |
* =============================================================
|
16 |
*/
|
17 |
+
|
18 |
class Magmodules_Channable_Model_Common extends Mage_Core_Helper_Abstract
|
19 |
{
|
20 |
|
53 |
|
54 |
if (($limit) && ($type != 'count')) {
|
55 |
$collection->setPage($page, $limit)->getCurPage();
|
56 |
+
if ($collection->getLastPageNumber() < $page) {
|
57 |
+
return array();
|
58 |
+
}
|
59 |
}
|
60 |
|
61 |
if (empty($config['conf_enabled'])) {
|
146 |
'use_config_qty_increments'
|
147 |
)
|
148 |
);
|
149 |
+
|
150 |
$collection->getSelect()->group('e.entity_id');
|
151 |
+
|
|
|
|
|
|
|
152 |
$products = $collection->load();
|
153 |
} else {
|
154 |
$products = $collection->getSize();
|
158 |
}
|
159 |
|
160 |
/**
|
161 |
+
* Araay of default Attributes
|
162 |
* @return array
|
163 |
*/
|
164 |
public function getDefaultAttributes()
|
188 |
return $attributes;
|
189 |
}
|
190 |
|
191 |
+
|
192 |
+
/**
|
193 |
+
* @param $products
|
194 |
+
* @param $config
|
195 |
+
* @return array
|
196 |
+
*/
|
197 |
+
public function getParents($products, $config)
|
198 |
{
|
199 |
+
if (!empty($config['conf_enabled'])) {
|
200 |
+
$ids = array();
|
201 |
+
foreach ($products as $product) {
|
202 |
+
if ($parentId = Mage::helper('channable')->getParentData($product, $config)) {
|
203 |
+
$ids[] = $parentId;
|
204 |
+
}
|
205 |
+
}
|
206 |
+
|
207 |
+
if (empty($ids)) {
|
208 |
+
return array();
|
209 |
+
}
|
210 |
+
|
211 |
+
$collection = Mage::getResourceModel('catalog/product_collection')
|
212 |
+
->setStore($config['store_id'])
|
213 |
+
->addStoreFilter($config['store_id'])
|
214 |
+
->addFinalPrice()
|
215 |
+
->addUrlRewrite()
|
216 |
+
->addAttributeToFilter('entity_id', array('in', $ids))
|
217 |
+
->addAttributeToSelect(array_unique($config['parent_att']));
|
218 |
+
|
219 |
+
if (!empty($config['hide_no_stock'])) {
|
220 |
+
Mage::getSingleton('cataloginventory/stock')->addInStockFilterToCollection($collection);
|
221 |
+
}
|
222 |
+
|
223 |
+
return $collection->load();
|
224 |
+
}
|
225 |
}
|
226 |
|
227 |
/**
|
252 |
$value = $filter['value'];
|
253 |
|
254 |
if ($attribute == 'final_price') {
|
255 |
+
$cType = array('eq'=> '=', 'neq' => '!=', 'gt' => '>', 'gteq' => '>=', 'lt' => '<', 'lteg' => '<=');
|
256 |
+
if (isset($cType[$condition])) {
|
257 |
+
$collection->getSelect()->where('price_index.final_price ' . $cType[$condition] . ' ' . $value);
|
258 |
}
|
259 |
|
260 |
continue;
|
303 |
}
|
304 |
}
|
305 |
}
|
306 |
+
}
|
|
app/code/community/Magmodules/Channable/controllers/FeedController.php
CHANGED
@@ -33,15 +33,8 @@ class Magmodules_Channable_FeedController extends Mage_Core_Controller_Front_Act
|
|
33 |
$limit = Mage::getStoreConfig('channable/connect/max_products', $storeId);
|
34 |
$appEmulation = Mage::getSingleton('core/app_emulation');
|
35 |
$initialEnvironmentInfo = $appEmulation->startEnvironmentEmulation($storeId);
|
36 |
-
Mage::app()->loadAreaPart(
|
37 |
-
|
38 |
-
Mage_Core_Model_App_Area::PART_EVENTS
|
39 |
-
)->loadArea(Mage_Core_Model_App_Area::AREA_FRONTEND);
|
40 |
-
if ($feed = Mage::getModel('channable/channable')->generateFeed(
|
41 |
-
$storeId, $limit, $page,
|
42 |
-
$timeStart
|
43 |
-
)
|
44 |
-
) {
|
45 |
if ($this->getRequest()->getParam('array')) {
|
46 |
$this->getResponse()->setBody(Zend_Debug::dump($feed, null, false));
|
47 |
} else {
|
33 |
$limit = Mage::getStoreConfig('channable/connect/max_products', $storeId);
|
34 |
$appEmulation = Mage::getSingleton('core/app_emulation');
|
35 |
$initialEnvironmentInfo = $appEmulation->startEnvironmentEmulation($storeId);
|
36 |
+
Mage::app()->loadAreaPart(Mage_Core_Model_App_Area::AREA_GLOBAL, Mage_Core_Model_App_Area::PART_EVENTS)->loadArea(Mage_Core_Model_App_Area::AREA_FRONTEND);
|
37 |
+
if ($feed = Mage::getModel('channable/channable')->generateFeed($storeId, $limit, $timeStart, $page)) {
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
38 |
if ($this->getRequest()->getParam('array')) {
|
39 |
$this->getResponse()->setBody(Zend_Debug::dump($feed, null, false));
|
40 |
} else {
|
app/code/community/Magmodules/Channable/etc/config.xml
CHANGED
@@ -19,7 +19,7 @@
|
|
19 |
<config>
|
20 |
<modules>
|
21 |
<Magmodules_Channable>
|
22 |
-
<version>1.5.
|
23 |
</Magmodules_Channable>
|
24 |
</modules>
|
25 |
<global>
|
19 |
<config>
|
20 |
<modules>
|
21 |
<Magmodules_Channable>
|
22 |
+
<version>1.5.1</version>
|
23 |
</Magmodules_Channable>
|
24 |
</modules>
|
25 |
<global>
|
package.xml
CHANGED
@@ -1,7 +1,7 @@
|
|
1 |
<?xml version="1.0"?>
|
2 |
<package>
|
3 |
<name>Magmodules_Channable</name>
|
4 |
-
<version>1.5.
|
5 |
<stability>stable</stability>
|
6 |
<license uri="http://www.magmodules.eu/license-agreement/">Single Server License</license>
|
7 |
<channel>community</channel>
|
@@ -10,9 +10,9 @@
|
|
10 |
<description>Magmodules_Channable</description>
|
11 |
<notes>Channable Connect</notes>
|
12 |
<authors><author><name>Magmodules</name><user>magmodules</user><email>info@magmodules.nl</email></author></authors>
|
13 |
-
<date>2016-12-
|
14 |
-
<time>
|
15 |
-
<contents><target name="magecommunity"><dir name="Magmodules"><dir name="Channable"><dir name="Block"><dir name="Adminhtml"><dir name="Config"><dir name="Form"><dir name="Field"><file name="Extra.php" hash="c3de2d254516fb969aa32e77e420cec0"/><file name="Filter.php" hash="c18a5c2b289ef4c8cb1950990aad824a"/><file name="Shipping.php" hash="6ff0ceaf1170cc1c8d6e322377d51c55"/></dir><dir name="Renderer"><file name="Select.php" hash="de38e69b1251f094e1818615a02278fb"/></dir></dir></dir><dir name="System"><dir name="Config"><dir name="Form"><dir name="Field"><file name="Feeds.php" hash="14f14219d1c08ad938a6db512f71eacf"/><file name="Heading.php" hash="4b406e44f5b9d36cdf15f3c52984df88"/><file name="Note.php" hash="f0898ebfb7883e3d1e4ef2aba7c4b1f6"/><file name="Token.php" hash="7c0a7173abe2dc5e0763f62236c57875"/><file name="Version.php" hash="afcf324b22f7b496eb24ee0e5c4827ed"/></dir></dir></dir></dir><dir name="Widget"><dir name="Info"><file name="Info.php" hash="086595fa1457f59c4b536703376ff34f"/></dir></dir></dir></dir><dir name="Helper"><file name="Data.php" hash="
|
16 |
<compatible/>
|
17 |
<dependencies><required><php><min>5.1.0</min><max>7.9.9</max></php></required></dependencies>
|
18 |
</package>
|
1 |
<?xml version="1.0"?>
|
2 |
<package>
|
3 |
<name>Magmodules_Channable</name>
|
4 |
+
<version>1.5.1</version>
|
5 |
<stability>stable</stability>
|
6 |
<license uri="http://www.magmodules.eu/license-agreement/">Single Server License</license>
|
7 |
<channel>community</channel>
|
10 |
<description>Magmodules_Channable</description>
|
11 |
<notes>Channable Connect</notes>
|
12 |
<authors><author><name>Magmodules</name><user>magmodules</user><email>info@magmodules.nl</email></author></authors>
|
13 |
+
<date>2016-12-09</date>
|
14 |
+
<time>08:37:59</time>
|
15 |
+
<contents><target name="magecommunity"><dir name="Magmodules"><dir name="Channable"><dir name="Block"><dir name="Adminhtml"><dir name="Config"><dir name="Form"><dir name="Field"><file name="Extra.php" hash="c3de2d254516fb969aa32e77e420cec0"/><file name="Filter.php" hash="c18a5c2b289ef4c8cb1950990aad824a"/><file name="Shipping.php" hash="6ff0ceaf1170cc1c8d6e322377d51c55"/></dir><dir name="Renderer"><file name="Select.php" hash="de38e69b1251f094e1818615a02278fb"/></dir></dir></dir><dir name="System"><dir name="Config"><dir name="Form"><dir name="Field"><file name="Feeds.php" hash="14f14219d1c08ad938a6db512f71eacf"/><file name="Heading.php" hash="4b406e44f5b9d36cdf15f3c52984df88"/><file name="Note.php" hash="f0898ebfb7883e3d1e4ef2aba7c4b1f6"/><file name="Token.php" hash="7c0a7173abe2dc5e0763f62236c57875"/><file name="Version.php" hash="afcf324b22f7b496eb24ee0e5c4827ed"/></dir></dir></dir></dir><dir name="Widget"><dir name="Info"><file name="Info.php" hash="086595fa1457f59c4b536703376ff34f"/></dir></dir></dir></dir><dir name="Helper"><file name="Data.php" hash="b1758b644b6aca18fc9891d175128259"/></dir><dir name="Model"><dir name="Adminhtml"><dir name="System"><dir name="Config"><dir name="Backend"><dir name="Design"><file name="Extra.php" hash="8ed25fdc80ab735ad7d20f565bff4d65"/><file name="Filter.php" hash="c396481ef9e8ec62629a7ed0c9a6aef4"/><file name="Shipping.php" hash="126481e0e3599cb62b9613ac5d462dbe"/></dir></dir><dir name="Source"><file name="Action.php" hash="f9eef61712b067c43db7a32c6e5933f1"/><file name="Attribute.php" hash="c278ab2184e9129dece4a22121e22e33"/><file name="Category.php" hash="c877eb5be8f84a8ec352b933e7ac2cd1"/><file name="Categorytype.php" hash="b330bd5d575592b933c810384f95acbc"/><file name="Conditions.php" hash="aa7c3018a74f60fb41388c307e4d928d"/><file name="Configurable.php" hash="24a00a6d577ab18f3a4b20200f92cad0"/><file name="Countries.php" hash="c678e1f8625630313f78654901ed7275"/><file name="Images.php" hash="847f4d99908923bf835cefc826fbbd4a"/><file name="Mainimage.php" hash="96a2d8df1920956113f5b4509506df47"/><file name="Name.php" hash="0bdf3102e7e52e74bcbbdbb6640f0c01"/><file name="Pricemodel.php" hash="d93cbeed02dd5d38e4dc835ed06cc46f"/><file name="Selectattribute.php" hash="eea82ac436e2b999d37954c4706c690d"/><file name="Shipping.php" hash="8a8b0753092eac24484508f541a317c0"/><file name="Tax.php" hash="fbdc14e6c556d3281f8fdf652c8c637f"/><file name="Textattribute.php" hash="b601321ea8f84413c201f6f1bd5da15d"/><file name="Type.php" hash="f0bd14bb3c19b0fe59e64e2f9d96ae7f"/><file name="Visibility.php" hash="ca3d49287963398b35a905f068cfd647"/><file name="Weight.php" hash="1b05f0f69a7ebd6e0ea445ae11544fc9"/></dir></dir></dir></dir><file name="Channable.php" hash="753c50313cc773d65615817a2f0cd7eb"/><file name="Common.php" hash="b6aae848464576dcb4c8bada2ad8e6f3"/></dir><dir name="controllers"><dir name="Adminhtml"><file name="ChannableController.php" hash="957b06156e54c3e78c3ee2fa1549f358"/></dir><file name="FeedController.php" hash="8ad6ae001206426a4476aeafcc8fda08"/></dir><dir name="data"><dir name="magmodules_channable_setup"><file name="data-upgrade-1.4.8-1.4.9.php" hash="66a5f5720815c9e738b54a039877c9c9"/></dir></dir><dir name="etc"><file name="adminhtml.xml" hash="0bc11d7499e07c074d3b7ecab3a2400b"/><file name="config.xml" hash="96a46885d540b04243dda14f5bdff76e"/><file name="system.xml" hash="1868aa41d072cb856e044e8bc6eb92a8"/></dir><dir name="sql"><dir name="magmodules_channable_setup"><file name="upgrade-1.4.8-1.4.9.php" hash="572c087cac6aa281aa23af1ad4b7ef6e"/></dir></dir></dir></dir></target><target name="magelocale"><dir><dir name="en_US"><file name="Magmodules_Channable.csv" hash="b7f6f15de57f502ccf1c98e71006a823"/></dir><dir name="nl_NL"><file name="Magmodules_Channable.csv" hash="2eaec8847182a0005c575e0acf6e1c1d"/></dir></dir></target><target name="mageetc"><dir name="modules"><file name="Magmodules_Channable.xml" hash="061032d718f1ddd64de211fc7133685c"/></dir></target></contents>
|
16 |
<compatible/>
|
17 |
<dependencies><required><php><min>5.1.0</min><max>7.9.9</max></php></required></dependencies>
|
18 |
</package>
|