Version Notes
Updated category fetch and UTC date format
Download this release
Release Info
| Developer | ShoppingFeeder |
| Extension | shoppingfeeder |
| Version | 1.3.11 |
| Comparing to | |
| See all releases | |
Code changes from version 1.3.10 to 1.3.11
app/code/community/ShoppingFeeder/Service/Model/Offers.php
CHANGED
|
@@ -1,411 +1,445 @@
|
|
| 1 |
-
<?php
|
| 2 |
-
|
| 3 |
-
class ShoppingFeeder_Service_Model_Offers extends Mage_Core_Model_Abstract
|
| 4 |
-
{
|
| 5 |
-
public function __construct()
|
| 6 |
-
{
|
| 7 |
-
$this->_init('shoppingfeeder_service/offers');
|
| 8 |
-
}
|
| 9 |
-
|
| 10 |
-
private function hasParent($product)
|
| 11 |
-
{
|
| 12 |
-
$parents = Mage::getModel('catalog/product_type_configurable')->getParentIdsByChild($product->getId());
|
| 13 |
-
return !empty($parents);
|
| 14 |
-
}
|
| 15 |
-
|
| 16 |
-
private function getProductInfo(Mage_Catalog_Model_Product $product, Mage_Catalog_Model_Product $parent = null, $variantOptions = null, $lastUpdate = null, $priceCurrency, $priceCurrencyRate)
|
| 17 |
-
{
|
| 18 |
-
/** @var Mage_Catalog_Model_Product_Type_Configurable $configModel */
|
| 19 |
-
$configModel = Mage::getModel('catalog/product_type_configurable');
|
| 20 |
-
|
| 21 |
-
$p = array();
|
| 22 |
-
|
| 23 |
-
$isVariant = !is_null($parent);
|
| 24 |
-
|
| 25 |
-
/**
|
| 26 |
-
* We only want to pull variants (children of configurable products) that are children, not as standalone products
|
| 27 |
-
*/
|
| 28 |
-
//if this product's parent is visible in catalog and search, Mage_Catalog_Model_Product_Visibility::VISIBILITY_BOTH,
|
| 29 |
-
//we will find this product when we fetch all the children of this parent through a normal iteration, so return nothing
|
| 30 |
-
if (!$isVariant && $this->hasParent($product))
|
| 31 |
-
{
|
| 32 |
-
return array();
|
| 33 |
-
}
|
| 34 |
-
|
| 35 |
-
if ($isVariant)
|
| 36 |
-
{
|
| 37 |
-
$variant = $product;
|
| 38 |
-
$product = $parent;
|
| 39 |
-
}
|
| 40 |
-
|
| 41 |
-
$data = $product->getData();
|
| 42 |
-
|
| 43 |
-
/* @var Mage_CatalogInventory_Model_Stock_Item $stockItem */
|
| 44 |
-
$stockItem = Mage::getModel('cataloginventory/stock_item')->loadByProduct($product);
|
| 45 |
-
|
| 46 |
-
$attributes = $product->getAttributes();
|
| 47 |
-
$manufacturer = '';
|
| 48 |
-
$brand = '';
|
| 49 |
-
|
| 50 |
-
$usefulAttributes = array();
|
| 51 |
-
|
| 52 |
-
/**
|
| 53 |
-
* @var Mage_Eav_Model_Entity_Attribute_Abstract $attribute
|
| 54 |
-
*/
|
| 55 |
-
// var_dump("");
|
| 56 |
-
// var_dump("");
|
| 57 |
-
// var_dump("");
|
| 58 |
-
foreach ($attributes as $attribute)
|
| 59 |
-
{
|
| 60 |
-
$attributeCode = $attribute->getAttributeCode();
|
| 61 |
-
$attributeLabel = $attribute->getData('frontend_label');
|
| 62 |
-
$value = $attribute->getFrontend()->getValue($product);
|
| 63 |
-
|
| 64 |
-
// var_dump($attributeCode. ' : '.print_r($value, true));
|
| 65 |
-
// var_dump($attributeLabel. ' : '.print_r($value, true));
|
| 66 |
-
|
| 67 |
-
if (preg_match('/^manufacturer$/i', $attributeCode) || preg_match('/^manufacturer$/i', $attributeLabel))
|
| 68 |
-
{
|
| 69 |
-
$manufacturer = $value;
|
| 70 |
-
}
|
| 71 |
-
|
| 72 |
-
if (preg_match('/^brand$/i', $attributeCode) || preg_match('/^brand$/i', $attributeLabel))
|
| 73 |
-
{
|
| 74 |
-
$brand = $value;
|
| 75 |
-
}
|
| 76 |
-
|
| 77 |
-
/*
|
| 78 |
-
if (preg_match('/age/i', $attributeCode) || preg_match('/age/i', $attributeLabel))
|
| 79 |
-
{
|
| 80 |
-
$usefulAttributes['age'] = $value;
|
| 81 |
-
}
|
| 82 |
-
if (preg_match('/color|colour/i', $attributeCode) || preg_match('/color|colour/i', $attributeLabel))
|
| 83 |
-
{
|
| 84 |
-
$usefulAttributes['colour'] = $value;
|
| 85 |
-
}
|
| 86 |
-
if (preg_match('/size/i', $attributeCode) || preg_match('/size/i', $attributeLabel))
|
| 87 |
-
{
|
| 88 |
-
$usefulAttributes['size'] = $value;
|
| 89 |
-
}
|
| 90 |
-
if (preg_match('/gender|sex/i', $attributeCode) || preg_match('/gender|sex/i', $attributeLabel))
|
| 91 |
-
{
|
| 92 |
-
$usefulAttributes['gender'] = $value;
|
| 93 |
-
}
|
| 94 |
-
if (preg_match('/material/i', $attributeCode) || preg_match('/material/i', $attributeLabel))
|
| 95 |
-
{
|
| 96 |
-
$usefulAttributes['material'] = $value;
|
| 97 |
-
}
|
| 98 |
-
if (preg_match('/pattern/i', $attributeCode) || preg_match('/pattern/i', $attributeLabel))
|
| 99 |
-
{
|
| 100 |
-
$usefulAttributes['pattern'] = $value;
|
| 101 |
-
}
|
| 102 |
-
*/
|
| 103 |
-
if (!is_null($product->getData($attributeCode)) && ((string)$attribute->getFrontend()->getValue($product) != ''))
|
| 104 |
-
{
|
| 105 |
-
$usefulAttributes[$attributeCode] = $value;
|
| 106 |
-
}
|
| 107 |
-
}
|
| 108 |
-
// exit();
|
| 109 |
-
|
| 110 |
-
//category path
|
| 111 |
-
$categories = $product->getCategoryIds();
|
| 112 |
-
|
| 113 |
-
$categoryPathsToEvaluate = array();
|
| 114 |
-
$maxDepth = 0;
|
| 115 |
-
$categoryPathToUse = '';
|
| 116 |
-
|
| 117 |
-
$storeRootCategoryId = Mage::app()->getStore()->getRootCategoryId();
|
| 118 |
-
$storeRootCategoryName = Mage::getModel('catalog/category')->load($storeRootCategoryId)->getName();
|
| 119 |
-
|
| 120 |
-
if (!empty($categories))
|
| 121 |
-
{
|
| 122 |
-
|
| 123 |
-
|
| 124 |
-
|
| 125 |
-
|
| 126 |
-
|
| 127 |
-
|
| 128 |
-
|
| 129 |
-
$
|
| 130 |
-
unset($
|
| 131 |
-
|
| 132 |
-
$
|
| 133 |
-
|
| 134 |
-
|
| 135 |
-
|
| 136 |
-
|
| 137 |
-
|
| 138 |
-
|
| 139 |
-
|
| 140 |
-
|
| 141 |
-
if ($
|
| 142 |
-
{
|
| 143 |
-
|
| 144 |
-
|
| 145 |
-
|
| 146 |
-
|
| 147 |
-
|
| 148 |
-
|
| 149 |
-
|
| 150 |
-
|
| 151 |
-
|
| 152 |
-
|
| 153 |
-
|
| 154 |
-
|
| 155 |
-
|
| 156 |
-
|
| 157 |
-
|
| 158 |
-
|
| 159 |
-
|
| 160 |
-
|
| 161 |
-
|
| 162 |
-
|
| 163 |
-
|
| 164 |
-
|
| 165 |
-
|
| 166 |
-
|
| 167 |
-
|
| 168 |
-
|
| 169 |
-
|
| 170 |
-
|
| 171 |
-
|
| 172 |
-
|
| 173 |
-
|
| 174 |
-
|
| 175 |
-
$
|
| 176 |
-
|
| 177 |
-
|
| 178 |
-
|
| 179 |
-
|
| 180 |
-
|
| 181 |
-
|
| 182 |
-
|
| 183 |
-
}
|
| 184 |
-
|
| 185 |
-
|
| 186 |
-
|
| 187 |
-
|
| 188 |
-
|
| 189 |
-
|
| 190 |
-
|
| 191 |
-
|
| 192 |
-
|
| 193 |
-
|
| 194 |
-
|
| 195 |
-
|
| 196 |
-
|
| 197 |
-
|
| 198 |
-
|
| 199 |
-
|
| 200 |
-
|
| 201 |
-
|
| 202 |
-
|
| 203 |
-
|
| 204 |
-
|
| 205 |
-
|
| 206 |
-
|
| 207 |
-
|
| 208 |
-
|
| 209 |
-
|
| 210 |
-
|
| 211 |
-
|
| 212 |
-
|
| 213 |
-
|
| 214 |
-
|
| 215 |
-
|
| 216 |
-
|
| 217 |
-
|
| 218 |
-
|
| 219 |
-
|
| 220 |
-
$
|
| 221 |
-
$
|
| 222 |
-
|
| 223 |
-
|
| 224 |
-
|
| 225 |
-
|
| 226 |
-
|
| 227 |
-
|
| 228 |
-
|
| 229 |
-
|
| 230 |
-
|
| 231 |
-
|
| 232 |
-
|
| 233 |
-
|
| 234 |
-
|
| 235 |
-
|
| 236 |
-
|
| 237 |
-
|
| 238 |
-
|
| 239 |
-
|
| 240 |
-
|
| 241 |
-
|
| 242 |
-
$
|
| 243 |
-
|
| 244 |
-
|
| 245 |
-
|
| 246 |
-
|
| 247 |
-
|
| 248 |
-
$
|
| 249 |
-
$
|
| 250 |
-
|
| 251 |
-
$p['
|
| 252 |
-
|
| 253 |
-
$p['
|
| 254 |
-
$
|
| 255 |
-
|
| 256 |
-
|
| 257 |
-
|
| 258 |
-
|
| 259 |
-
|
| 260 |
-
|
| 261 |
-
|
| 262 |
-
|
| 263 |
-
|
| 264 |
-
|
| 265 |
-
|
| 266 |
-
|
| 267 |
-
$p['
|
| 268 |
-
|
| 269 |
-
$p['
|
| 270 |
-
|
| 271 |
-
|
| 272 |
-
|
| 273 |
-
|
| 274 |
-
$p['
|
| 275 |
-
$p['
|
| 276 |
-
$p['
|
| 277 |
-
$p['
|
| 278 |
-
|
| 279 |
-
|
| 280 |
-
|
| 281 |
-
|
| 282 |
-
|
| 283 |
-
|
| 284 |
-
|
| 285 |
-
|
| 286 |
-
|
| 287 |
-
|
| 288 |
-
|
| 289 |
-
|
| 290 |
-
|
| 291 |
-
|
| 292 |
-
|
| 293 |
-
|
| 294 |
-
|
| 295 |
-
|
| 296 |
-
|
| 297 |
-
|
| 298 |
-
|
| 299 |
-
|
| 300 |
-
|
| 301 |
-
|
| 302 |
-
|
| 303 |
-
|
| 304 |
-
|
| 305 |
-
|
| 306 |
-
|
| 307 |
-
|
| 308 |
-
|
| 309 |
-
$
|
| 310 |
-
|
| 311 |
-
|
| 312 |
-
|
| 313 |
-
|
| 314 |
-
|
| 315 |
-
|
| 316 |
-
|
| 317 |
-
|
| 318 |
-
|
| 319 |
-
|
| 320 |
-
|
| 321 |
-
|
| 322 |
-
|
| 323 |
-
|
| 324 |
-
|
| 325 |
-
|
| 326 |
-
|
| 327 |
-
|
| 328 |
-
|
| 329 |
-
|
| 330 |
-
|
| 331 |
-
|
| 332 |
-
|
| 333 |
-
|
| 334 |
-
|
| 335 |
-
|
| 336 |
-
|
| 337 |
-
|
| 338 |
-
|
| 339 |
-
|
| 340 |
-
|
| 341 |
-
|
| 342 |
-
|
| 343 |
-
|
| 344 |
-
|
| 345 |
-
|
| 346 |
-
|
| 347 |
-
|
| 348 |
-
|
| 349 |
-
|
| 350 |
-
|
| 351 |
-
|
| 352 |
-
|
| 353 |
-
|
| 354 |
-
|
| 355 |
-
|
| 356 |
-
|
| 357 |
-
|
| 358 |
-
|
| 359 |
-
|
| 360 |
-
|
| 361 |
-
|
| 362 |
-
|
| 363 |
-
|
| 364 |
-
|
| 365 |
-
|
| 366 |
-
|
| 367 |
-
|
| 368 |
-
|
| 369 |
-
|
| 370 |
-
|
| 371 |
-
|
| 372 |
-
|
| 373 |
-
|
| 374 |
-
|
| 375 |
-
|
| 376 |
-
|
| 377 |
-
|
| 378 |
-
|
| 379 |
-
|
| 380 |
-
|
| 381 |
-
|
| 382 |
-
|
| 383 |
-
|
| 384 |
-
|
| 385 |
-
|
| 386 |
-
|
| 387 |
-
|
| 388 |
-
|
| 389 |
-
|
| 390 |
-
|
| 391 |
-
|
| 392 |
-
|
| 393 |
-
|
| 394 |
-
|
| 395 |
-
|
| 396 |
-
|
| 397 |
-
|
| 398 |
-
|
| 399 |
-
|
| 400 |
-
|
| 401 |
-
|
| 402 |
-
|
| 403 |
-
|
| 404 |
-
|
| 405 |
-
|
| 406 |
-
|
| 407 |
-
|
| 408 |
-
|
| 409 |
-
|
| 410 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 411 |
}
|
| 1 |
+
<?php
|
| 2 |
+
|
| 3 |
+
class ShoppingFeeder_Service_Model_Offers extends Mage_Core_Model_Abstract
|
| 4 |
+
{
|
| 5 |
+
public function __construct()
|
| 6 |
+
{
|
| 7 |
+
$this->_init('shoppingfeeder_service/offers');
|
| 8 |
+
}
|
| 9 |
+
|
| 10 |
+
private function hasParent($product)
|
| 11 |
+
{
|
| 12 |
+
$parents = Mage::getModel('catalog/product_type_configurable')->getParentIdsByChild($product->getId());
|
| 13 |
+
return !empty($parents);
|
| 14 |
+
}
|
| 15 |
+
|
| 16 |
+
private function getProductInfo(Mage_Catalog_Model_Product $product, Mage_Catalog_Model_Product $parent = null, $variantOptions = null, $lastUpdate = null, $priceCurrency, $priceCurrencyRate)
|
| 17 |
+
{
|
| 18 |
+
/** @var Mage_Catalog_Model_Product_Type_Configurable $configModel */
|
| 19 |
+
$configModel = Mage::getModel('catalog/product_type_configurable');
|
| 20 |
+
|
| 21 |
+
$p = array();
|
| 22 |
+
|
| 23 |
+
$isVariant = !is_null($parent);
|
| 24 |
+
|
| 25 |
+
/**
|
| 26 |
+
* We only want to pull variants (children of configurable products) that are children, not as standalone products
|
| 27 |
+
*/
|
| 28 |
+
//if this product's parent is visible in catalog and search, Mage_Catalog_Model_Product_Visibility::VISIBILITY_BOTH,
|
| 29 |
+
//we will find this product when we fetch all the children of this parent through a normal iteration, so return nothing
|
| 30 |
+
if (!$isVariant && $this->hasParent($product))
|
| 31 |
+
{
|
| 32 |
+
return array();
|
| 33 |
+
}
|
| 34 |
+
|
| 35 |
+
if ($isVariant)
|
| 36 |
+
{
|
| 37 |
+
$variant = $product;
|
| 38 |
+
$product = $parent;
|
| 39 |
+
}
|
| 40 |
+
|
| 41 |
+
$data = $product->getData();
|
| 42 |
+
|
| 43 |
+
/* @var Mage_CatalogInventory_Model_Stock_Item $stockItem */
|
| 44 |
+
$stockItem = Mage::getModel('cataloginventory/stock_item')->loadByProduct($product);
|
| 45 |
+
|
| 46 |
+
$attributes = $product->getAttributes();
|
| 47 |
+
$manufacturer = '';
|
| 48 |
+
$brand = '';
|
| 49 |
+
|
| 50 |
+
$usefulAttributes = array();
|
| 51 |
+
|
| 52 |
+
/**
|
| 53 |
+
* @var Mage_Eav_Model_Entity_Attribute_Abstract $attribute
|
| 54 |
+
*/
|
| 55 |
+
// var_dump("");
|
| 56 |
+
// var_dump("");
|
| 57 |
+
// var_dump("");
|
| 58 |
+
foreach ($attributes as $attribute)
|
| 59 |
+
{
|
| 60 |
+
$attributeCode = $attribute->getAttributeCode();
|
| 61 |
+
$attributeLabel = $attribute->getData('frontend_label');
|
| 62 |
+
$value = $attribute->getFrontend()->getValue($product);
|
| 63 |
+
|
| 64 |
+
// var_dump($attributeCode. ' : '.print_r($value, true));
|
| 65 |
+
// var_dump($attributeLabel. ' : '.print_r($value, true));
|
| 66 |
+
|
| 67 |
+
if (preg_match('/^manufacturer$/i', $attributeCode) || preg_match('/^manufacturer$/i', $attributeLabel))
|
| 68 |
+
{
|
| 69 |
+
$manufacturer = $value;
|
| 70 |
+
}
|
| 71 |
+
|
| 72 |
+
if (preg_match('/^brand$/i', $attributeCode) || preg_match('/^brand$/i', $attributeLabel))
|
| 73 |
+
{
|
| 74 |
+
$brand = $value;
|
| 75 |
+
}
|
| 76 |
+
|
| 77 |
+
/*
|
| 78 |
+
if (preg_match('/age/i', $attributeCode) || preg_match('/age/i', $attributeLabel))
|
| 79 |
+
{
|
| 80 |
+
$usefulAttributes['age'] = $value;
|
| 81 |
+
}
|
| 82 |
+
if (preg_match('/color|colour/i', $attributeCode) || preg_match('/color|colour/i', $attributeLabel))
|
| 83 |
+
{
|
| 84 |
+
$usefulAttributes['colour'] = $value;
|
| 85 |
+
}
|
| 86 |
+
if (preg_match('/size/i', $attributeCode) || preg_match('/size/i', $attributeLabel))
|
| 87 |
+
{
|
| 88 |
+
$usefulAttributes['size'] = $value;
|
| 89 |
+
}
|
| 90 |
+
if (preg_match('/gender|sex/i', $attributeCode) || preg_match('/gender|sex/i', $attributeLabel))
|
| 91 |
+
{
|
| 92 |
+
$usefulAttributes['gender'] = $value;
|
| 93 |
+
}
|
| 94 |
+
if (preg_match('/material/i', $attributeCode) || preg_match('/material/i', $attributeLabel))
|
| 95 |
+
{
|
| 96 |
+
$usefulAttributes['material'] = $value;
|
| 97 |
+
}
|
| 98 |
+
if (preg_match('/pattern/i', $attributeCode) || preg_match('/pattern/i', $attributeLabel))
|
| 99 |
+
{
|
| 100 |
+
$usefulAttributes['pattern'] = $value;
|
| 101 |
+
}
|
| 102 |
+
*/
|
| 103 |
+
if (!is_null($product->getData($attributeCode)) && ((string)$attribute->getFrontend()->getValue($product) != ''))
|
| 104 |
+
{
|
| 105 |
+
$usefulAttributes[$attributeCode] = $value;
|
| 106 |
+
}
|
| 107 |
+
}
|
| 108 |
+
// exit();
|
| 109 |
+
|
| 110 |
+
//category path
|
| 111 |
+
$categories = $product->getCategoryIds();
|
| 112 |
+
|
| 113 |
+
$categoryPathsToEvaluate = array();
|
| 114 |
+
$maxDepth = 0;
|
| 115 |
+
$categoryPathToUse = '';
|
| 116 |
+
|
| 117 |
+
$storeRootCategoryId = Mage::app()->getStore()->getRootCategoryId();
|
| 118 |
+
$storeRootCategoryName = Mage::getModel('catalog/category')->load($storeRootCategoryId)->getName();
|
| 119 |
+
|
| 120 |
+
if (!empty($categories))
|
| 121 |
+
{
|
| 122 |
+
|
| 123 |
+
|
| 124 |
+
/** @var Mage_Catalog_Model_Resource_Category_Collection $categoryCollection */
|
| 125 |
+
$categoryCollection = $product->getCategoryCollection()->addAttributeToSelect('name');
|
| 126 |
+
|
| 127 |
+
$depth = 0;
|
| 128 |
+
foreach($categoryCollection as $cat1){
|
| 129 |
+
$pathIds = explode('/', $cat1->getPath());
|
| 130 |
+
unset($pathIds[0]);
|
| 131 |
+
|
| 132 |
+
$collection = Mage::getModel('catalog/category')->getCollection()
|
| 133 |
+
->setStoreId(Mage::app()->getStore()->getId())
|
| 134 |
+
->addAttributeToSelect('name')
|
| 135 |
+
->addAttributeToSelect('is_active')
|
| 136 |
+
->addFieldToFilter('entity_id', array('in' => $pathIds));
|
| 137 |
+
|
| 138 |
+
$pathByName = array();
|
| 139 |
+
/** @var Mage_Catalog_Model_Category $cat */
|
| 140 |
+
foreach($collection as $cat){
|
| 141 |
+
if ($cat->getName() != $storeRootCategoryName)
|
| 142 |
+
{
|
| 143 |
+
$pathByName[] = $cat->getName();
|
| 144 |
+
}
|
| 145 |
+
}
|
| 146 |
+
|
| 147 |
+
//take the longest (generally more detailed) path
|
| 148 |
+
$thisDepth = count($pathByName);
|
| 149 |
+
if ($thisDepth > $depth)
|
| 150 |
+
{
|
| 151 |
+
$depth = $thisDepth;
|
| 152 |
+
$categoryPathToUse = implode(' > ', $pathByName);
|
| 153 |
+
}
|
| 154 |
+
}
|
| 155 |
+
|
| 156 |
+
// //we will get all the category paths and then use the most refined, deepest one
|
| 157 |
+
// foreach ($categories as $rootCategoryId)
|
| 158 |
+
// {
|
| 159 |
+
// $depth = 0;
|
| 160 |
+
// $category_path = '';
|
| 161 |
+
//
|
| 162 |
+
// $mageCategoryPath = Mage::getModel('catalog/category')->load($rootCategoryId)->getPath();
|
| 163 |
+
// $allCategoryIds = explode('/', $mageCategoryPath);
|
| 164 |
+
// unset($allCategoryIds[0]);
|
| 165 |
+
//
|
| 166 |
+
// $categoryPath = '';
|
| 167 |
+
// /**
|
| 168 |
+
// * @var Mage_Catalog_Model_Category $category
|
| 169 |
+
// */
|
| 170 |
+
// foreach ($allCategoryIds as $categoryId)
|
| 171 |
+
// {
|
| 172 |
+
// $depth++;
|
| 173 |
+
// $category = Mage::getModel('catalog/category')->load($categoryId);
|
| 174 |
+
// $category_name = $category->getName();
|
| 175 |
+
// if ($category_name != $storeRootCategoryName)
|
| 176 |
+
// {
|
| 177 |
+
// if (!empty($categoryPath))
|
| 178 |
+
// {
|
| 179 |
+
// $categoryPath.= ' > ';
|
| 180 |
+
// }
|
| 181 |
+
// $categoryPath.= $category_name;
|
| 182 |
+
// }
|
| 183 |
+
// }
|
| 184 |
+
//
|
| 185 |
+
// $categoryPathsToEvaluate[$rootCategoryId]['path'] = $categoryPath;
|
| 186 |
+
// $categoryPathsToEvaluate[$rootCategoryId]['depth'] = $depth;
|
| 187 |
+
//
|
| 188 |
+
// if ($maxDepth < $depth)
|
| 189 |
+
// {
|
| 190 |
+
// $maxDepth = $depth;
|
| 191 |
+
// $categoryPathToUse = $categoryPath;
|
| 192 |
+
// }
|
| 193 |
+
// }
|
| 194 |
+
}
|
| 195 |
+
|
| 196 |
+
if ($isVariant && isset($variant))
|
| 197 |
+
{
|
| 198 |
+
$p['internal_variant_id'] = $variant->getId();
|
| 199 |
+
|
| 200 |
+
$variantOptionsTitle = array();
|
| 201 |
+
$variantPrice = $variantOptions['basePrice'];
|
| 202 |
+
|
| 203 |
+
$urlHashParts = array();
|
| 204 |
+
|
| 205 |
+
// Collect options applicable to the configurable product
|
| 206 |
+
if (isset($variantOptions['refactoredOptions'][$variant->getId()]))
|
| 207 |
+
{
|
| 208 |
+
foreach ($variantOptions['refactoredOptions'][$variant->getId()] as $attributeCode => $option) {
|
| 209 |
+
$variantOptionsTitle[] = $option['value'];
|
| 210 |
+
|
| 211 |
+
//add these configured attributes to the set of parent's attributes
|
| 212 |
+
$usefulAttributes[$attributeCode] = $option['value'];
|
| 213 |
+
|
| 214 |
+
$variantPrice += $option['price'];
|
| 215 |
+
|
| 216 |
+
$urlHashParts[] = $option['attributeId'].'='.$option['valueId'];
|
| 217 |
+
}
|
| 218 |
+
}
|
| 219 |
+
|
| 220 |
+
$variantOptionsTitle = implode(' / ', $variantOptionsTitle);
|
| 221 |
+
$title = $data['name'] . ' - ' . $variantOptionsTitle;
|
| 222 |
+
$sku = $variant->getData('sku');
|
| 223 |
+
$price = $variantPrice;
|
| 224 |
+
$variantImage = $variant->getImage();
|
| 225 |
+
|
| 226 |
+
if (!is_null($variantImage) && !empty($variantImage) && $variantImage!='no_selection')
|
| 227 |
+
{
|
| 228 |
+
$imageFile = $variant->getImage();
|
| 229 |
+
// $imageUrl = $p['image_url'] = Mage::getBaseUrl(Mage_Core_Model_Store::URL_TYPE_MEDIA).
|
| 230 |
+
// 'catalog/product/'.preg_replace('/^\//', '', $imageFile);
|
| 231 |
+
$imageUrl = $p['image_url'] = $variant->getMediaConfig()->getMediaUrl($imageFile);
|
| 232 |
+
$imageLocalPath = $variant->getMediaConfig()->getMediaPath($imageFile);
|
| 233 |
+
}
|
| 234 |
+
else
|
| 235 |
+
{
|
| 236 |
+
$imageFile = $product->getImage();
|
| 237 |
+
// $imageUrl = $p['image_url'] = Mage::getBaseUrl(Mage_Core_Model_Store::URL_TYPE_MEDIA).
|
| 238 |
+
// 'catalog/product/'.preg_replace('/^\//', '', $imageFile);
|
| 239 |
+
$imageUrl = $p['image_url'] = $product->getMediaConfig()->getMediaUrl($imageFile);
|
| 240 |
+
$imageLocalPath = $product->getMediaConfig()->getMediaPath($imageFile);
|
| 241 |
+
}
|
| 242 |
+
$productUrl = $product->getProductUrl().'#'.implode('&', $urlHashParts);
|
| 243 |
+
}
|
| 244 |
+
else
|
| 245 |
+
{
|
| 246 |
+
$p['internal_variant_id'] = '';
|
| 247 |
+
$title = $data['name'];
|
| 248 |
+
$sku = $data['sku'];
|
| 249 |
+
$price = $product->getPrice();
|
| 250 |
+
$imageFile = $product->getImage();
|
| 251 |
+
// $imageUrl = $p['image_url'] = Mage::getBaseUrl(Mage_Core_Model_Store::URL_TYPE_MEDIA).
|
| 252 |
+
// 'catalog/product/'.preg_replace('/^\//', '', $imageFile);
|
| 253 |
+
$imageUrl = $p['image_url'] = $product->getMediaConfig()->getMediaUrl($imageFile);
|
| 254 |
+
$imageLocalPath = $product->getMediaConfig()->getMediaPath($imageFile);
|
| 255 |
+
$productUrl = $product->getProductUrl();
|
| 256 |
+
}
|
| 257 |
+
|
| 258 |
+
//if we have previously captured this product and it hasn't changed, don't send through full payload
|
| 259 |
+
$wasPreviouslyCaptured = !is_null($lastUpdate) && isset($usefulAttributes['updated_at']) && strtotime($usefulAttributes['updated_at']) < $lastUpdate;
|
| 260 |
+
if ($wasPreviouslyCaptured)
|
| 261 |
+
{
|
| 262 |
+
$p['internal_id'] = $product->getId();
|
| 263 |
+
$p['internal_update_time'] = date("c", strtotime($usefulAttributes['updated_at']));
|
| 264 |
+
}
|
| 265 |
+
else
|
| 266 |
+
{
|
| 267 |
+
$p['category'] = $categoryPathToUse;
|
| 268 |
+
$p['title'] = $title;
|
| 269 |
+
$p['brand'] = ($brand=='No') ? (($manufacturer == 'No') ? '' : $manufacturer) : $brand;
|
| 270 |
+
$p['manufacturer'] = ($manufacturer=='No') ? $brand : $manufacturer;
|
| 271 |
+
$p['mpn'] = isset($data['model']) ? $data['model'] : $data['sku'];
|
| 272 |
+
$p['internal_id'] = $product->getId();
|
| 273 |
+
$p['description'] = $data['description'];
|
| 274 |
+
$p['short_description'] = $data['short_description'];
|
| 275 |
+
$p['weight'] = isset($data['weight']) ? $data['weight'] : 0.00;
|
| 276 |
+
$p['sku'] = $sku;
|
| 277 |
+
$p['gtin'] = '';
|
| 278 |
+
|
| 279 |
+
//$priceModel = $product->getPriceModel();
|
| 280 |
+
|
| 281 |
+
//do a currency conversion. if the currency is in base currency, it will be 1.0
|
| 282 |
+
$price = $price * $priceCurrencyRate;
|
| 283 |
+
$salePrice = $product->getSpecialPrice() * $priceCurrencyRate;
|
| 284 |
+
|
| 285 |
+
$p['currency'] = $priceCurrency;
|
| 286 |
+
$p['price'] = $price;// Mage::helper('checkout')->convertPrice($priceModel->getPrice($product), false);
|
| 287 |
+
$p['sale_price'] = '';
|
| 288 |
+
$p['sale_price_effective_date'] = '';
|
| 289 |
+
if ($salePrice != $p['price'])
|
| 290 |
+
{
|
| 291 |
+
$p['sale_price'] = $salePrice;
|
| 292 |
+
if ($product->getSpecialFromDate()!=null && $product->getSpecialToDate()!=null)
|
| 293 |
+
{
|
| 294 |
+
$p['sale_price_effective_date'] = date("c", strtotime($product->getSpecialFromDate())).'/'.date("c", strtotime($product->getSpecialToDate()));
|
| 295 |
+
}
|
| 296 |
+
}
|
| 297 |
+
|
| 298 |
+
$p['delivery_cost'] = 0.00;
|
| 299 |
+
$p['tax'] = 0.00;
|
| 300 |
+
$p['url'] = $productUrl;
|
| 301 |
+
$p['internal_update_time'] = isset($usefulAttributes['updated_at']) ? date("c", strtotime($usefulAttributes['updated_at'])) : '';
|
| 302 |
+
|
| 303 |
+
$p['image_url'] = $imageUrl;
|
| 304 |
+
if (file_exists($imageLocalPath))
|
| 305 |
+
{
|
| 306 |
+
$p['image_modified_time'] = date("c", filemtime($imageLocalPath));
|
| 307 |
+
}
|
| 308 |
+
$p['availability'] = ($stockItem->getIsInStock())?'in stock':'out of stock';
|
| 309 |
+
$p['quantity'] = $stockItem->getQty();
|
| 310 |
+
$p['condition'] = '';
|
| 311 |
+
$p['availability_date'] = '';
|
| 312 |
+
$p['attributes'] = $usefulAttributes;
|
| 313 |
+
$imageGallery = array();
|
| 314 |
+
foreach ($product->getMediaGalleryImages() as $image)
|
| 315 |
+
{
|
| 316 |
+
$galleryImage = array();
|
| 317 |
+
$galleryImage['url'] = $image['url'];
|
| 318 |
+
if (file_exists($image['path']))
|
| 319 |
+
{
|
| 320 |
+
$galleryImage['image_modified_time'] = date("c", filemtime($image['path']));
|
| 321 |
+
}
|
| 322 |
+
$imageGallery[] = $galleryImage;
|
| 323 |
+
}
|
| 324 |
+
$p['extra_images'] = $imageGallery;
|
| 325 |
+
}
|
| 326 |
+
|
| 327 |
+
return $p;
|
| 328 |
+
}
|
| 329 |
+
|
| 330 |
+
public function getItems($page = null, $numPerPage = 1000, $lastUpdate = null, $store = null, $priceCurrency = null, $priceCurrencyRate = null, $allowVariants = true)
|
| 331 |
+
{
|
| 332 |
+
/* @var Mage_Catalog_Model_Resource_Eav_Mysql4_Product_Collection $collection */
|
| 333 |
+
$collection = Mage::getModel('catalog/product')->getCollection()
|
| 334 |
+
->addAttributeToSelect('*')
|
| 335 |
+
->addAttributeToFilter('status', Mage_Catalog_Model_Product_Status::STATUS_ENABLED)
|
| 336 |
+
->addAttributeToFilter('visibility', Mage_Catalog_Model_Product_Visibility::VISIBILITY_BOTH);
|
| 337 |
+
|
| 338 |
+
/**
|
| 339 |
+
* For per-store system
|
| 340 |
+
*/
|
| 341 |
+
if (!is_null($store))
|
| 342 |
+
{
|
| 343 |
+
$collection->addStoreFilter(Mage::app()->getStore($store)->getId());
|
| 344 |
+
}
|
| 345 |
+
|
| 346 |
+
if (!is_null($page))
|
| 347 |
+
{
|
| 348 |
+
$offset = ($page * $numPerPage) - $numPerPage;
|
| 349 |
+
$productIds = $collection->getAllIds($numPerPage, $offset);
|
| 350 |
+
}
|
| 351 |
+
else
|
| 352 |
+
{
|
| 353 |
+
$productIds = $collection->getAllIds();
|
| 354 |
+
}
|
| 355 |
+
|
| 356 |
+
$products = array();
|
| 357 |
+
foreach ($productIds as $productId)
|
| 358 |
+
{
|
| 359 |
+
Mage::getModel('catalog/product')->reset();
|
| 360 |
+
/** @var Mage_Catalog_Model_Product $product */
|
| 361 |
+
$product = Mage::getModel('catalog/product')->load($productId);
|
| 362 |
+
|
| 363 |
+
/**
|
| 364 |
+
* Get variants, if there are any
|
| 365 |
+
* If there are variants that are visible in the catalog, we will skip them when we iterate normally
|
| 366 |
+
*/
|
| 367 |
+
|
| 368 |
+
//if we have a configurable product, capture the variants
|
| 369 |
+
if ($product->getTypeId() == 'configurable' && $allowVariants)
|
| 370 |
+
{
|
| 371 |
+
/** @var Mage_Catalog_Model_Product_Type_Configurable $configModel */
|
| 372 |
+
$configModel = Mage::getModel('catalog/product_type_configurable');
|
| 373 |
+
|
| 374 |
+
//$children = $configModel->getChildrenIds($product->getId());
|
| 375 |
+
$children = $configModel->getUsedProducts(null,$product);
|
| 376 |
+
|
| 377 |
+
if (count($children) > 0)
|
| 378 |
+
{
|
| 379 |
+
$parent = $product;
|
| 380 |
+
|
| 381 |
+
//get variant options
|
| 382 |
+
$layout = Mage::getSingleton('core/layout');
|
| 383 |
+
$block = $layout->createBlock('catalog/product_view_type_configurable');
|
| 384 |
+
$block->setProduct($parent);
|
| 385 |
+
$variantOptions = Mage::helper('core')->jsonDecode($block->getJsonConfig());
|
| 386 |
+
|
| 387 |
+
$variantAttributes = array();
|
| 388 |
+
foreach ($variantOptions['attributes'] as $attributeId => $options)
|
| 389 |
+
{
|
| 390 |
+
$code = $options['code'];
|
| 391 |
+
foreach ($options['options'] as $option)
|
| 392 |
+
{
|
| 393 |
+
$value = $option['label'];
|
| 394 |
+
$price = $option['price'];
|
| 395 |
+
$valueId = $option['id'];
|
| 396 |
+
foreach ($option['products'] as $productId)
|
| 397 |
+
{
|
| 398 |
+
//$children[] = $productId;
|
| 399 |
+
$variantAttributes[$productId][$code]['value'] = $value;
|
| 400 |
+
$variantAttributes[$productId][$code]['price'] = $price;
|
| 401 |
+
$variantAttributes[$productId][$code]['valueId'] = $valueId;
|
| 402 |
+
$variantAttributes[$productId][$code]['attributeId'] = $attributeId;
|
| 403 |
+
}
|
| 404 |
+
}
|
| 405 |
+
}
|
| 406 |
+
$variantOptions['refactoredOptions'] = $variantAttributes;
|
| 407 |
+
|
| 408 |
+
|
| 409 |
+
foreach ($children as $variant)
|
| 410 |
+
{
|
| 411 |
+
/** @var Mage_Catalog_Model_Product $variant */
|
| 412 |
+
//$variant = Mage::getModel('catalog/product')->load($variantId);
|
| 413 |
+
|
| 414 |
+
$productData = $this->getProductInfo($variant, $parent, $variantOptions, $lastUpdate, $priceCurrency, $priceCurrencyRate);
|
| 415 |
+
if (!empty($productData))
|
| 416 |
+
{
|
| 417 |
+
$products[] = $productData;
|
| 418 |
+
}
|
| 419 |
+
}
|
| 420 |
+
}
|
| 421 |
+
}
|
| 422 |
+
else
|
| 423 |
+
{
|
| 424 |
+
$productData = $this->getProductInfo($product, null, null, $lastUpdate, $priceCurrency, $priceCurrencyRate);
|
| 425 |
+
if (!empty($productData))
|
| 426 |
+
{
|
| 427 |
+
$products[] = $productData;
|
| 428 |
+
}
|
| 429 |
+
}
|
| 430 |
+
}
|
| 431 |
+
|
| 432 |
+
return $products;
|
| 433 |
+
}
|
| 434 |
+
|
| 435 |
+
public function getItem($itemId, $store = null, $priceCurrency = null, $priceCurrencyRate = null)
|
| 436 |
+
{
|
| 437 |
+
$products = array();
|
| 438 |
+
|
| 439 |
+
$product = Mage::getModel('catalog/product')->load($itemId);
|
| 440 |
+
|
| 441 |
+
$products[] = $this->getProductInfo($product, null, null, null, $priceCurrency, $priceCurrencyRate);
|
| 442 |
+
|
| 443 |
+
return $products;
|
| 444 |
+
}
|
| 445 |
}
|
package.xml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
| 1 |
<?xml version="1.0"?>
|
| 2 |
<package>
|
| 3 |
<name>shoppingfeeder</name>
|
| 4 |
-
<version>1.3.
|
| 5 |
<stability>stable</stability>
|
| 6 |
<license>GNU General Public License (GPL)</license>
|
| 7 |
<channel>community</channel>
|
|
@@ -16,11 +16,11 @@ Use ShoppingFeeder to import your Shopify product catalogue, export it to numero
|
|
| 16 |
Export to Google, Shopping.com, Nextag, kelkoo, PriceCheck, Shopmania, Fruugo and more!
|
| 17 |

|
| 18 |
To set up your ShoppingFeeder account and install this extension seamlessly, create an account at: <a href="http://www.shoppingfeeder.com/register">http://www.shoppingfeeder.com/register</a></description>
|
| 19 |
-
<notes>
|
| 20 |
<authors><author><name>ShoppingFeeder</name><user>shoppingfeeder</user><email>support@shoppingfeeder.com</email></author></authors>
|
| 21 |
-
<date>2015-
|
| 22 |
-
<time>
|
| 23 |
-
<contents><target name="mageetc"><dir name="modules"><file name="ShoppingFeeder_Service.xml" hash="90b374109c2d1281ddf527f24fa7d914"/></dir></target><target name="magecommunity"><dir name="ShoppingFeeder"><dir name="Service"><dir name="Block"><dir name="Adminhtml"><file name="Service.php" hash="e94d54bc342dc2941753ad635c0454a3"/></dir><file name="Service.php" hash="48874f0e80ce70686b81eb5380e9f498"/></dir><dir name="Controller"><file name="FrontAuth.php" hash="28ed32e1bf3250362911a26869f0e6d7"/></dir><dir name="Helper"><file name="Data.php" hash="17589bd08352e497806bef9884972300"/></dir><dir name="Model"><file name="Auth.php" hash="2cff17b0750ff70695b32524627b2aaf"/><file name="Observer.php" hash="fe8d86049e9fef786b13cec3b3a902ed"/><file name="Offers.php" hash="
|
| 24 |
<compatible/>
|
| 25 |
<dependencies><required><php><min>5.1.0</min><max>6.0.0</max></php></required></dependencies>
|
| 26 |
</package>
|
| 1 |
<?xml version="1.0"?>
|
| 2 |
<package>
|
| 3 |
<name>shoppingfeeder</name>
|
| 4 |
+
<version>1.3.11</version>
|
| 5 |
<stability>stable</stability>
|
| 6 |
<license>GNU General Public License (GPL)</license>
|
| 7 |
<channel>community</channel>
|
| 16 |
Export to Google, Shopping.com, Nextag, kelkoo, PriceCheck, Shopmania, Fruugo and more!
|
| 17 |

|
| 18 |
To set up your ShoppingFeeder account and install this extension seamlessly, create an account at: <a href="http://www.shoppingfeeder.com/register">http://www.shoppingfeeder.com/register</a></description>
|
| 19 |
+
<notes>Updated category fetch and UTC date format</notes>
|
| 20 |
<authors><author><name>ShoppingFeeder</name><user>shoppingfeeder</user><email>support@shoppingfeeder.com</email></author></authors>
|
| 21 |
+
<date>2015-10-10</date>
|
| 22 |
+
<time>18:52:15</time>
|
| 23 |
+
<contents><target name="mageetc"><dir name="modules"><file name="ShoppingFeeder_Service.xml" hash="90b374109c2d1281ddf527f24fa7d914"/></dir></target><target name="magecommunity"><dir name="ShoppingFeeder"><dir name="Service"><dir name="Block"><dir name="Adminhtml"><file name="Service.php" hash="e94d54bc342dc2941753ad635c0454a3"/></dir><file name="Service.php" hash="48874f0e80ce70686b81eb5380e9f498"/></dir><dir name="Controller"><file name="FrontAuth.php" hash="28ed32e1bf3250362911a26869f0e6d7"/></dir><dir name="Helper"><file name="Data.php" hash="17589bd08352e497806bef9884972300"/></dir><dir name="Model"><file name="Auth.php" hash="2cff17b0750ff70695b32524627b2aaf"/><file name="Observer.php" hash="fe8d86049e9fef786b13cec3b3a902ed"/><file name="Offers.php" hash="173b764ba70fd8fb86b6175b01b43717"/><file name="Orders.php" hash="cc3c9f38ae41c11ab7dda0bcb8dd001f"/></dir><dir name="controllers"><file name="AttributesController.php" hash="e937c492f770bc8381a003a080cf878b"/><file name="FeedController.php" hash="92b70af3a048ece99d262480c51aa862"/><file name="OrdersController.php" hash="e0dcf407e15ca212b43ee0015c918675"/><file name="StoresController.php" hash="a29fa0e97299ce764fd66360cbf6632a"/><file name="TestController.php" hash="5138a844cb7cbc8e792df664057bdf9b"/><file name="VersionController.php" hash="47c29bda780633f5b444bc9ed8223861"/></dir><dir name="data"><file name="cacert.pem" hash="380df856e8f789c1af97d0da9a243769"/></dir><dir name="etc"><file name="config.xml" hash="8a1f626994555fbb56b405aa0a7eb081"/><file name="system.xml" hash="9681c74fa8886143197932690616e2dd"/></dir></dir></dir></target></contents>
|
| 24 |
<compatible/>
|
| 25 |
<dependencies><required><php><min>5.1.0</min><max>6.0.0</max></php></required></dependencies>
|
| 26 |
</package>
|
