Version Notes
- Add default tax attribute.
- Add support multisites stores category mapping.
- Removed skipped field warnings
- Fix some bugs...etc.
- Delete old not relevant products
- Set is anchor category property to yes
- Sort imported categories by name
- Added method to set categories, subcategories without products to inactive
-Added imported products to all categories listed in import file for product including Default webshop's category
Download this release
Release Info
| Developer | IceShop |
| Extension | ice_import |
| Version | 1.4.0 |
| Comparing to | |
| See all releases | |
Code changes from version 1.3.0 to 1.4.0
app/code/community/Capacitywebsolutions/Importproduct/Model/Convert/Adapter/Product.php
CHANGED
|
@@ -1,887 +1,907 @@
|
|
| 1 |
-
<?php
|
| 2 |
-
/**
|
| 3 |
-
* Import Multiple Images during Product Import
|
| 4 |
-
* Copyright ? 2010 Web Design by Capacity Web Solutions Pvt. Ltd. All Rights Reserved.
|
| 5 |
-
* http://www.capacitywebsolutions.com
|
| 6 |
-
*/
|
| 7 |
-
|
| 8 |
-
|
| 9 |
-
class Capacitywebsolutions_Importproduct_Model_Convert_Adapter_Product extends Mage_Catalog_Model_Convert_Adapter_Product
|
| 10 |
-
{
|
| 11 |
-
protected $_categoryCache = array();
|
| 12 |
-
protected $_connRes = null;
|
| 13 |
-
protected $_tablePrefix = '';
|
| 14 |
-
|
| 15 |
-
public function __construct(){
|
| 16 |
-
|
| 17 |
-
$this->_connRes = Mage::getSingleton('core/resource')->getConnection('core_write');
|
| 18 |
-
$tablePrefix = (array)Mage::getConfig()->getTablePrefix();
|
| 19 |
-
if (!empty($tablePrefix)) {
|
| 20 |
-
$this->_tablePrefix = $tablePrefix[0];
|
| 21 |
-
}
|
| 22 |
-
|
| 23 |
-
}
|
| 24 |
-
|
| 25 |
-
public function saveRow(array $importData) {
|
| 26 |
-
|
| 27 |
-
// separate import data to eav & static
|
| 28 |
-
$sortedProductData = $this->_mapAttributes($importData);
|
| 29 |
-
$productData = $sortedProductData['productData'];
|
| 30 |
-
$iceimportAttributes = $sortedProductData['iceimportAttributes'];
|
| 31 |
-
$failedAttributes = $sortedProductData['failedAttributes'];
|
| 32 |
-
|
| 33 |
-
//Init session values to count total products and determine the last call of saveRow method
|
| 34 |
-
$session = Mage::getSingleton("core/session");
|
| 35 |
-
$import_total = $session->getData("import_total");
|
| 36 |
-
$counter = $session->getData("counter");
|
| 37 |
-
|
| 38 |
-
if (!isset($counter)) {
|
| 39 |
-
$session->setData("counter",1);
|
| 40 |
-
$counter = $session->getData("counter");
|
| 41 |
-
}
|
| 42 |
-
|
| 43 |
-
if (!isset($import_total)) {
|
| 44 |
-
$batchId = Mage::getSingleton('core/app')->getRequest()->getPost('batch_id', 0);
|
| 45 |
-
$batchModel = Mage::getModel('dataflow/batch')->load($batchId);
|
| 46 |
-
$batchImportModel = $batchModel->getBatchImportModel();
|
| 47 |
-
$importIds = $batchImportModel->getIdCollection();
|
| 48 |
-
$import_total = count($importIds);
|
| 49 |
-
$session->setData("import_total",(int)$import_total);
|
| 50 |
-
} else if(isset($counter) && isset($import_total)) {
|
| 51 |
-
if($counter < $import_total) {
|
| 52 |
-
$session->setData("counter",(int)++$counter);
|
| 53 |
-
}
|
| 54 |
-
}
|
| 55 |
-
|
| 56 |
-
// mark product ice_import generic
|
| 57 |
-
$productData['varchar']['is_iceimport'] =1;
|
| 58 |
-
|
| 59 |
-
// set website id
|
| 60 |
-
if (empty($iceimportAttributes['websites'])) {
|
| 61 |
-
$message = Mage::helper('catalog')->__('Skip import row, required field "%s" not defined', 'website');
|
| 62 |
-
Mage::throwException($message);
|
| 63 |
-
}
|
| 64 |
-
$website = Mage::app()->getWebsite(trim($iceimportAttributes['websites']));
|
| 65 |
-
$websiteId = $website->getId();
|
| 66 |
-
|
| 67 |
-
// set store id
|
| 68 |
-
if (empty($iceimportAttributes['store'])) {
|
| 69 |
-
if (!is_null($this->getBatchParams('store'))) {
|
| 70 |
-
$store = $this->getStoreById($this->getBatchParams('store'));
|
| 71 |
-
} else {
|
| 72 |
-
$message = Mage::helper('catalog')->__('Skip import row, required field "%s" not defined', 'store');
|
| 73 |
-
Mage::throwException($message);
|
| 74 |
-
}
|
| 75 |
-
}
|
| 76 |
-
$store = $this->getStoreByCode($iceimportAttributes['store']);
|
| 77 |
-
if ($store === false) {
|
| 78 |
-
$message = Mage::helper('catalog')->__('Skip import row, store "%s" not exists', $iceimportAttributes['store']);
|
| 79 |
-
Mage::throwException($message);
|
| 80 |
-
}
|
| 81 |
-
$storeId = $store->getId();
|
| 82 |
-
|
| 83 |
-
// set type
|
| 84 |
-
if (empty($iceimportAttributes['type'])) {
|
| 85 |
-
$message = Mage::helper('catalog')->__('Skip import row, required field "%s" not defined', 'type');
|
| 86 |
-
Mage::throwException($message);
|
| 87 |
-
}
|
| 88 |
-
$productType = $iceimportAttributes['type'];
|
| 89 |
-
|
| 90 |
-
// set attribute set
|
| 91 |
-
if (empty($iceimportAttributes['attribute_set'])) {
|
| 92 |
-
$message = Mage::helper('catalog')->__('Skip import row, required field "%s" not defined', 'attribute_set');
|
| 93 |
-
Mage::throwException($message);
|
| 94 |
-
}
|
| 95 |
-
$attribute_set = $iceimportAttributes['attribute_set'];
|
| 96 |
-
|
| 97 |
-
// set sku
|
| 98 |
-
if (empty($iceimportAttributes['sku'])) {
|
| 99 |
-
$message = Mage::helper('catalog')->__('Skip import row, required field "%s" not defined', 'sku');
|
| 100 |
-
Mage::throwException($message);
|
| 101 |
-
}
|
| 102 |
-
$sku = $iceimportAttributes['sku'];
|
| 103 |
-
|
| 104 |
-
// set category, unspsc, unspsc path
|
| 105 |
-
if (empty($iceimportAttributes['categories'])) {
|
| 106 |
-
$message = Mage::helper('catalog')->__('Skip import row, required field "%s" not defined', 'categories');
|
| 107 |
-
Mage::throwException($message);
|
| 108 |
-
}
|
| 109 |
-
$category = $iceimportAttributes['categories'];
|
| 110 |
-
if (empty($iceimportAttributes['unspsc'])) {
|
| 111 |
-
$message = Mage::helper('catalog')->__('Skip import. Category UNSPSC not defined in store');
|
| 112 |
-
Mage::throwException($message);
|
| 113 |
-
}
|
| 114 |
-
$unspsc = $iceimportAttributes['unspsc'];
|
| 115 |
-
if (empty($iceimportAttributes['unspsc_path'])) {
|
| 116 |
-
$message = Mage::helper('catalog')->__('Skip import. Category UNSPSC path not defined in store');
|
| 117 |
-
Mage::throwException($message);
|
| 118 |
-
}
|
| 119 |
-
$unspscPath = $iceimportAttributes['unspsc_path'];
|
| 120 |
-
|
| 121 |
-
// set in / out of stock
|
| 122 |
-
$isInStock = 0;
|
| 123 |
-
if (!empty($iceimportAttributes['is_in_stock'])) {
|
| 124 |
-
$isInStock = $iceimportAttributes['is_in_stock'];
|
| 125 |
-
}
|
| 126 |
-
|
| 127 |
-
// set qty
|
| 128 |
-
$qty = 0;
|
| 129 |
-
if (!empty($iceimportAttributes['qty'])) {
|
| 130 |
-
$qty = $iceimportAttributes['qty'];
|
| 131 |
-
}
|
| 132 |
-
|
| 133 |
-
// set price
|
| 134 |
-
$price = 0.00;
|
| 135 |
-
if (!empty($iceimportAttributes['price'])) {
|
| 136 |
-
$price = $iceimportAttributes['price'];
|
| 137 |
-
}
|
| 138 |
-
|
| 139 |
-
// set status value
|
| 140 |
-
$statusValue = (!empty($iceimportAttributes['status']) && $iceimportAttributes['status'] == 'Enabled') ? 1 : 0;
|
| 141 |
-
$productData['int']['status'] = $statusValue;
|
| 142 |
-
|
| 143 |
-
// set visibility value
|
| 144 |
-
$visibilityValue = 1;
|
| 145 |
-
if (!empty($iceimportAttributes['visibility'])) {
|
| 146 |
-
switch ($iceimportAttributes['visibility']) {
|
| 147 |
-
case 'Not Visible Individually':
|
| 148 |
-
$visibilityValue = 1;
|
| 149 |
-
break;
|
| 150 |
-
case 'Catalog':
|
| 151 |
-
$visibilityValue = 2;
|
| 152 |
-
break;
|
| 153 |
-
case 'Search':
|
| 154 |
-
$visibilityValue = 3;
|
| 155 |
-
break;
|
| 156 |
-
case 'Catalog, Search':
|
| 157 |
-
$visibilityValue = 4;
|
| 158 |
-
break;
|
| 159 |
-
}
|
| 160 |
-
}
|
| 161 |
-
$productData['int']['visibility'] = $visibilityValue;
|
| 162 |
-
|
| 163 |
-
// set product image
|
| 164 |
-
$productImage = '';
|
| 165 |
-
if (!empty($iceimportAttributes['image'])) {
|
| 166 |
-
$productImage = $iceimportAttributes['image'];
|
| 167 |
-
}
|
| 168 |
-
|
| 169 |
-
// init general attributes query
|
| 170 |
-
$initAttributes = "
|
| 171 |
-
SELECT @product_entity_type_id := `entity_type_id` FROM `" . $this->_tablePrefix . "eav_entity_type` WHERE
|
| 172 |
-
entity_type_code = 'catalog_product';
|
| 173 |
-
SELECT @category_entity_type_id := `entity_type_id` FROM `" . $this->_tablePrefix . "eav_entity_type` WHERE
|
| 174 |
-
entity_type_code = 'catalog_category';
|
| 175 |
-
SELECT @attribute_set_id := `entity_type_id` FROM `" . $this->_tablePrefix . "eav_entity_type` WHERE
|
| 176 |
-
entity_type_code = 'catalog_product';
|
| 177 |
-
SELECT @stock_id := `stock_id` FROM `" . $this->_tablePrefix . "cataloginventory_stock` WHERE
|
| 178 |
-
stock_name = 'Default';
|
| 179 |
-
SELECT @attribute_set_id := `attribute_set_id` FROM `" . $this->_tablePrefix . "eav_attribute_set`
|
| 180 |
-
WHERE attribute_set_name = :attribute_set AND entity_type_id =
|
| 181 |
-
@product_entity_type_id;
|
| 182 |
-
|
| 183 |
-
SELECT @price_id := `attribute_id` FROM `" . $this->_tablePrefix . "eav_attribute` WHERE
|
| 184 |
-
`attribute_code` = 'price' AND entity_type_id = @product_entity_type_id;
|
| 185 |
-
|
| 186 |
-
SELECT @unspcs_id := `attribute_id` FROM `" . $this->_tablePrefix . "eav_attribute` WHERE
|
| 187 |
-
`attribute_code` = 'unspsc' AND entity_type_id = @category_entity_type_id;
|
| 188 |
-
SELECT @category_name_id := `attribute_id` FROM `" . $this->_tablePrefix . "eav_attribute` WHERE
|
| 189 |
-
`attribute_code` = 'name' AND entity_type_id = @category_entity_type_id;
|
| 190 |
-
SELECT @category_active_id := `attribute_id` FROM `" . $this->_tablePrefix . "eav_attribute` WHERE
|
| 191 |
-
`attribute_code` = 'is_active' AND entity_type_id = @category_entity_type_id;
|
| 192 |
-
SELECT @include_nav_bar_id := `attribute_id` FROM `" . $this->_tablePrefix . "eav_attribute` WHERE
|
| 193 |
-
`attribute_code` = 'include_in_menu' AND entity_type_id = @category_entity_type_id;
|
| 194 |
-
SELECT @category_is_anchor_id := `attribute_id` FROM `" . $this->_tablePrefix . "eav_attribute` WHERE
|
| 195 |
-
`attribute_code` = 'is_anchor' AND entity_type_id = @category_entity_type_id;
|
| 196 |
-
";
|
| 197 |
-
|
| 198 |
-
|
| 199 |
-
$this->_connRes->query($initAttributes, array(':attribute_set' => $iceimportAttributes['attribute_set']));
|
| 200 |
-
|
| 201 |
-
$prodIdFetch = $this->_connRes->fetchRow("SELECT entity_id FROM `" . $this->_tablePrefix . "catalog_product_entity` WHERE sku = :sku limit 1" , array(
|
| 202 |
-
':sku' => $sku
|
| 203 |
-
));
|
| 204 |
-
$productId = $prodIdFetch['entity_id'];
|
| 205 |
-
|
| 206 |
-
if (!empty($productId)) {
|
| 207 |
-
// check import type (Import only price & qty or all product info)
|
| 208 |
-
if('import_price_stock' == Mage::getStoreConfig('importprod_root/importprod/import_only_prices_stock',
|
| 209 |
-
$storeId)) {
|
| 210 |
-
$this->_corePriceStock($websiteId, $productId, $price, $qty, $sku, $isInStock);
|
| 211 |
-
$query = $this->_connRes->query('INSERT INTO iceimport_imported_product_ids (product_id, product_sku) VALUES (:prod_id, :sku)',array(':prod_id' => $productId,':sku' => $sku));
|
| 212 |
-
return true;
|
| 213 |
-
}
|
| 214 |
-
} else {
|
| 215 |
-
$productId = null;
|
| 216 |
-
}
|
| 217 |
-
$defaulttaxConf = (int)Mage::getStoreConfig('importprod_root/importprod/default_tax',$storeId);
|
| 218 |
-
|
| 219 |
-
if( !empty($defaulttaxConf) ) {
|
| 220 |
-
$productData['int']['tax_class_id'] = $defaulttaxConf;
|
| 221 |
-
}
|
| 222 |
-
// get category id
|
| 223 |
-
$categoriesToActiveConf = Mage::getStoreConfig('importprod_root/importprod/category_active',
|
| 224 |
-
$storeId);
|
| 225 |
-
$
|
| 226 |
-
|
| 227 |
-
// get url key
|
| 228 |
-
$url = '';
|
| 229 |
-
if (!empty($productData['varchar']['name'])) {
|
| 230 |
-
$preUrl = explode(' ', strtolower($productData['varchar']['name']));
|
| 231 |
-
$url = implode('-', $preUrl) . '-' . $iceimportAttributes['store'];
|
| 232 |
-
}
|
| 233 |
-
$productData['varchar']['url_key'] = $url;
|
| 234 |
-
|
| 235 |
-
// if new product then ovewrride product id from null to id
|
| 236 |
-
$productId = $this->_coreSave($productData, $productId, $storeId, $sku, $
|
| 237 |
-
|
| 238 |
-
// add product image to queue
|
| 239 |
-
if (Mage::getStoreConfig('importprod_root/importprod/import_images')) {
|
| 240 |
-
$this->_addImageToQueue($productId, $productImage);
|
| 241 |
-
}
|
| 242 |
-
|
| 243 |
-
// add price & stock
|
| 244 |
-
$this->_corePriceStock($websiteId, $productId, $price, $qty, $sku, $isInStock);
|
| 245 |
-
|
| 246 |
-
$query = $this->_connRes->query('INSERT INTO iceimport_imported_product_ids (product_id, product_sku) VALUES (:prod_id, :sku)',array(':prod_id' => $productId,':sku' => $sku));
|
| 247 |
-
|
| 248 |
-
// Check if this is last imported product
|
| 249 |
-
// Do category sort and set categories without products to inactive
|
| 250 |
-
if (isset($counter) && isset($import_total) && ($counter==$import_total)) {
|
| 251 |
-
$catCollection = Mage::getModel('catalog/category')
|
| 252 |
-
->getCollection()
|
| 253 |
-
->addAttributeToSort('name', 'ASC');
|
| 254 |
-
$position = 1;
|
| 255 |
-
|
| 256 |
-
foreach ($catCollection as $category) {
|
| 257 |
-
|
| 258 |
-
$query = $this->_connRes->query("UPDATE `". $this->_tablePrefix . "catalog_category_entity` SET position = :position WHERE entity_id = :cat_id ", array(
|
| 259 |
-
':position'=>$position,
|
| 260 |
-
':cat_id'=> $category->getId()
|
| 261 |
-
));
|
| 262 |
-
|
| 263 |
-
$query = "SELECT COUNT(*) FROM `" . $this->_tablePrefix . "catalog_category_product` WHERE category_id = :cat_id ";
|
| 264 |
-
$cat_products = $this->_connRes->fetchRow($query,array(
|
| 265 |
-
':cat_id'=> $category->getId()
|
| 266 |
-
));
|
| 267 |
-
|
| 268 |
-
if ($cat_products['COUNT(*)'] == 0) {
|
| 269 |
-
$query = "SELECT `entity_id` FROM `" . $this->_tablePrefix . "catalog_category_entity` WHERE parent_id = :cat_id";
|
| 270 |
-
$child_cat = $this->_connRes->fetchAll($query,array(
|
| 271 |
-
':cat_id'=> $category->getId()
|
| 272 |
-
));
|
| 273 |
-
|
| 274 |
-
if (isset($child_cat) && count($child_cat) > 0) {
|
| 275 |
-
//Count child categories products and set them to inactive if they have no
|
| 276 |
-
$this->CountChildProd($child_cat);
|
| 277 |
-
} else {
|
| 278 |
-
$this->_connRes->query("UPDATE `" . $this->_tablePrefix . "catalog_category_entity_int`
|
| 279 |
-
SET `value` = 0 WHERE `attribute_id` = @category_active_id AND entity_id = :cat_id",array(
|
| 280 |
-
':cat_id'=> $category->getId()
|
| 281 |
-
));
|
| 282 |
-
}
|
| 283 |
-
}
|
| 284 |
-
$position++;
|
| 285 |
-
}
|
| 286 |
-
|
| 287 |
-
$session->unsetData('import_total');
|
| 288 |
-
$session->unsetData('counter');
|
| 289 |
-
}
|
| 290 |
-
|
| 291 |
-
return true;
|
| 292 |
-
}
|
| 293 |
-
|
| 294 |
-
protected function _coreSave(array $entityData, $productId = null, $storeId = 0, $sku, $
|
| 295 |
-
if ($productId === null) {
|
| 296 |
-
// add product to store
|
| 297 |
-
$coreSaveProduct = "INSERT INTO `" . $this->_tablePrefix . "catalog_product_entity` (`entity_type_id`, `attribute_set_id`, `type_id`, `sku`, `created_at`) VALUES
|
| 298 |
-
(@product_entity_type_id, @attribute_set_id, 'simple', :sku, NOW());
|
| 299 |
-
SELECT @product_id := LAST_INSERT_ID();
|
| 300 |
-
";
|
| 301 |
-
$this->_connRes->query($coreSaveProduct, array(':sku' => $sku));
|
| 302 |
-
// get product ID
|
| 303 |
-
$prodFetch = $this->_connRes->fetchRow('SELECT @product_id AS prod_id');
|
| 304 |
-
$productId = $prodFetch['prod_id'];
|
| 305 |
-
} else {
|
| 306 |
-
$coreSaveSQL .= "SELECT @product_id := " . (int)$productId . "; ";
|
| 307 |
-
}
|
| 308 |
-
|
| 309 |
-
$bindArray[':store_id'] = $storeId;
|
| 310 |
-
foreach ($entityData as $type => $typeAttributes) {
|
| 311 |
-
if ($type != 'spec') {
|
| 312 |
-
$tailCoreSaveSQL = '';
|
| 313 |
-
$attributesInit = '';
|
| 314 |
-
if (!empty($typeAttributes)) {
|
| 315 |
-
$tailCoreSaveSQL .= "
|
| 316 |
-
INSERT INTO `" . $this->_tablePrefix . "catalog_product_entity_" . $type . "` (`entity_type_id`, `attribute_id`, `store_id`, `entity_id`, `value`) VALUES ";
|
| 317 |
-
foreach ($typeAttributes as $attribute => $value) {
|
| 318 |
-
$attributesInit .= "
|
| 319 |
-
SELECT @" . $attribute . "_id := `attribute_id` FROM `" . $this->_tablePrefix . "eav_attribute` WHERE
|
| 320 |
-
`attribute_code` = '" . $attribute . "' AND entity_type_id = @product_entity_type_id;
|
| 321 |
-
";
|
| 322 |
-
$tailCoreSaveSQL .= "
|
| 323 |
-
(@product_entity_type_id, @" . $attribute . "_id, 0, @product_id, :" . $attribute . " ),
|
| 324 |
-
(@product_entity_type_id, @" . $attribute . "_id, :store_id, @product_id, :" . $attribute . " ), ";
|
| 325 |
-
$bindArray[':' . $attribute] = $value;
|
| 326 |
-
}
|
| 327 |
-
$tailCoreSaveSQL = substr($tailCoreSaveSQL, 0, -2);
|
| 328 |
-
$tailCoreSaveSQL .= "
|
| 329 |
-
ON DUPLICATE KEY UPDATE
|
| 330 |
-
`value` = VALUES (`value`);
|
| 331 |
-
";
|
| 332 |
-
}
|
| 333 |
-
$coreSaveSQL .= $attributesInit . $tailCoreSaveSQL;
|
| 334 |
-
} else {
|
| 335 |
-
foreach ($typeAttributes as $attribute => $attributeData) {
|
| 336 |
-
$prod_id_field = $attributeData['prod_id_field'];
|
| 337 |
-
$table = $attributeData['table'];
|
| 338 |
-
$field = $attributeData['field'];
|
| 339 |
-
$value = $attributeData['value'];
|
| 340 |
-
if (!empty($table) && !empty($field)) {
|
| 341 |
-
$coreSaveSQL .= "
|
| 342 |
-
UPDATE `" . $this->_tablePrefix . $table . "` SET `" . $field . "` = :" . $attribute . " WHERE `" . $prod_id_field . "` = @product_id;
|
| 343 |
-
";
|
| 344 |
-
$bindArray[':' . $attribute] = $value;
|
| 345 |
-
}
|
| 346 |
-
}
|
| 347 |
-
}
|
| 348 |
-
}
|
| 349 |
-
|
| 350 |
-
|
| 351 |
-
|
| 352 |
-
|
| 353 |
-
|
| 354 |
-
|
| 355 |
-
|
| 356 |
-
|
| 357 |
-
|
| 358 |
-
|
| 359 |
-
|
| 360 |
-
|
| 361 |
-
|
| 362 |
-
|
| 363 |
-
|
| 364 |
-
|
| 365 |
-
|
| 366 |
-
|
| 367 |
-
$
|
| 368 |
-
Mage::
|
| 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 |
-
$this->
|
| 406 |
-
|
| 407 |
-
|
| 408 |
-
|
| 409 |
-
|
| 410 |
-
|
| 411 |
-
)
|
| 412 |
-
|
| 413 |
-
|
| 414 |
-
|
| 415 |
-
|
| 416 |
-
|
| 417 |
-
|
| 418 |
-
|
| 419 |
-
|
| 420 |
-
|
| 421 |
-
|
| 422 |
-
|
| 423 |
-
|
| 424 |
-
|
| 425 |
-
|
| 426 |
-
|
| 427 |
-
|
| 428 |
-
|
| 429 |
-
|
| 430 |
-
|
| 431 |
-
|
| 432 |
-
|
| 433 |
-
if ($
|
| 434 |
-
|
| 435 |
-
|
| 436 |
-
|
| 437 |
-
|
| 438 |
-
|
| 439 |
-
|
| 440 |
-
|
| 441 |
-
|
| 442 |
-
|
| 443 |
-
|
| 444 |
-
|
| 445 |
-
|
| 446 |
-
|
| 447 |
-
|
| 448 |
-
|
| 449 |
-
|
| 450 |
-
|
| 451 |
-
|
| 452 |
-
|
| 453 |
-
|
| 454 |
-
|
| 455 |
-
|
| 456 |
-
|
| 457 |
-
|
| 458 |
-
|
| 459 |
-
|
| 460 |
-
|
| 461 |
-
|
| 462 |
-
|
| 463 |
-
|
| 464 |
-
|
| 465 |
-
|
| 466 |
-
|
| 467 |
-
|
| 468 |
-
|
| 469 |
-
|
| 470 |
-
|
| 471 |
-
|
| 472 |
-
|
| 473 |
-
|
| 474 |
-
|
| 475 |
-
|
| 476 |
-
|
| 477 |
-
|
| 478 |
-
|
| 479 |
-
|
| 480 |
-
|
| 481 |
-
|
| 482 |
-
|
| 483 |
-
|
| 484 |
-
|
| 485 |
-
|
| 486 |
-
|
| 487 |
-
|
| 488 |
-
|
| 489 |
-
|
| 490 |
-
|
| 491 |
-
|
| 492 |
-
|
| 493 |
-
|
| 494 |
-
|
| 495 |
-
|
| 496 |
-
|
| 497 |
-
|
| 498 |
-
|
| 499 |
-
|
| 500 |
-
|
| 501 |
-
|
| 502 |
-
|
| 503 |
-
|
| 504 |
-
|
| 505 |
-
|
| 506 |
-
|
| 507 |
-
|
| 508 |
-
|
| 509 |
-
|
| 510 |
-
|
| 511 |
-
|
| 512 |
-
|
| 513 |
-
|
| 514 |
-
|
| 515 |
-
|
| 516 |
-
|
| 517 |
-
|
| 518 |
-
|
| 519 |
-
|
| 520 |
-
|
| 521 |
-
|
| 522 |
-
|
| 523 |
-
|
| 524 |
-
|
| 525 |
-
|
| 526 |
-
|
| 527 |
-
|
| 528 |
-
|
| 529 |
-
$
|
| 530 |
-
|
| 531 |
-
|
| 532 |
-
|
| 533 |
-
|
| 534 |
-
|
| 535 |
-
|
| 536 |
-
|
| 537 |
-
|
| 538 |
-
|
| 539 |
-
|
| 540 |
-
|
| 541 |
-
|
| 542 |
-
|
| 543 |
-
|
| 544 |
-
|
| 545 |
-
|
| 546 |
-
|
| 547 |
-
|
| 548 |
-
|
| 549 |
-
|
| 550 |
-
|
| 551 |
-
}
|
| 552 |
-
|
| 553 |
-
|
| 554 |
-
|
| 555 |
-
|
| 556 |
-
|
| 557 |
-
|
| 558 |
-
|
| 559 |
-
|
| 560 |
-
|
| 561 |
-
$
|
| 562 |
-
|
| 563 |
-
|
| 564 |
-
|
| 565 |
-
|
| 566 |
-
|
| 567 |
-
|
| 568 |
-
|
| 569 |
-
$
|
| 570 |
-
|
| 571 |
-
|
| 572 |
-
|
| 573 |
-
|
| 574 |
-
|
| 575 |
-
|
| 576 |
-
|
| 577 |
-
|
| 578 |
-
|
| 579 |
-
|
| 580 |
-
|
| 581 |
-
|
| 582 |
-
|
| 583 |
-
|
| 584 |
-
|
| 585 |
-
|
| 586 |
-
|
| 587 |
-
|
| 588 |
-
|
| 589 |
-
|
| 590 |
-
|
| 591 |
-
|
| 592 |
-
|
| 593 |
-
|
| 594 |
-
|
| 595 |
-
|
| 596 |
-
|
| 597 |
-
|
| 598 |
-
|
| 599 |
-
|
| 600 |
-
(@category_entity_type_id,
|
| 601 |
-
|
| 602 |
-
|
| 603 |
-
|
| 604 |
-
|
| 605 |
-
|
| 606 |
-
|
| 607 |
-
|
| 608 |
-
|
| 609 |
-
|
| 610 |
-
|
| 611 |
-
|
| 612 |
-
|
| 613 |
-
|
| 614 |
-
|
| 615 |
-
|
| 616 |
-
|
| 617 |
-
|
| 618 |
-
|
| 619 |
-
|
| 620 |
-
|
| 621 |
-
|
| 622 |
-
|
| 623 |
-
|
| 624 |
-
|
| 625 |
-
|
| 626 |
-
|
| 627 |
-
|
| 628 |
-
|
| 629 |
-
|
| 630 |
-
|
| 631 |
-
|
| 632 |
-
|
| 633 |
-
|
| 634 |
-
|
| 635 |
-
|
| 636 |
-
|
| 637 |
-
|
| 638 |
-
|
| 639 |
-
|
| 640 |
-
|
| 641 |
-
|
| 642 |
-
|
| 643 |
-
//
|
| 644 |
-
if ($attribute == '
|
| 645 |
-
$attribute == '
|
| 646 |
-
$attribute == '
|
| 647 |
-
$attribute == '
|
| 648 |
-
$attribute == '
|
| 649 |
-
$attribute == '
|
| 650 |
-
$attribute == '
|
| 651 |
-
$attribute == '
|
| 652 |
-
$attribute == '
|
| 653 |
-
$attribute == '
|
| 654 |
-
$attribute == '
|
| 655 |
-
$attribute == '
|
| 656 |
-
$attribute == '
|
| 657 |
-
$attribute == '
|
| 658 |
-
|
| 659 |
-
|
| 660 |
-
|
| 661 |
-
|
| 662 |
-
|
| 663 |
-
|
| 664 |
-
|
| 665 |
-
$attribute == '
|
| 666 |
-
$attribute == '
|
| 667 |
-
$attribute == '
|
| 668 |
-
$attribute == '
|
| 669 |
-
$attribute == '
|
| 670 |
-
$attribute == '
|
| 671 |
-
$attribute == '
|
| 672 |
-
$attribute == '
|
| 673 |
-
$attribute == '
|
| 674 |
-
$attribute == '
|
| 675 |
-
$attribute == '
|
| 676 |
-
$attribute == '
|
| 677 |
-
$attribute == '
|
| 678 |
-
$attribute == '
|
| 679 |
-
|
| 680 |
-
|
| 681 |
-
|
| 682 |
-
|
| 683 |
-
|
| 684 |
-
|
| 685 |
-
|
| 686 |
-
|
| 687 |
-
|
| 688 |
-
|
| 689 |
-
|
| 690 |
-
|
| 691 |
-
|
| 692 |
-
|
| 693 |
-
|
| 694 |
-
|
| 695 |
-
|
| 696 |
-
|
| 697 |
-
|
| 698 |
-
|
| 699 |
-
|
| 700 |
-
|
| 701 |
-
|
| 702 |
-
|
| 703 |
-
|
| 704 |
-
|
| 705 |
-
|
| 706 |
-
|
| 707 |
-
|
| 708 |
-
|
| 709 |
-
|
| 710 |
-
|
| 711 |
-
|
| 712 |
-
|
| 713 |
-
|
| 714 |
-
|
| 715 |
-
}
|
| 716 |
-
}
|
| 717 |
-
|
| 718 |
-
|
| 719 |
-
|
| 720 |
-
|
| 721 |
-
|
| 722 |
-
|
| 723 |
-
|
| 724 |
-
|
| 725 |
-
|
| 726 |
-
|
| 727 |
-
|
| 728 |
-
)
|
| 729 |
-
|
| 730 |
-
|
| 731 |
-
|
| 732 |
-
|
| 733 |
-
|
| 734 |
-
|
| 735 |
-
|
| 736 |
-
|
| 737 |
-
|
| 738 |
-
|
| 739 |
-
|
| 740 |
-
|
| 741 |
-
|
| 742 |
-
|
| 743 |
-
|
| 744 |
-
|
| 745 |
-
|
| 746 |
-
|
| 747 |
-
|
| 748 |
-
|
| 749 |
-
|
| 750 |
-
|
| 751 |
-
|
| 752 |
-
|
| 753 |
-
|
| 754 |
-
|
| 755 |
-
'
|
| 756 |
-
'
|
| 757 |
-
'
|
| 758 |
-
'
|
| 759 |
-
|
| 760 |
-
|
| 761 |
-
'
|
| 762 |
-
'
|
| 763 |
-
'
|
| 764 |
-
'
|
| 765 |
-
'
|
| 766 |
-
|
| 767 |
-
|
| 768 |
-
|
| 769 |
-
'
|
| 770 |
-
'
|
| 771 |
-
'
|
| 772 |
-
'
|
| 773 |
-
|
| 774 |
-
|
| 775 |
-
'
|
| 776 |
-
'
|
| 777 |
-
'
|
| 778 |
-
'
|
| 779 |
-
|
| 780 |
-
|
| 781 |
-
|
| 782 |
-
|
| 783 |
-
'
|
| 784 |
-
|
| 785 |
-
|
| 786 |
-
|
| 787 |
-
|
| 788 |
-
'
|
| 789 |
-
|
| 790 |
-
|
| 791 |
-
|
| 792 |
-
|
| 793 |
-
|
| 794 |
-
|
| 795 |
-
|
| 796 |
-
|
| 797 |
-
|
| 798 |
-
'
|
| 799 |
-
|
| 800 |
-
|
| 801 |
-
|
| 802 |
-
|
| 803 |
-
'
|
| 804 |
-
'prod_id_field' => 'product_id',
|
| 805 |
-
'table' => 'cataloginventory_stock_item',
|
| 806 |
-
'field' => '
|
| 807 |
-
),
|
| 808 |
-
'
|
| 809 |
-
'prod_id_field' => 'product_id',
|
| 810 |
-
'table' => 'cataloginventory_stock_item',
|
| 811 |
-
'field' => '
|
| 812 |
-
),
|
| 813 |
-
'
|
| 814 |
-
'prod_id_field' => 'product_id',
|
| 815 |
-
'table' => 'cataloginventory_stock_item',
|
| 816 |
-
'field' => '
|
| 817 |
-
),
|
| 818 |
-
'
|
| 819 |
-
'prod_id_field' => 'product_id',
|
| 820 |
-
'table' => 'cataloginventory_stock_item',
|
| 821 |
-
'field' => '
|
| 822 |
-
),
|
| 823 |
-
'
|
| 824 |
-
'prod_id_field' => 'product_id',
|
| 825 |
-
'table' => 'cataloginventory_stock_item',
|
| 826 |
-
'field' => '
|
| 827 |
-
),
|
| 828 |
-
'
|
| 829 |
-
'prod_id_field' => 'product_id',
|
| 830 |
-
'table' => 'cataloginventory_stock_item',
|
| 831 |
-
'field' => '
|
| 832 |
-
),
|
| 833 |
-
'
|
| 834 |
-
'prod_id_field' => 'product_id',
|
| 835 |
-
'table' => 'cataloginventory_stock_item',
|
| 836 |
-
'field' => '
|
| 837 |
-
),
|
| 838 |
-
'
|
| 839 |
-
'prod_id_field' => 'product_id',
|
| 840 |
-
'table' => 'cataloginventory_stock_item',
|
| 841 |
-
'field' => '
|
| 842 |
-
),
|
| 843 |
-
'
|
| 844 |
-
'prod_id_field' => '
|
| 845 |
-
'table' => '
|
| 846 |
-
'field' => '
|
| 847 |
-
),
|
| 848 |
-
'
|
| 849 |
-
'prod_id_field' => 'product_id',
|
| 850 |
-
'table' => 'cataloginventory_stock_item',
|
| 851 |
-
'field' => '
|
| 852 |
-
),
|
| 853 |
-
'
|
| 854 |
-
'prod_id_field' => '
|
| 855 |
-
'table' => '
|
| 856 |
-
'field' => '
|
| 857 |
-
)
|
| 858 |
-
|
| 859 |
-
|
| 860 |
-
|
| 861 |
-
|
| 862 |
-
|
| 863 |
-
|
| 864 |
-
|
| 865 |
-
|
| 866 |
-
|
| 867 |
-
|
| 868 |
-
|
| 869 |
-
|
| 870 |
-
|
| 871 |
-
|
| 872 |
-
|
| 873 |
-
|
| 874 |
-
|
| 875 |
-
|
| 876 |
-
|
| 877 |
-
|
| 878 |
-
|
| 879 |
-
|
| 880 |
-
|
| 881 |
-
|
| 882 |
-
|
| 883 |
-
|
| 884 |
-
|
| 885 |
-
|
| 886 |
-
|
| 887 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
<?php
|
| 2 |
+
/**
|
| 3 |
+
* Import Multiple Images during Product Import
|
| 4 |
+
* Copyright ? 2010 Web Design by Capacity Web Solutions Pvt. Ltd. All Rights Reserved.
|
| 5 |
+
* http://www.capacitywebsolutions.com
|
| 6 |
+
*/
|
| 7 |
+
|
| 8 |
+
|
| 9 |
+
class Capacitywebsolutions_Importproduct_Model_Convert_Adapter_Product extends Mage_Catalog_Model_Convert_Adapter_Product
|
| 10 |
+
{
|
| 11 |
+
protected $_categoryCache = array();
|
| 12 |
+
protected $_connRes = null;
|
| 13 |
+
protected $_tablePrefix = '';
|
| 14 |
+
|
| 15 |
+
public function __construct(){
|
| 16 |
+
|
| 17 |
+
$this->_connRes = Mage::getSingleton('core/resource')->getConnection('core_write');
|
| 18 |
+
$tablePrefix = (array)Mage::getConfig()->getTablePrefix();
|
| 19 |
+
if (!empty($tablePrefix)) {
|
| 20 |
+
$this->_tablePrefix = $tablePrefix[0];
|
| 21 |
+
}
|
| 22 |
+
|
| 23 |
+
}
|
| 24 |
+
|
| 25 |
+
public function saveRow(array $importData) {
|
| 26 |
+
|
| 27 |
+
// separate import data to eav & static
|
| 28 |
+
$sortedProductData = $this->_mapAttributes($importData);
|
| 29 |
+
$productData = $sortedProductData['productData'];
|
| 30 |
+
$iceimportAttributes = $sortedProductData['iceimportAttributes'];
|
| 31 |
+
$failedAttributes = $sortedProductData['failedAttributes'];
|
| 32 |
+
|
| 33 |
+
//Init session values to count total products and determine the last call of saveRow method
|
| 34 |
+
$session = Mage::getSingleton("core/session");
|
| 35 |
+
$import_total = $session->getData("import_total");
|
| 36 |
+
$counter = $session->getData("counter");
|
| 37 |
+
|
| 38 |
+
if (!isset($counter)) {
|
| 39 |
+
$session->setData("counter",1);
|
| 40 |
+
$counter = $session->getData("counter");
|
| 41 |
+
}
|
| 42 |
+
|
| 43 |
+
if (!isset($import_total)) {
|
| 44 |
+
$batchId = Mage::getSingleton('core/app')->getRequest()->getPost('batch_id', 0);
|
| 45 |
+
$batchModel = Mage::getModel('dataflow/batch')->load($batchId);
|
| 46 |
+
$batchImportModel = $batchModel->getBatchImportModel();
|
| 47 |
+
$importIds = $batchImportModel->getIdCollection();
|
| 48 |
+
$import_total = count($importIds);
|
| 49 |
+
$session->setData("import_total",(int)$import_total);
|
| 50 |
+
} else if(isset($counter) && isset($import_total)) {
|
| 51 |
+
if($counter < $import_total) {
|
| 52 |
+
$session->setData("counter",(int)++$counter);
|
| 53 |
+
}
|
| 54 |
+
}
|
| 55 |
+
|
| 56 |
+
// mark product ice_import generic
|
| 57 |
+
$productData['varchar']['is_iceimport'] =1;
|
| 58 |
+
|
| 59 |
+
// set website id
|
| 60 |
+
if (empty($iceimportAttributes['websites'])) {
|
| 61 |
+
$message = Mage::helper('catalog')->__('Skip import row, required field "%s" not defined', 'website');
|
| 62 |
+
Mage::throwException($message);
|
| 63 |
+
}
|
| 64 |
+
$website = Mage::app()->getWebsite(trim($iceimportAttributes['websites']));
|
| 65 |
+
$websiteId = $website->getId();
|
| 66 |
+
|
| 67 |
+
// set store id
|
| 68 |
+
if (empty($iceimportAttributes['store'])) {
|
| 69 |
+
if (!is_null($this->getBatchParams('store'))) {
|
| 70 |
+
$store = $this->getStoreById($this->getBatchParams('store'));
|
| 71 |
+
} else {
|
| 72 |
+
$message = Mage::helper('catalog')->__('Skip import row, required field "%s" not defined', 'store');
|
| 73 |
+
Mage::throwException($message);
|
| 74 |
+
}
|
| 75 |
+
}
|
| 76 |
+
$store = $this->getStoreByCode($iceimportAttributes['store']);
|
| 77 |
+
if ($store === false) {
|
| 78 |
+
$message = Mage::helper('catalog')->__('Skip import row, store "%s" not exists', $iceimportAttributes['store']);
|
| 79 |
+
Mage::throwException($message);
|
| 80 |
+
}
|
| 81 |
+
$storeId = $store->getId();
|
| 82 |
+
|
| 83 |
+
// set type
|
| 84 |
+
if (empty($iceimportAttributes['type'])) {
|
| 85 |
+
$message = Mage::helper('catalog')->__('Skip import row, required field "%s" not defined', 'type');
|
| 86 |
+
Mage::throwException($message);
|
| 87 |
+
}
|
| 88 |
+
$productType = $iceimportAttributes['type'];
|
| 89 |
+
|
| 90 |
+
// set attribute set
|
| 91 |
+
if (empty($iceimportAttributes['attribute_set'])) {
|
| 92 |
+
$message = Mage::helper('catalog')->__('Skip import row, required field "%s" not defined', 'attribute_set');
|
| 93 |
+
Mage::throwException($message);
|
| 94 |
+
}
|
| 95 |
+
$attribute_set = $iceimportAttributes['attribute_set'];
|
| 96 |
+
|
| 97 |
+
// set sku
|
| 98 |
+
if (empty($iceimportAttributes['sku'])) {
|
| 99 |
+
$message = Mage::helper('catalog')->__('Skip import row, required field "%s" not defined', 'sku');
|
| 100 |
+
Mage::throwException($message);
|
| 101 |
+
}
|
| 102 |
+
$sku = $iceimportAttributes['sku'];
|
| 103 |
+
|
| 104 |
+
// set category, unspsc, unspsc path
|
| 105 |
+
if (empty($iceimportAttributes['categories'])) {
|
| 106 |
+
$message = Mage::helper('catalog')->__('Skip import row, required field "%s" not defined', 'categories');
|
| 107 |
+
Mage::throwException($message);
|
| 108 |
+
}
|
| 109 |
+
$category = $iceimportAttributes['categories'];
|
| 110 |
+
if (empty($iceimportAttributes['unspsc'])) {
|
| 111 |
+
$message = Mage::helper('catalog')->__('Skip import. Category UNSPSC not defined in store');
|
| 112 |
+
Mage::throwException($message);
|
| 113 |
+
}
|
| 114 |
+
$unspsc = $iceimportAttributes['unspsc'];
|
| 115 |
+
if (empty($iceimportAttributes['unspsc_path'])) {
|
| 116 |
+
$message = Mage::helper('catalog')->__('Skip import. Category UNSPSC path not defined in store');
|
| 117 |
+
Mage::throwException($message);
|
| 118 |
+
}
|
| 119 |
+
$unspscPath = $iceimportAttributes['unspsc_path'];
|
| 120 |
+
|
| 121 |
+
// set in / out of stock
|
| 122 |
+
$isInStock = 0;
|
| 123 |
+
if (!empty($iceimportAttributes['is_in_stock'])) {
|
| 124 |
+
$isInStock = $iceimportAttributes['is_in_stock'];
|
| 125 |
+
}
|
| 126 |
+
|
| 127 |
+
// set qty
|
| 128 |
+
$qty = 0;
|
| 129 |
+
if (!empty($iceimportAttributes['qty'])) {
|
| 130 |
+
$qty = $iceimportAttributes['qty'];
|
| 131 |
+
}
|
| 132 |
+
|
| 133 |
+
// set price
|
| 134 |
+
$price = 0.00;
|
| 135 |
+
if (!empty($iceimportAttributes['price'])) {
|
| 136 |
+
$price = $iceimportAttributes['price'];
|
| 137 |
+
}
|
| 138 |
+
|
| 139 |
+
// set status value
|
| 140 |
+
$statusValue = (!empty($iceimportAttributes['status']) && $iceimportAttributes['status'] == 'Enabled') ? 1 : 0;
|
| 141 |
+
$productData['int']['status'] = $statusValue;
|
| 142 |
+
|
| 143 |
+
// set visibility value
|
| 144 |
+
$visibilityValue = 1;
|
| 145 |
+
if (!empty($iceimportAttributes['visibility'])) {
|
| 146 |
+
switch ($iceimportAttributes['visibility']) {
|
| 147 |
+
case 'Not Visible Individually':
|
| 148 |
+
$visibilityValue = 1;
|
| 149 |
+
break;
|
| 150 |
+
case 'Catalog':
|
| 151 |
+
$visibilityValue = 2;
|
| 152 |
+
break;
|
| 153 |
+
case 'Search':
|
| 154 |
+
$visibilityValue = 3;
|
| 155 |
+
break;
|
| 156 |
+
case 'Catalog, Search':
|
| 157 |
+
$visibilityValue = 4;
|
| 158 |
+
break;
|
| 159 |
+
}
|
| 160 |
+
}
|
| 161 |
+
$productData['int']['visibility'] = $visibilityValue;
|
| 162 |
+
|
| 163 |
+
// set product image
|
| 164 |
+
$productImage = '';
|
| 165 |
+
if (!empty($iceimportAttributes['image'])) {
|
| 166 |
+
$productImage = $iceimportAttributes['image'];
|
| 167 |
+
}
|
| 168 |
+
|
| 169 |
+
// init general attributes query
|
| 170 |
+
$initAttributes = "
|
| 171 |
+
SELECT @product_entity_type_id := `entity_type_id` FROM `" . $this->_tablePrefix . "eav_entity_type` WHERE
|
| 172 |
+
entity_type_code = 'catalog_product';
|
| 173 |
+
SELECT @category_entity_type_id := `entity_type_id` FROM `" . $this->_tablePrefix . "eav_entity_type` WHERE
|
| 174 |
+
entity_type_code = 'catalog_category';
|
| 175 |
+
SELECT @attribute_set_id := `entity_type_id` FROM `" . $this->_tablePrefix . "eav_entity_type` WHERE
|
| 176 |
+
entity_type_code = 'catalog_product';
|
| 177 |
+
SELECT @stock_id := `stock_id` FROM `" . $this->_tablePrefix . "cataloginventory_stock` WHERE
|
| 178 |
+
stock_name = 'Default';
|
| 179 |
+
SELECT @attribute_set_id := `attribute_set_id` FROM `" . $this->_tablePrefix . "eav_attribute_set`
|
| 180 |
+
WHERE attribute_set_name = :attribute_set AND entity_type_id =
|
| 181 |
+
@product_entity_type_id;
|
| 182 |
+
|
| 183 |
+
SELECT @price_id := `attribute_id` FROM `" . $this->_tablePrefix . "eav_attribute` WHERE
|
| 184 |
+
`attribute_code` = 'price' AND entity_type_id = @product_entity_type_id;
|
| 185 |
+
|
| 186 |
+
SELECT @unspcs_id := `attribute_id` FROM `" . $this->_tablePrefix . "eav_attribute` WHERE
|
| 187 |
+
`attribute_code` = 'unspsc' AND entity_type_id = @category_entity_type_id;
|
| 188 |
+
SELECT @category_name_id := `attribute_id` FROM `" . $this->_tablePrefix . "eav_attribute` WHERE
|
| 189 |
+
`attribute_code` = 'name' AND entity_type_id = @category_entity_type_id;
|
| 190 |
+
SELECT @category_active_id := `attribute_id` FROM `" . $this->_tablePrefix . "eav_attribute` WHERE
|
| 191 |
+
`attribute_code` = 'is_active' AND entity_type_id = @category_entity_type_id;
|
| 192 |
+
SELECT @include_nav_bar_id := `attribute_id` FROM `" . $this->_tablePrefix . "eav_attribute` WHERE
|
| 193 |
+
`attribute_code` = 'include_in_menu' AND entity_type_id = @category_entity_type_id;
|
| 194 |
+
SELECT @category_is_anchor_id := `attribute_id` FROM `" . $this->_tablePrefix . "eav_attribute` WHERE
|
| 195 |
+
`attribute_code` = 'is_anchor' AND entity_type_id = @category_entity_type_id;
|
| 196 |
+
";
|
| 197 |
+
|
| 198 |
+
|
| 199 |
+
$this->_connRes->query($initAttributes, array(':attribute_set' => $iceimportAttributes['attribute_set']));
|
| 200 |
+
|
| 201 |
+
$prodIdFetch = $this->_connRes->fetchRow("SELECT entity_id FROM `" . $this->_tablePrefix . "catalog_product_entity` WHERE sku = :sku limit 1" , array(
|
| 202 |
+
':sku' => $sku
|
| 203 |
+
));
|
| 204 |
+
$productId = $prodIdFetch['entity_id'];
|
| 205 |
+
|
| 206 |
+
if (!empty($productId)) {
|
| 207 |
+
// check import type (Import only price & qty or all product info)
|
| 208 |
+
if('import_price_stock' == Mage::getStoreConfig('importprod_root/importprod/import_only_prices_stock',
|
| 209 |
+
$storeId)) {
|
| 210 |
+
$this->_corePriceStock($websiteId, $productId, $price, $qty, $sku, $isInStock);
|
| 211 |
+
$query = $this->_connRes->query('INSERT INTO iceimport_imported_product_ids (product_id, product_sku) VALUES (:prod_id, :sku)',array(':prod_id' => $productId,':sku' => $sku));
|
| 212 |
+
return true;
|
| 213 |
+
}
|
| 214 |
+
} else {
|
| 215 |
+
$productId = null;
|
| 216 |
+
}
|
| 217 |
+
$defaulttaxConf = (int)Mage::getStoreConfig('importprod_root/importprod/default_tax',$storeId);
|
| 218 |
+
|
| 219 |
+
if( !empty($defaulttaxConf) ) {
|
| 220 |
+
$productData['int']['tax_class_id'] = $defaulttaxConf;
|
| 221 |
+
}
|
| 222 |
+
// get category id
|
| 223 |
+
$categoriesToActiveConf = Mage::getStoreConfig('importprod_root/importprod/category_active',
|
| 224 |
+
$storeId);
|
| 225 |
+
$categoryIds = $this->_addCategories($category, $storeId, $unspsc, $unspscPath, $categoriesToActiveConf);
|
| 226 |
+
|
| 227 |
+
// get url key
|
| 228 |
+
$url = '';
|
| 229 |
+
if (!empty($productData['varchar']['name'])) {
|
| 230 |
+
$preUrl = explode(' ', strtolower($productData['varchar']['name']));
|
| 231 |
+
$url = implode('-', $preUrl) . '-' . $iceimportAttributes['store'];
|
| 232 |
+
}
|
| 233 |
+
$productData['varchar']['url_key'] = $url;
|
| 234 |
+
|
| 235 |
+
// if new product then ovewrride product id from null to id
|
| 236 |
+
$productId = $this->_coreSave($productData, $productId, $storeId, $sku, $categoryIds);
|
| 237 |
+
|
| 238 |
+
// add product image to queue
|
| 239 |
+
if (Mage::getStoreConfig('importprod_root/importprod/import_images')) {
|
| 240 |
+
$this->_addImageToQueue($productId, $productImage);
|
| 241 |
+
}
|
| 242 |
+
|
| 243 |
+
// add price & stock
|
| 244 |
+
$this->_corePriceStock($websiteId, $productId, $price, $qty, $sku, $isInStock);
|
| 245 |
+
|
| 246 |
+
$query = $this->_connRes->query('INSERT INTO iceimport_imported_product_ids (product_id, product_sku) VALUES (:prod_id, :sku)',array(':prod_id' => $productId,':sku' => $sku));
|
| 247 |
+
|
| 248 |
+
// Check if this is last imported product
|
| 249 |
+
// Do category sort and set categories without products to inactive
|
| 250 |
+
if (isset($counter) && isset($import_total) && ($counter==$import_total)) {
|
| 251 |
+
$catCollection = Mage::getModel('catalog/category')
|
| 252 |
+
->getCollection()
|
| 253 |
+
->addAttributeToSort('name', 'ASC');
|
| 254 |
+
$position = 1;
|
| 255 |
+
|
| 256 |
+
foreach ($catCollection as $category) {
|
| 257 |
+
|
| 258 |
+
$query = $this->_connRes->query("UPDATE `". $this->_tablePrefix . "catalog_category_entity` SET position = :position WHERE entity_id = :cat_id ", array(
|
| 259 |
+
':position'=>$position,
|
| 260 |
+
':cat_id'=> $category->getId()
|
| 261 |
+
));
|
| 262 |
+
|
| 263 |
+
$query = "SELECT COUNT(*) FROM `" . $this->_tablePrefix . "catalog_category_product` WHERE category_id = :cat_id ";
|
| 264 |
+
$cat_products = $this->_connRes->fetchRow($query,array(
|
| 265 |
+
':cat_id'=> $category->getId()
|
| 266 |
+
));
|
| 267 |
+
|
| 268 |
+
if ($cat_products['COUNT(*)'] == 0) {
|
| 269 |
+
$query = "SELECT `entity_id` FROM `" . $this->_tablePrefix . "catalog_category_entity` WHERE parent_id = :cat_id";
|
| 270 |
+
$child_cat = $this->_connRes->fetchAll($query,array(
|
| 271 |
+
':cat_id'=> $category->getId()
|
| 272 |
+
));
|
| 273 |
+
|
| 274 |
+
if (isset($child_cat) && count($child_cat) > 0) {
|
| 275 |
+
//Count child categories products and set them to inactive if they have no
|
| 276 |
+
$this->CountChildProd($child_cat);
|
| 277 |
+
} else {
|
| 278 |
+
$this->_connRes->query("UPDATE `" . $this->_tablePrefix . "catalog_category_entity_int`
|
| 279 |
+
SET `value` = 0 WHERE `attribute_id` = @category_active_id AND entity_id = :cat_id",array(
|
| 280 |
+
':cat_id'=> $category->getId()
|
| 281 |
+
));
|
| 282 |
+
}
|
| 283 |
+
}
|
| 284 |
+
$position++;
|
| 285 |
+
}
|
| 286 |
+
|
| 287 |
+
$session->unsetData('import_total');
|
| 288 |
+
$session->unsetData('counter');
|
| 289 |
+
}
|
| 290 |
+
|
| 291 |
+
return true;
|
| 292 |
+
}
|
| 293 |
+
|
| 294 |
+
protected function _coreSave(array $entityData, $productId = null, $storeId = 0, $sku, $categoryIds) {
|
| 295 |
+
if ($productId === null) {
|
| 296 |
+
// add product to store
|
| 297 |
+
$coreSaveProduct = "INSERT INTO `" . $this->_tablePrefix . "catalog_product_entity` (`entity_type_id`, `attribute_set_id`, `type_id`, `sku`, `created_at`) VALUES
|
| 298 |
+
(@product_entity_type_id, @attribute_set_id, 'simple', :sku, NOW());
|
| 299 |
+
SELECT @product_id := LAST_INSERT_ID();
|
| 300 |
+
";
|
| 301 |
+
$this->_connRes->query($coreSaveProduct, array(':sku' => $sku));
|
| 302 |
+
// get product ID
|
| 303 |
+
$prodFetch = $this->_connRes->fetchRow('SELECT @product_id AS prod_id');
|
| 304 |
+
$productId = $prodFetch['prod_id'];
|
| 305 |
+
} else {
|
| 306 |
+
$coreSaveSQL .= "SELECT @product_id := " . (int)$productId . "; ";
|
| 307 |
+
}
|
| 308 |
+
|
| 309 |
+
$bindArray[':store_id'] = $storeId;
|
| 310 |
+
foreach ($entityData as $type => $typeAttributes) {
|
| 311 |
+
if ($type != 'spec') {
|
| 312 |
+
$tailCoreSaveSQL = '';
|
| 313 |
+
$attributesInit = '';
|
| 314 |
+
if (!empty($typeAttributes)) {
|
| 315 |
+
$tailCoreSaveSQL .= "
|
| 316 |
+
INSERT INTO `" . $this->_tablePrefix . "catalog_product_entity_" . $type . "` (`entity_type_id`, `attribute_id`, `store_id`, `entity_id`, `value`) VALUES ";
|
| 317 |
+
foreach ($typeAttributes as $attribute => $value) {
|
| 318 |
+
$attributesInit .= "
|
| 319 |
+
SELECT @" . $attribute . "_id := `attribute_id` FROM `" . $this->_tablePrefix . "eav_attribute` WHERE
|
| 320 |
+
`attribute_code` = '" . $attribute . "' AND entity_type_id = @product_entity_type_id;
|
| 321 |
+
";
|
| 322 |
+
$tailCoreSaveSQL .= "
|
| 323 |
+
(@product_entity_type_id, @" . $attribute . "_id, 0, @product_id, :" . $attribute . " ),
|
| 324 |
+
(@product_entity_type_id, @" . $attribute . "_id, :store_id, @product_id, :" . $attribute . " ), ";
|
| 325 |
+
$bindArray[':' . $attribute] = $value;
|
| 326 |
+
}
|
| 327 |
+
$tailCoreSaveSQL = substr($tailCoreSaveSQL, 0, -2);
|
| 328 |
+
$tailCoreSaveSQL .= "
|
| 329 |
+
ON DUPLICATE KEY UPDATE
|
| 330 |
+
`value` = VALUES (`value`);
|
| 331 |
+
";
|
| 332 |
+
}
|
| 333 |
+
$coreSaveSQL .= $attributesInit . $tailCoreSaveSQL;
|
| 334 |
+
} else {
|
| 335 |
+
foreach ($typeAttributes as $attribute => $attributeData) {
|
| 336 |
+
$prod_id_field = $attributeData['prod_id_field'];
|
| 337 |
+
$table = $attributeData['table'];
|
| 338 |
+
$field = $attributeData['field'];
|
| 339 |
+
$value = $attributeData['value'];
|
| 340 |
+
if (!empty($table) && !empty($field)) {
|
| 341 |
+
$coreSaveSQL .= "
|
| 342 |
+
UPDATE `" . $this->_tablePrefix . $table . "` SET `" . $field . "` = :" . $attribute . " WHERE `" . $prod_id_field . "` = @product_id;
|
| 343 |
+
";
|
| 344 |
+
$bindArray[':' . $attribute] = $value;
|
| 345 |
+
}
|
| 346 |
+
}
|
| 347 |
+
}
|
| 348 |
+
}
|
| 349 |
+
|
| 350 |
+
|
| 351 |
+
// categories
|
| 352 |
+
$coreSaveSQL .= "INSERT INTO `" . $this->_tablePrefix . "catalog_category_product` (`category_id`, `product_id`, `position`) VALUES ";
|
| 353 |
+
$counter = 1;
|
| 354 |
+
$categoryIds[] = Mage::app()->getStore(1)->getRootCategoryId();
|
| 355 |
+
foreach ($categoryIds as $categoryId) {
|
| 356 |
+
if ($counter < count($categoryIds)) {
|
| 357 |
+
$coreSaveSQL .= " (" . (int)$categoryId . ", @product_id, 1) , ";
|
| 358 |
+
} else if ($counter == count($categoryIds)) {
|
| 359 |
+
$coreSaveSQL .= " (" . (int)$categoryId . ", @product_id, 1) ON DUPLICATE KEY UPDATE `position` = 1 ";
|
| 360 |
+
}
|
| 361 |
+
$counter++;
|
| 362 |
+
}
|
| 363 |
+
try{
|
| 364 |
+
$query = $this->_connRes->query($coreSaveSQL, $bindArray);
|
| 365 |
+
|
| 366 |
+
/*$newCategories = $categoryIds;
|
| 367 |
+
$newCategories[] = Mage::app()->getStore(1)->getRootCategoryId();
|
| 368 |
+
$product = Mage::getModel('catalog/product')->load($productId);
|
| 369 |
+
$product->setCategoryIds(
|
| 370 |
+
array_merge($product->getCategoryIds(), $newCategories)
|
| 371 |
+
);
|
| 372 |
+
echo ' 367 ';
|
| 373 |
+
$product->save();*/
|
| 374 |
+
} catch(Exception $e) {
|
| 375 |
+
echo $e->getMessage();
|
| 376 |
+
}
|
| 377 |
+
return $productId;
|
| 378 |
+
}
|
| 379 |
+
|
| 380 |
+
protected function _corePriceStock($website =0, $productId =false, $price =0.00, $qty =0.00, $sku =false, $isInStock =0) {
|
| 381 |
+
|
| 382 |
+
if (!$productId) {
|
| 383 |
+
$message = Mage::helper('catalog')->__('Skip import row, product_id for product "%s" not defined ', $sku);
|
| 384 |
+
Mage::throwException($message);
|
| 385 |
+
}
|
| 386 |
+
|
| 387 |
+
$stockSaveSQL = "
|
| 388 |
+
INSERT INTO `" . $this->_tablePrefix . "cataloginventory_stock_item` (`product_id`, `stock_id`, `qty`, `is_in_stock`) VALUES
|
| 389 |
+
(:product_id, @stock_id, :qty,1)
|
| 390 |
+
ON DUPLICATE KEY UPDATE
|
| 391 |
+
`product_id` = :product_id,
|
| 392 |
+
`stock_id` = @stock_id,
|
| 393 |
+
`qty` = :qty,
|
| 394 |
+
`is_in_stock` = :is_in_stock;
|
| 395 |
+
|
| 396 |
+
INSERT INTO `" . $this->_tablePrefix . "cataloginventory_stock_status` (`product_id`, `website_id`, `stock_id`, `qty`, `stock_status`) VALUES
|
| 397 |
+
(:product_id, :webisteId, @stock_id, :qty, 1)
|
| 398 |
+
ON DUPLICATE KEY UPDATE
|
| 399 |
+
`product_id` = :product_id,
|
| 400 |
+
`website_id` = :webisteId,
|
| 401 |
+
`stock_id` = @stock_id,
|
| 402 |
+
`qty` = :qty,
|
| 403 |
+
`stock_status` = :is_in_stock;
|
| 404 |
+
|
| 405 |
+
INSERT INTO `" . $this->_tablePrefix . "catalog_product_website` (`product_id`, `website_id`) VALUES
|
| 406 |
+
(:product_id, :webisteId)
|
| 407 |
+
ON DUPLICATE KEY UPDATE
|
| 408 |
+
`product_id` = :product_id,
|
| 409 |
+
`website_id` = :webisteId;
|
| 410 |
+
|
| 411 |
+
INSERT INTO `" . $this->_tablePrefix . "catalog_product_entity_decimal` (`entity_type_id`,`attribute_id`,`store_id`, `entity_id`, `value`) VALUES
|
| 412 |
+
(@product_entity_type_id, @price_id, 0, :product_id, :price)
|
| 413 |
+
ON DUPLICATE KEY UPDATE
|
| 414 |
+
`entity_type_id` = @product_entity_type_id,
|
| 415 |
+
`attribute_id` = @price_id,
|
| 416 |
+
`store_id` = 0,
|
| 417 |
+
`entity_id` = :product_id,
|
| 418 |
+
`value` = :price;
|
| 419 |
+
";
|
| 420 |
+
|
| 421 |
+
$this->_connRes->query($stockSaveSQL, array(
|
| 422 |
+
':webisteId' => $website,
|
| 423 |
+
':product_id' => $productId,
|
| 424 |
+
':price' => $price,
|
| 425 |
+
':qty' => $qty,
|
| 426 |
+
':is_in_stock' => $isInStock
|
| 427 |
+
));
|
| 428 |
+
|
| 429 |
+
}
|
| 430 |
+
|
| 431 |
+
protected function _addImageToQueue ($productId =false, $productImageUrl) {
|
| 432 |
+
$productImageUrl = trim($productImageUrl);
|
| 433 |
+
if ($productId && !empty($productImageUrl)) {
|
| 434 |
+
// add image if not exists to queue
|
| 435 |
+
$this->_connRes->query(" INSERT IGNORE INTO `" . $this->_tablePrefix . "capacity_product_image_queue` (`entity_id`, `image_url` ) VALUES
|
| 436 |
+
(:product_id, :image_url)
|
| 437 |
+
", array(':product_id' => $productId,
|
| 438 |
+
':image_url' => $productImageUrl));
|
| 439 |
+
}
|
| 440 |
+
}
|
| 441 |
+
|
| 442 |
+
public function getImageQueue(){
|
| 443 |
+
return $this->_connRes->fetchAll("SELECT `queue_id`, `entity_id`, `image_url` FROM `" . $this->_tablePrefix . "capacity_product_image_queue`
|
| 444 |
+
WHERE `is_downloaded` = 0
|
| 445 |
+
");
|
| 446 |
+
}
|
| 447 |
+
|
| 448 |
+
public function setImageAsDownloaded($queueId =false){
|
| 449 |
+
if ($queueId) {
|
| 450 |
+
$this->_connRes->query("UPDATE `" . $this->_tablePrefix . "capacity_product_image_queue` SET is_downloaded = 1
|
| 451 |
+
WHERE queue_id = :queue_id", array(':queue_id' => $queueId));
|
| 452 |
+
}
|
| 453 |
+
}
|
| 454 |
+
|
| 455 |
+
protected function _addCategories($categories, $storeId, $unspsc, $unspscPath, $categoryActive = 1) {
|
| 456 |
+
|
| 457 |
+
// check if product exists
|
| 458 |
+
$categoryId = $this->_getCategoryIdByUnspsc($unspsc);
|
| 459 |
+
$categoryIds = array();
|
| 460 |
+
|
| 461 |
+
if (!empty($categoryId)) {
|
| 462 |
+
// merge categories by unspsc
|
| 463 |
+
$categoryMergedArray = $this->_categoryMapper($categories, $unspscPath);
|
| 464 |
+
foreach ($categoryMergedArray as $category) {
|
| 465 |
+
$categoryName = $category['name'];
|
| 466 |
+
$categoryUnspsc = $category['unspsc'];
|
| 467 |
+
$categoryTreeId = $this->_getCategoryIdByUnspsc($categoryUnspsc);
|
| 468 |
+
// check category name to current store
|
| 469 |
+
$categoryBindArray = array(
|
| 470 |
+
':store_id' => $storeId,
|
| 471 |
+
':category_id' => $categoryTreeId
|
| 472 |
+
);
|
| 473 |
+
$nameCheckerFetch = $this->_connRes->fetchRow("SELECT value_id FROM `" . $this->_tablePrefix . "catalog_category_entity_varchar` WHERE
|
| 474 |
+
store_id = :store_id AND entity_id = :category_id AND attribute_id = @category_name_id
|
| 475 |
+
", $categoryBindArray);
|
| 476 |
+
$nameChecker = $nameCheckerFetch['value_id'];
|
| 477 |
+
if (!$nameChecker) {
|
| 478 |
+
// add category name to current store
|
| 479 |
+
$categoryBindArray[':category_name'] = $categoryName;
|
| 480 |
+
if (!empty($categoryBindArray[':category_id'])){
|
| 481 |
+
$this->_connRes->query("
|
| 482 |
+
INSERT INTO `" . $this->_tablePrefix . "catalog_category_entity_varchar` (`entity_type_id`, `attribute_id`, `store_id`, `entity_id`, `value`) VALUES
|
| 483 |
+
(@category_entity_type_id, @category_name_id, :store_id, :category_id, :category_name)
|
| 484 |
+
", $categoryBindArray);
|
| 485 |
+
}
|
| 486 |
+
}
|
| 487 |
+
}
|
| 488 |
+
if (1 == $categoryActive) {
|
| 489 |
+
// get current path of category
|
| 490 |
+
$categoryPath = $this->_connRes->fetchRow("SELECT path FROM `" . $this->_tablePrefix . "catalog_category_entity` WHERE entity_id = :entity_id",
|
| 491 |
+
array(':entity_id' => $categoryId));
|
| 492 |
+
$categoryPathArray = explode('/', $categoryPath['path']);
|
| 493 |
+
if ($categoryPathArray) {
|
| 494 |
+
$activeSetter = "INSERT INTO `" . $this->_tablePrefix . "catalog_category_entity_int` (`entity_type_id`, `attribute_id`, `store_id`, `entity_id`, `value`) VALUES ";
|
| 495 |
+
}
|
| 496 |
+
|
| 497 |
+
$falseCounter = 0;
|
| 498 |
+
foreach($categoryPathArray as $categoryId) {
|
| 499 |
+
$category = Mage::getModel('catalog/category')->load($categoryId);
|
| 500 |
+
$cid = $category->getId();
|
| 501 |
+
if (!empty($cid)) {
|
| 502 |
+
if (!empty($categoryId)) {
|
| 503 |
+
$categoryIds[] = (int)$categoryId;
|
| 504 |
+
$activeSetter .= "(@category_entity_type_id, @category_active_id, :store_id, " . $categoryId . ", 1),
|
| 505 |
+
(@category_entity_type_id, @category_active_id, 0, " . $categoryId . ", 1), ";
|
| 506 |
+
} else {
|
| 507 |
+
$falseCounter++;
|
| 508 |
+
}
|
| 509 |
+
} else {
|
| 510 |
+
$falseCounter++;
|
| 511 |
+
}
|
| 512 |
+
}
|
| 513 |
+
$activeSetter = substr($activeSetter, 0, -2);
|
| 514 |
+
$activeSetter .= "
|
| 515 |
+
ON DUPLICATE KEY UPDATE
|
| 516 |
+
`value` = 1
|
| 517 |
+
";
|
| 518 |
+
if ($falseCounter < count($categoryPathArray)) {
|
| 519 |
+
$this->_connRes->query($activeSetter, array(':store_id' => $storeId));
|
| 520 |
+
}
|
| 521 |
+
}
|
| 522 |
+
return $categoryIds;
|
| 523 |
+
} else {
|
| 524 |
+
|
| 525 |
+
// merge unspcs to current name in unspcs & name path's
|
| 526 |
+
$categoryMergedArray = $this->_categoryMapper($categories, $unspscPath);
|
| 527 |
+
// get max created parrent category
|
| 528 |
+
$categoryCreateArray = array();
|
| 529 |
+
for ($i = count($categoryMergedArray) -1; $i >= 0; $i--) {
|
| 530 |
+
$category = $categoryMergedArray[$i];
|
| 531 |
+
$checkCategoryId = $this->_getCategoryIdByUnspsc($category['unspsc']);
|
| 532 |
+
if ($checkCategoryId != null) {
|
| 533 |
+
$categoryId = $this->_buildCategoryTree($checkCategoryId, $storeId, $categoryCreateArray, $categoryActive);
|
| 534 |
+
$categoryIds[] = (int)$categoryId;
|
| 535 |
+
break;
|
| 536 |
+
} else {
|
| 537 |
+
$categoryCreateArray[] = $category;
|
| 538 |
+
}
|
| 539 |
+
}
|
| 540 |
+
return $categoryIds;
|
| 541 |
+
}
|
| 542 |
+
}
|
| 543 |
+
|
| 544 |
+
protected function _categoryMapper($categoryPath, $unspscPath) {
|
| 545 |
+
$nameArray = explode('/', $categoryPath);
|
| 546 |
+
$unspscArray = explode('/', $unspscPath);
|
| 547 |
+
|
| 548 |
+
if (count($nameArray) != count($unspscArray)) {
|
| 549 |
+
$message = Mage::helper('catalog')->__('Skip import row, @categories data is invaled');
|
| 550 |
+
Mage::throwException($message);
|
| 551 |
+
}
|
| 552 |
+
|
| 553 |
+
$categoryMergedArray = array(
|
| 554 |
+
array(
|
| 555 |
+
'unspsc' => 'default_root',
|
| 556 |
+
'name' => 'Default category'
|
| 557 |
+
)
|
| 558 |
+
);
|
| 559 |
+
|
| 560 |
+
for($i = 0; $i < count($unspscArray); $i++) {
|
| 561 |
+
$categoryMergedArray[] = array('name' =>$nameArray[$i],
|
| 562 |
+
'unspsc' =>$unspscArray[$i]);
|
| 563 |
+
}
|
| 564 |
+
|
| 565 |
+
return $categoryMergedArray;
|
| 566 |
+
}
|
| 567 |
+
|
| 568 |
+
protected function _getCategoryIdByUnspsc($unspcs) {
|
| 569 |
+
if ($unspcs == 'default_root') {
|
| 570 |
+
return Mage::app()->getStore(1)->getRootCategoryId();
|
| 571 |
+
} else {
|
| 572 |
+
$categoryId = $this->_connRes->fetchRow("SELECT entity_id FROM `" . $this->_tablePrefix . "catalog_category_entity_varchar` WHERE
|
| 573 |
+
`value` = :unspsc AND attribute_id = @unspcs_id", array(':unspsc' => $unspcs));
|
| 574 |
+
return ($categoryId['entity_id']) ? $categoryId['entity_id'] : null;
|
| 575 |
+
}
|
| 576 |
+
}
|
| 577 |
+
|
| 578 |
+
protected function _buildCategoryTree($parrentCategoryId, $storeId, $pathArray, $categoryActive = 0) {
|
| 579 |
+
for ($i = count($pathArray) -1; $i >= 0; $i--) {
|
| 580 |
+
$category = $pathArray[$i];
|
| 581 |
+
$parrentCategoryId = $this->_createCategory($parrentCategoryId, $category['unspsc'], $storeId, $category['name'], $categoryActive);
|
| 582 |
+
}
|
| 583 |
+
|
| 584 |
+
return $parrentCategoryId;
|
| 585 |
+
}
|
| 586 |
+
|
| 587 |
+
protected function _createCategory($parrentId, $unspsc, $storeId, $name, $categoryActive = 0) {
|
| 588 |
+
|
| 589 |
+
$addCategory = "
|
| 590 |
+
SELECT @tPath := `path`, @tLevel := `level` FROM `" . $this->_tablePrefix . "catalog_category_entity` WHERE `entity_id` = :parrent_id;
|
| 591 |
+
SET @tLevel = @tLevel +1;
|
| 592 |
+
|
| 593 |
+
SET @path := CONCAT(@tPath, '/',(SELECT MAX(entity_id) FROM `" . $this->_tablePrefix . "catalog_category_entity`) +1 );
|
| 594 |
+
|
| 595 |
+
INSERT INTO `" . $this->_tablePrefix . "catalog_category_entity` (`entity_type_id`, `attribute_set_id`,
|
| 596 |
+
`parent_id`, `created_at`,
|
| 597 |
+
`path`, `position`,
|
| 598 |
+
`level`, `children_count`)
|
| 599 |
+
VALUES
|
| 600 |
+
(@category_entity_type_id, 0, :parrent_id, NOW(), @path, 1, @tLevel, 0);
|
| 601 |
+
|
| 602 |
+
SELECT @catId := LAST_INSERT_ID();
|
| 603 |
+
|
| 604 |
+
UPDATE `" . $this->_tablePrefix . "catalog_category_entity` SET children_count = children_count +1 WHERE entity_id = :parrent_id;
|
| 605 |
+
|
| 606 |
+
INSERT IGNORE INTO `" . $this->_tablePrefix . "catalog_category_entity_int` (`entity_type_id`, `attribute_id`,
|
| 607 |
+
`store_id`, `entity_id`, `value`)
|
| 608 |
+
VALUES
|
| 609 |
+
(@category_entity_type_id, @category_active_id, 0, @catId, :category_active),
|
| 610 |
+
(@category_entity_type_id, @category_active_id, :store, @catId, :category_active),
|
| 611 |
+
(@category_entity_type_id, @category_is_anchor_id, 0, @catId, 1),
|
| 612 |
+
(@category_entity_type_id, @category_is_anchor_id, :store, @catId, 1),
|
| 613 |
+
(@category_entity_type_id, @include_nav_bar_id, 0, @catId, 1),
|
| 614 |
+
(@category_entity_type_id, @include_nav_bar_id, :store, @catId, 1);
|
| 615 |
+
|
| 616 |
+
INSERT IGNORE INTO `" . $this->_tablePrefix . "catalog_category_entity_varchar` (`entity_type_id`, `attribute_id`,
|
| 617 |
+
`store_id`, `entity_id`, `value`)
|
| 618 |
+
VALUES
|
| 619 |
+
(@category_entity_type_id, @category_name_id, 0, @catId, :category_name),
|
| 620 |
+
(@category_entity_type_id, @category_name_id, :store, @catId, :category_name),
|
| 621 |
+
(@category_entity_type_id, @unspcs_id, 0, @catId, :unspsc_val),
|
| 622 |
+
(@category_entity_type_id, @unspcs_id, :store, @catId, :unspsc_val);
|
| 623 |
+
";
|
| 624 |
+
|
| 625 |
+
$this->_connRes->query($addCategory, array(
|
| 626 |
+
':store' => $storeId,
|
| 627 |
+
':parrent_id' => $parrentId,
|
| 628 |
+
':category_name' => $name,
|
| 629 |
+
':unspsc_val' => $unspsc,
|
| 630 |
+
':category_active' => (int)$categoryActive
|
| 631 |
+
));
|
| 632 |
+
|
| 633 |
+
$categoryIdFetch = $this->_connRes->fetchRow('SELECT @catId AS category_id');
|
| 634 |
+
|
| 635 |
+
return $categoryIdFetch['category_id'];
|
| 636 |
+
}
|
| 637 |
+
|
| 638 |
+
protected function _mapAttributes(array $importData) {
|
| 639 |
+
|
| 640 |
+
// map iceimport attributes, skip some attributes
|
| 641 |
+
$iceAttributes = array();
|
| 642 |
+
foreach ($importData as $attribute => $value) {
|
| 643 |
+
// map iceimport attributes
|
| 644 |
+
if ($attribute == 'type' ||
|
| 645 |
+
$attribute == 'sku' ||
|
| 646 |
+
$attribute == 'attribute_set' ||
|
| 647 |
+
$attribute == 'categories' ||
|
| 648 |
+
$attribute == 'unspsc' ||
|
| 649 |
+
$attribute == 'price' ||
|
| 650 |
+
$attribute == 'qty' ||
|
| 651 |
+
$attribute == 'status' ||
|
| 652 |
+
$attribute == 'visibility' ||
|
| 653 |
+
$attribute == 'store' ||
|
| 654 |
+
$attribute == 'websites' ||
|
| 655 |
+
$attribute == 'is_in_stock' ||
|
| 656 |
+
$attribute == 'image' ||
|
| 657 |
+
$attribute == 'unspsc_path') {
|
| 658 |
+
|
| 659 |
+
$iceAttributes[$attribute] = $value;
|
| 660 |
+
unset($importData[$attribute]);
|
| 661 |
+
|
| 662 |
+
}
|
| 663 |
+
// skip some attributes
|
| 664 |
+
if ($attribute == 'supplier_product_code' ||
|
| 665 |
+
$attribute == 'supplier' ||
|
| 666 |
+
$attribute == 'leader_categories' ||
|
| 667 |
+
$attribute == 'leader_store' ||
|
| 668 |
+
$attribute == 'sprice' ||
|
| 669 |
+
$attribute == 'euprice' ||
|
| 670 |
+
$attribute == 'icecat_product_id' ||
|
| 671 |
+
$attribute == 'icecat_category_id' ||
|
| 672 |
+
$attribute == 'icecat_vendor_id' ||
|
| 673 |
+
$attribute == 'icecat_quality' ||
|
| 674 |
+
$attribute == 'icecat_url' ||
|
| 675 |
+
$attribute == 'icecat_thumbnail_img' ||
|
| 676 |
+
$attribute == 'icecat_low_res_img' ||
|
| 677 |
+
$attribute == 'icecat_high_res_img' ||
|
| 678 |
+
$attribute == 'tax1' ||
|
| 679 |
+
$attribute == 'tax2' ||
|
| 680 |
+
$attribute == 'tax3' ||
|
| 681 |
+
$attribute == 'tax4' ||
|
| 682 |
+
$attribute == 'min_quantity' ||
|
| 683 |
+
$attribute == 'loms' ||
|
| 684 |
+
$attribute == 'image_label' ||
|
| 685 |
+
$attribute == 'links_title' ||
|
| 686 |
+
$attribute == 'small_image_label' ||
|
| 687 |
+
$attribute == 'tax_rate' ||
|
| 688 |
+
$attribute == 'gallery' ||
|
| 689 |
+
$attribute == 'weight_type' ||
|
| 690 |
+
$attribute == 'sku_type' ||
|
| 691 |
+
$attribute == 'manage_stock' ||
|
| 692 |
+
$attribute == 'minimal_price' ||
|
| 693 |
+
$attribute == 'required_options' ||
|
| 694 |
+
$attribute == 'samples_title' ||
|
| 695 |
+
$attribute == 'shipment_type' ||
|
| 696 |
+
$attribute == 'url_path' ||
|
| 697 |
+
$attribute == 'recurring_profile' ||
|
| 698 |
+
$attribute == 'product_keys') {
|
| 699 |
+
|
| 700 |
+
unset($importData[$attribute]);
|
| 701 |
+
|
| 702 |
+
}
|
| 703 |
+
|
| 704 |
+
}
|
| 705 |
+
|
| 706 |
+
// map default attributes
|
| 707 |
+
$productData = array();
|
| 708 |
+
foreach($this->_getDefaultAttributesList() as $backendType => $attributesList) {
|
| 709 |
+
if ($backendType != 'spec') {
|
| 710 |
+
foreach($attributesList as $attribute) {
|
| 711 |
+
if (isset($importData[$attribute])) {
|
| 712 |
+
$productData[$backendType][$attribute] = $importData[$attribute];
|
| 713 |
+
unset($importData[$attribute]);
|
| 714 |
+
}
|
| 715 |
+
}
|
| 716 |
+
} else {
|
| 717 |
+
foreach($attributesList as $attributeCode => $attributeSpecs) {
|
| 718 |
+
if (isset($importData[$attributeCode])) {
|
| 719 |
+
$attributeSpecs['value'] = $importData[$attributeCode];
|
| 720 |
+
$productData[$backendType][$attributeCode] = $attributeSpecs;
|
| 721 |
+
unset($importData[$attributeCode]);
|
| 722 |
+
}
|
| 723 |
+
}
|
| 724 |
+
}
|
| 725 |
+
}
|
| 726 |
+
|
| 727 |
+
// map custom attributes
|
| 728 |
+
if (!empty($importData)) {
|
| 729 |
+
foreach ($importData as $attributeCode => $value) {
|
| 730 |
+
$backendTypeFetch = $this->_connRes->fetchRow("SELECT backend_type FROM `" . $this->_tablePrefix . "eav_attribute` WHERE `attribute_code` = :code", array(':code' => $attributeCode));
|
| 731 |
+
$backendType = $backendTypeFetch['backend_type'];
|
| 732 |
+
if ($backendType != 'static' && !empty($backendType)) {
|
| 733 |
+
$productData[$backendType][$attributeCode] = $value;
|
| 734 |
+
unset($importData[$attributeCode]);
|
| 735 |
+
}
|
| 736 |
+
}
|
| 737 |
+
}
|
| 738 |
+
|
| 739 |
+
$failedAttributes = array();
|
| 740 |
+
if (count($importData) > 0) {
|
| 741 |
+
$failedAttributes = array_keys($importData);
|
| 742 |
+
}
|
| 743 |
+
|
| 744 |
+
return array(
|
| 745 |
+
'iceimportAttributes' => $iceAttributes,
|
| 746 |
+
'productData' => $productData,
|
| 747 |
+
'failedAttributes' => $failedAttributes
|
| 748 |
+
);
|
| 749 |
+
|
| 750 |
+
}
|
| 751 |
+
|
| 752 |
+
protected function _getDefaultAttributesList () {
|
| 753 |
+
return array(
|
| 754 |
+
'varchar' => array(
|
| 755 |
+
'gift_message_available',
|
| 756 |
+
'custom_design',
|
| 757 |
+
'msrp_display_actual_price_type',
|
| 758 |
+
'msrp_enabled',
|
| 759 |
+
'options_container',
|
| 760 |
+
'page_layout',
|
| 761 |
+
'mpn',
|
| 762 |
+
'brand_name',
|
| 763 |
+
'name',
|
| 764 |
+
'url_key',
|
| 765 |
+
'meta_description',
|
| 766 |
+
'meta_title'
|
| 767 |
+
),
|
| 768 |
+
'int' => array(
|
| 769 |
+
'enable_googlecheckout',
|
| 770 |
+
'is_recurring',
|
| 771 |
+
'links_purchased_separately',
|
| 772 |
+
'links_exist',
|
| 773 |
+
'status',
|
| 774 |
+
'visibility',
|
| 775 |
+
'tax_class_id',
|
| 776 |
+
'color',
|
| 777 |
+
'price_view',
|
| 778 |
+
'manufacturer'
|
| 779 |
+
),
|
| 780 |
+
'text' => array(
|
| 781 |
+
'recurring_profile',
|
| 782 |
+
'description',
|
| 783 |
+
'custom_layout_update',
|
| 784 |
+
'meta_keyword',
|
| 785 |
+
'short_description'
|
| 786 |
+
),
|
| 787 |
+
'decimal' => array(
|
| 788 |
+
'cost',
|
| 789 |
+
'group_price',
|
| 790 |
+
'weight',
|
| 791 |
+
'special_price',
|
| 792 |
+
'msrp'
|
| 793 |
+
),
|
| 794 |
+
'datetime' => array(
|
| 795 |
+
'custom_design_from',
|
| 796 |
+
'custom_design_to',
|
| 797 |
+
'news_from_date',
|
| 798 |
+
'news_to_date',
|
| 799 |
+
'special_from_date',
|
| 800 |
+
'special_to_date'
|
| 801 |
+
),
|
| 802 |
+
'spec' => array(
|
| 803 |
+
'is_qty_decimal' => array(
|
| 804 |
+
'prod_id_field' => 'product_id',
|
| 805 |
+
'table' => 'cataloginventory_stock_item',
|
| 806 |
+
'field' => 'is_qty_decimal'
|
| 807 |
+
),
|
| 808 |
+
'use_config_min_qty' => array(
|
| 809 |
+
'prod_id_field' => 'product_id',
|
| 810 |
+
'table' => 'cataloginventory_stock_item',
|
| 811 |
+
'field' => 'use_config_min_qty'
|
| 812 |
+
),
|
| 813 |
+
'use_config_min_sale_qty' => array(
|
| 814 |
+
'prod_id_field' => 'product_id',
|
| 815 |
+
'table' => 'cataloginventory_stock_item',
|
| 816 |
+
'field' => 'use_config_min_sale_qty'
|
| 817 |
+
),
|
| 818 |
+
'use_config_max_sale_qty' => array(
|
| 819 |
+
'prod_id_field' => 'product_id',
|
| 820 |
+
'table' => 'cataloginventory_stock_item',
|
| 821 |
+
'field' => 'use_config_max_sale_qty'
|
| 822 |
+
),
|
| 823 |
+
'use_config_manage_stock' => array(
|
| 824 |
+
'prod_id_field' => 'product_id',
|
| 825 |
+
'table' => 'cataloginventory_stock_item',
|
| 826 |
+
'field' => 'use_config_manage_stock'
|
| 827 |
+
),
|
| 828 |
+
'is_decimal_divided' => array(
|
| 829 |
+
'prod_id_field' => 'product_id',
|
| 830 |
+
'table' => 'cataloginventory_stock_item',
|
| 831 |
+
'field' => 'is_decimal_divided'
|
| 832 |
+
),
|
| 833 |
+
'use_config_backorders' => array(
|
| 834 |
+
'prod_id_field' => 'product_id',
|
| 835 |
+
'table' => 'cataloginventory_stock_item',
|
| 836 |
+
'field' => 'use_config_backorders'
|
| 837 |
+
),
|
| 838 |
+
'use_config_notify_stock_qty' => array(
|
| 839 |
+
'prod_id_field' => 'product_id',
|
| 840 |
+
'table' => 'cataloginventory_stock_item',
|
| 841 |
+
'field' => 'use_config_notify_stock_qty'
|
| 842 |
+
),
|
| 843 |
+
'max_sale_qty' => array(
|
| 844 |
+
'prod_id_field' => 'product_id',
|
| 845 |
+
'table' => 'cataloginventory_stock_item',
|
| 846 |
+
'field' => 'max_sale_qty'
|
| 847 |
+
),
|
| 848 |
+
'min_sale_qty' => array(
|
| 849 |
+
'prod_id_field' => 'product_id',
|
| 850 |
+
'table' => 'cataloginventory_stock_item',
|
| 851 |
+
'field' => 'min_sale_qty'
|
| 852 |
+
),
|
| 853 |
+
'notify_stock_qty' => array(
|
| 854 |
+
'prod_id_field' => 'product_id',
|
| 855 |
+
'table' => 'cataloginventory_stock_item',
|
| 856 |
+
'field' => 'notify_stock_qty'
|
| 857 |
+
),
|
| 858 |
+
'backorders' => array(
|
| 859 |
+
'prod_id_field' => 'product_id',
|
| 860 |
+
'table' => 'cataloginventory_stock_item',
|
| 861 |
+
'field' => 'backorders'
|
| 862 |
+
),
|
| 863 |
+
'created_at' => array(
|
| 864 |
+
'prod_id_field' => 'entity_id',
|
| 865 |
+
'table' => 'catalog_product_entity',
|
| 866 |
+
'field' => 'created_at'
|
| 867 |
+
),
|
| 868 |
+
'min_qty' => array(
|
| 869 |
+
'prod_id_field' => 'product_id',
|
| 870 |
+
'table' => 'cataloginventory_stock_item',
|
| 871 |
+
'field' => 'min_qty'
|
| 872 |
+
),
|
| 873 |
+
'updated_at' => array(
|
| 874 |
+
'prod_id_field' => 'entity_id',
|
| 875 |
+
'table' => 'catalog_product_entity',
|
| 876 |
+
'field' => 'updated_at'
|
| 877 |
+
)
|
| 878 |
+
)
|
| 879 |
+
);
|
| 880 |
+
}
|
| 881 |
+
|
| 882 |
+
// Count child categories products and set them inactive if they have no products
|
| 883 |
+
public function CountChildProd($child_cat) {
|
| 884 |
+
foreach ($child_cat as $cat) {
|
| 885 |
+
$query = "SELECT `entity_id` FROM `" . $this->_tablePrefix . "catalog_category_entity` WHERE parent_id = :cat_id";
|
| 886 |
+
$child_cat = $this->_connRes->fetchAll($query,array(
|
| 887 |
+
':cat_id'=> $cat['entity_id']
|
| 888 |
+
));
|
| 889 |
+
|
| 890 |
+
$query = "SELECT COUNT(*) FROM `" . $this->_tablePrefix . "catalog_category_product` WHERE category_id = :cat_id ";
|
| 891 |
+
$cat_products = $this->_connRes->fetchRow($query,array(
|
| 892 |
+
':cat_id'=> $cat['entity_id']
|
| 893 |
+
));
|
| 894 |
+
|
| 895 |
+
if ($cat_products['COUNT(*)'] == 0 && empty($child_cat)) {
|
| 896 |
+
$this->_connRes->query("UPDATE `" . $this->_tablePrefix . "catalog_category_entity_int`
|
| 897 |
+
SET `value` = 0 WHERE `attribute_id` = @category_active_id AND entity_id = :cat_id",array(
|
| 898 |
+
':cat_id'=> $cat['entity_id']
|
| 899 |
+
));
|
| 900 |
+
} else if (!empty($child_cat)) {
|
| 901 |
+
$this->CountChildProd($child_cat);
|
| 902 |
+
}
|
| 903 |
+
}
|
| 904 |
+
}
|
| 905 |
+
|
| 906 |
+
}
|
| 907 |
+
|
app/code/community/Capacitywebsolutions/Importproduct/etc/config.xml
CHANGED
|
@@ -2,7 +2,7 @@
|
|
| 2 |
<config>
|
| 3 |
<modules>
|
| 4 |
<Capacitywebsolutions_Importproduct>
|
| 5 |
-
<version>1.0</version>
|
| 6 |
</Capacitywebsolutions_Importproduct>
|
| 7 |
</modules>
|
| 8 |
<global>
|
| 2 |
<config>
|
| 3 |
<modules>
|
| 4 |
<Capacitywebsolutions_Importproduct>
|
| 5 |
+
<version>1.4.0</version>
|
| 6 |
</Capacitywebsolutions_Importproduct>
|
| 7 |
</modules>
|
| 8 |
<global>
|
package.xml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
| 1 |
<?xml version="1.0"?>
|
| 2 |
<package>
|
| 3 |
<name>ice_import</name>
|
| 4 |
-
<version>1.
|
| 5 |
<stability>stable</stability>
|
| 6 |
<license uri="http://opensource.org/licenses/osl-3.0.php">OSL v.3</license>
|
| 7 |
<channel>community</channel>
|
|
@@ -14,10 +14,10 @@
|
|
| 14 |
- Delete old not relevant products
|
| 15 |
- Set is anchor category property to yes
|
| 16 |
- Sort imported categories by name
|
| 17 |
-
- Added method to set categories, subcategories without products to inactive </notes>
|
| 18 |
<authors><author><name>Iceshop</name><user>Iceshop</user><email>support@iceshop.nl</email></author></authors>
|
| 19 |
-
<date>2013-
|
| 20 |
-
<time>
|
| 21 |
<contents><target name="magecommunity"><dir name="Capacitywebsolutions"><dir name="Importproduct"><dir name="etc"><file name="config.xml" hash="c59424e1f6806af1c50f322a84c262a9"/><file name="system.xml" hash="0f76e79143ac01dc948a1c4c5315c072"/></dir><dir name="Model"><dir name="Convert"><dir name="Adapter"><file name="Product.php" hash="b14683db8316b3bfa88a663abc42e7df"/></dir></dir><dir name="System"><dir name="Config"><file name="Categoryactivity.php" hash="2ddc7588dd1d038661f0017c8ff397a6"/><file name="Imageimport.php" hash="8b29e7bbf67d82a06f04ad9a63df26a0"/><file name="Lockproddetails.php" hash="32a823c0c914348585702536732fed3e"/><file name="Defaulttax.php" hash="32a823c0c914348585702536732fed3e"/></dir></dir><file name="Observer.php" hash="cf7944e708df4fca8fbb218f8828b305"/></dir><dir name="sql"><dir name="importproduct_setup"><file name="mysql4-install-0.1.0.php" hash="61102e9caee6f92ebba4230d391b922d"/></dir></dir></dir></dir></target><target name="mageetc"><dir name="modules"><file name="Capacitywebsolutions_Importproduct.xml" hash="02cb79dd6ed129ce3aa5305e1bfb4bbf"/></dir></target></contents>
|
| 22 |
<compatible/>
|
| 23 |
<dependencies><required><php><min>5.2.0</min><max>6.0.0</max></php></required></dependencies>
|
| 1 |
<?xml version="1.0"?>
|
| 2 |
<package>
|
| 3 |
<name>ice_import</name>
|
| 4 |
+
<version>1.4.0</version>
|
| 5 |
<stability>stable</stability>
|
| 6 |
<license uri="http://opensource.org/licenses/osl-3.0.php">OSL v.3</license>
|
| 7 |
<channel>community</channel>
|
| 14 |
- Delete old not relevant products
|
| 15 |
- Set is anchor category property to yes
|
| 16 |
- Sort imported categories by name
|
| 17 |
+
- Added method to set categories, subcategories without products to inactive
 -Added imported products to all categories listed in import file for product including Default webshop's category </notes>
|
| 18 |
<authors><author><name>Iceshop</name><user>Iceshop</user><email>support@iceshop.nl</email></author></authors>
|
| 19 |
+
<date>2013-08-23</date>
|
| 20 |
+
<time>12:07:42</time>
|
| 21 |
<contents><target name="magecommunity"><dir name="Capacitywebsolutions"><dir name="Importproduct"><dir name="etc"><file name="config.xml" hash="c59424e1f6806af1c50f322a84c262a9"/><file name="system.xml" hash="0f76e79143ac01dc948a1c4c5315c072"/></dir><dir name="Model"><dir name="Convert"><dir name="Adapter"><file name="Product.php" hash="b14683db8316b3bfa88a663abc42e7df"/></dir></dir><dir name="System"><dir name="Config"><file name="Categoryactivity.php" hash="2ddc7588dd1d038661f0017c8ff397a6"/><file name="Imageimport.php" hash="8b29e7bbf67d82a06f04ad9a63df26a0"/><file name="Lockproddetails.php" hash="32a823c0c914348585702536732fed3e"/><file name="Defaulttax.php" hash="32a823c0c914348585702536732fed3e"/></dir></dir><file name="Observer.php" hash="cf7944e708df4fca8fbb218f8828b305"/></dir><dir name="sql"><dir name="importproduct_setup"><file name="mysql4-install-0.1.0.php" hash="61102e9caee6f92ebba4230d391b922d"/></dir></dir></dir></dir></target><target name="mageetc"><dir name="modules"><file name="Capacitywebsolutions_Importproduct.xml" hash="02cb79dd6ed129ce3aa5305e1bfb4bbf"/></dir></target></contents>
|
| 22 |
<compatible/>
|
| 23 |
<dependencies><required><php><min>5.2.0</min><max>6.0.0</max></php></required></dependencies>
|
