Version Notes
Bug-fix (Tested on Magento 1.9.x)
1. Fixed: When an associated simple product transforms into a pure simple product, reset its visibility.
Download this release
Release Info
| Developer | Vince Clark |
| Extension | Gec_Customimport |
| Version | 2.0.0.6 |
| Comparing to | |
| See all releases | |
Code changes from version 2.0.0.5 to 2.0.0.6
app/code/local/Gec/Customimport/Block/Adminhtml/Customimport.php
CHANGED
|
@@ -169,11 +169,12 @@ class Gec_Customimport_Block_Adminhtml_Customimport extends Gec_Customimport_Blo
|
|
| 169 |
Mage::throwException($this->customHelper->__('This attribute set no longer exists.'));
|
| 170 |
}
|
| 171 |
$modelSet->setAttributeSetName(trim($attribute_set_name));
|
| 172 |
-
try
|
| 173 |
$modelSet->validate();
|
| 174 |
$modelSet->save();
|
| 175 |
-
}
|
| 176 |
-
|
|
|
|
| 177 |
}
|
| 178 |
return $attributeSetId;
|
| 179 |
}
|
|
@@ -340,16 +341,17 @@ class Gec_Customimport_Block_Adminhtml_Customimport extends Gec_Customimport_Blo
|
|
| 340 |
if ($attributeGroupId) {
|
| 341 |
$setup = new Mage_Eav_Model_Entity_Setup('core_setup');
|
| 342 |
$attribute_id = $setup->getAttributeId('catalog_product', $attribute_code);
|
| 343 |
-
|
| 344 |
-
$this->customHelper->reportError($this->customHelper->__("Attribute
|
| 345 |
} else {
|
| 346 |
-
|
| 347 |
-
|
| 348 |
-
|
| 349 |
-
|
| 350 |
-
|
| 351 |
-
|
| 352 |
-
|
|
|
|
| 353 |
}
|
| 354 |
}
|
| 355 |
|
|
@@ -510,37 +512,38 @@ class Gec_Customimport_Block_Adminhtml_Customimport extends Gec_Customimport_Blo
|
|
| 510 |
$preCrossArray[$prid] = array(
|
| 511 |
'position' => $position
|
| 512 |
);
|
| 513 |
-
}
|
| 514 |
$preUpsellArray[$prid] = array(
|
| 515 |
'position' => $position
|
| 516 |
);
|
| 517 |
-
}
|
| 518 |
$preRelatedArray[$prid] = array(
|
| 519 |
'position' => $position
|
| 520 |
);
|
| 521 |
-
}
|
| 522 |
$preAssociatedArray[] = $prid;
|
| 523 |
-
$this->
|
| 524 |
-
}
|
| 525 |
$bundleArray[] = $prid;
|
| 526 |
$bundleQuantityArray[] = (int) $association->quantity;
|
| 527 |
$bundlePositionArray[] = (int) $position;
|
| 528 |
}
|
| 529 |
-
}
|
| 530 |
-
|
| 531 |
$crossArray[$prid] = array(
|
| 532 |
'position' => $position
|
| 533 |
);
|
| 534 |
-
}
|
| 535 |
-
|
| 536 |
'position' => $position
|
| 537 |
);
|
| 538 |
-
}
|
| 539 |
-
|
| 540 |
'position' => $position
|
| 541 |
);
|
| 542 |
-
}
|
| 543 |
-
|
|
|
|
| 544 |
}
|
| 545 |
}
|
| 546 |
}
|
|
@@ -808,7 +811,7 @@ class Gec_Customimport_Block_Adminhtml_Customimport extends Gec_Customimport_Blo
|
|
| 808 |
$isActive = ((string) $subcat->isActive == 'Y') ? 1 : 0;
|
| 809 |
$category->setData('is_active', $isActive);
|
| 810 |
$category->save();
|
| 811 |
-
}
|
| 812 |
$isActive = ((string) $subcat->isActive);
|
| 813 |
$status = $this->getTreeCategories($category_id, $p_id, $isActive, false);
|
| 814 |
} else {
|
|
@@ -845,14 +848,14 @@ class Gec_Customimport_Block_Adminhtml_Customimport extends Gec_Customimport_Blo
|
|
| 845 |
$asid = $itemids["asid"];
|
| 846 |
if (!isset($pid)) {
|
| 847 |
if (!isset($asid)) {
|
| 848 |
-
$this->customHelper->reportError($this->customHelper->__('
|
| 849 |
return false;
|
| 850 |
}
|
| 851 |
if ((string) $item->type == 'configurable') {
|
| 852 |
$this->createConfigurableProduct($item, $asid); //create con product
|
| 853 |
-
}
|
| 854 |
$this->createProduct($item, $asid); //create simple product
|
| 855 |
-
}
|
| 856 |
$this->createBundleProduct($item, $asid); //create bundle product
|
| 857 |
} else {
|
| 858 |
$this->customHelper->reportError($this->customHelper->__('Import function does not support product type of record: %s ', $item->id));
|
|
@@ -863,18 +866,17 @@ class Gec_Customimport_Block_Adminhtml_Customimport extends Gec_Customimport_Blo
|
|
| 863 |
try {
|
| 864 |
if ((string) $item->type == 'configurable') {
|
| 865 |
$this->updateConfigurableProduct($item, $pid); //create con product
|
| 866 |
-
}
|
| 867 |
$this->updateProduct($item, $pid); //create simple product
|
| 868 |
-
}
|
| 869 |
$this->updateBundleProduct($item, $pid); //create simple product
|
| 870 |
}
|
| 871 |
-
}
|
| 872 |
-
|
| 873 |
-
$this->customHelper->reportError($this->customHelper->__('ERROR: Product can not created for %s', $item->id));
|
| 874 |
}
|
| 875 |
}
|
| 876 |
} else {
|
| 877 |
-
$this->customHelper->reportInfo($this->customHelper->__('
|
| 878 |
}
|
| 879 |
}
|
| 880 |
|
|
@@ -913,6 +915,7 @@ class Gec_Customimport_Block_Adminhtml_Customimport extends Gec_Customimport_Blo
|
|
| 913 |
$product->setSpecialToDate("");
|
| 914 |
}
|
| 915 |
|
|
|
|
| 916 |
$product->setStatus($p_status);
|
| 917 |
$product->setTaxClassId($p_taxclass);
|
| 918 |
$product->setDescription((string) $item->longDescription);
|
|
@@ -944,21 +947,31 @@ class Gec_Customimport_Block_Adminhtml_Customimport extends Gec_Customimport_Blo
|
|
| 944 |
}
|
| 945 |
|
| 946 |
foreach ($config_attribute_array as $attr) {
|
| 947 |
-
$external_id = $configAttributeValue[$attr][0]; // valueDefId from XML for an attribute
|
| 948 |
$model = Mage::getModel('catalog/resource_eav_attribute');
|
| 949 |
$loadedattr = $model->loadByCode('catalog_product', $attr);
|
| 950 |
$attr_id = $loadedattr->getAttributeId(); // attribute id of magento
|
| 951 |
$attr_type = $loadedattr->getFrontendInput();
|
| 952 |
-
if ($attr_type == 'select' || $attr_type == 'multiselect'
|
|
|
|
| 953 |
$mapObj = Mage::getModel('customimport/customimport');
|
| 954 |
$option_id = $mapObj->isOptionExistsInAttribute($external_id, $attr_id);
|
| 955 |
if ($option_id) {
|
| 956 |
$product->setData($attr, $option_id);
|
| 957 |
-
}
|
| 958 |
-
|
| 959 |
-
|
|
|
|
|
|
|
| 960 |
$attr_value = $configAttributeValue[$attr][1];
|
| 961 |
$product->setData($attr, $attr_value);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 962 |
}
|
| 963 |
}
|
| 964 |
|
|
@@ -1025,8 +1038,8 @@ class Gec_Customimport_Block_Adminhtml_Customimport extends Gec_Customimport_Blo
|
|
| 1025 |
$catalogNewproductDays = Mage::getStoreConfig('catalog/newproduct/days', Mage::app()->getStore());
|
| 1026 |
if (!empty($catalogNewproductDays) && $catalogNewproductDays >= 0) {
|
| 1027 |
$currenDateTime = date("Y-m-d H:i:s", Mage::getModel('core/date')->timestamp(time()));
|
| 1028 |
-
$new_from_date = $currenDateTime;
|
| 1029 |
-
$new_to_date
|
| 1030 |
$product->setNewsFromDate($new_from_date);
|
| 1031 |
$product->setNewsToDate($new_to_date);
|
| 1032 |
}
|
|
@@ -1062,6 +1075,7 @@ class Gec_Customimport_Block_Adminhtml_Customimport extends Gec_Customimport_Blo
|
|
| 1062 |
if (!empty($toDate))
|
| 1063 |
$product->setSpecialToDate(Mage::helper('customimport')->getCurrentLocaleDateTime($item->specialPrice->toDateTime)); //special price to (MM-DD-YYYY)
|
| 1064 |
}
|
|
|
|
| 1065 |
$product->setStatus($p_status);
|
| 1066 |
$product->setTaxClassId($p_taxclass);
|
| 1067 |
$product->setDescription((string) $item->longDescription);
|
|
@@ -1110,6 +1124,10 @@ class Gec_Customimport_Block_Adminhtml_Customimport extends Gec_Customimport_Blo
|
|
| 1110 |
$model = Mage::getModel('catalog/resource_eav_attribute');
|
| 1111 |
$attr = $model->loadByCode('catalog_product', $attribute_code);
|
| 1112 |
$attr_id = $attr->getAttributeId();
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1113 |
$ProductAttributeIds[] = $attr_id;
|
| 1114 |
$attribute_label = $attr->getFrontendLabel();
|
| 1115 |
$attr_detail = array(
|
|
@@ -1127,21 +1145,36 @@ class Gec_Customimport_Block_Adminhtml_Customimport extends Gec_Customimport_Blo
|
|
| 1127 |
$product->setConfigurableAttributesData($attribute_detail);
|
| 1128 |
$product->setCanSaveConfigurableAttributes(1);
|
| 1129 |
foreach ($config_attribute_array as $attr) {
|
| 1130 |
-
$external_id = $configAttributeValue[$attr][0]; // valueDefId from XML for an attribute
|
| 1131 |
$model = Mage::getModel('catalog/resource_eav_attribute');
|
| 1132 |
$loadedattr = $model->loadByCode('catalog_product', $attr);
|
| 1133 |
$attr_id = $loadedattr->getAttributeId(); // attribute id of magento
|
| 1134 |
-
|
| 1135 |
-
|
| 1136 |
-
|
| 1137 |
-
|
| 1138 |
-
|
| 1139 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1140 |
}
|
| 1141 |
-
} else if ($attr_type == 'text' || $attr_type == 'textarea')
|
| 1142 |
-
{
|
| 1143 |
-
$attr_value = $configAttributeValue[$attr][1];
|
| 1144 |
-
$product->setData($attr, $attr_value);
|
| 1145 |
}
|
| 1146 |
}
|
| 1147 |
try {
|
|
@@ -1174,20 +1207,18 @@ class Gec_Customimport_Block_Adminhtml_Customimport extends Gec_Customimport_Blo
|
|
| 1174 |
$stockStatus->assignProduct($product);
|
| 1175 |
$stockStatus->saveProductStatus($product->getId(), 1);
|
| 1176 |
$this->_created_num++;
|
| 1177 |
-
}
|
| 1178 |
-
catch (Exception $e) {
|
| 1179 |
$this->customHelper->writeCustomLog('<span style="color:red;">' . $e->getMessage() . '</span>', $this->logPath);
|
| 1180 |
$this->customHelper->sendLogEmail($this->logPath);
|
| 1181 |
-
echo "exception:$e";
|
| 1182 |
}
|
| 1183 |
} else {
|
| 1184 |
-
$this->customHelper->reportError($this->customHelper->__('Could not
|
| 1185 |
}
|
| 1186 |
} else {
|
| 1187 |
-
$this->customHelper->reportError($this->customHelper->__('
|
| 1188 |
}
|
| 1189 |
} else {
|
| 1190 |
-
$this->customHelper->reportError($this->customHelper->__('Attribute set ID # %s is missing. Hence skipped product
|
| 1191 |
}
|
| 1192 |
}
|
| 1193 |
|
|
@@ -1207,8 +1238,8 @@ class Gec_Customimport_Block_Adminhtml_Customimport extends Gec_Customimport_Blo
|
|
| 1207 |
$catalogNewproductDays = Mage::getStoreConfig('catalog/newproduct/days', Mage::app()->getStore());
|
| 1208 |
if (!empty($catalogNewproductDays) && $catalogNewproductDays >= 0) {
|
| 1209 |
$currenDateTime = date("Y-m-d H:i:s", Mage::getModel('core/date')->timestamp(time()));
|
| 1210 |
-
$new_from_date = $currenDateTime;
|
| 1211 |
-
$new_to_date
|
| 1212 |
$product->setNewsFromDate($new_from_date);
|
| 1213 |
$product->setNewsToDate($new_to_date);
|
| 1214 |
}
|
|
@@ -1302,14 +1333,12 @@ class Gec_Customimport_Block_Adminhtml_Customimport extends Gec_Customimport_Blo
|
|
| 1302 |
}
|
| 1303 |
}
|
| 1304 |
}
|
| 1305 |
-
$skipStatus = 0;
|
| 1306 |
foreach ($multiple_values as $attribute_code => $attribute_values) {
|
| 1307 |
$loadedattr = $model->loadByCode('catalog_product', $attribute_code);
|
| 1308 |
$attr_id = $loadedattr->getAttributeId(); // attribute id of magento
|
| 1309 |
if (!$attr_id) {
|
| 1310 |
-
$this->customHelper->reportError($this->customHelper->__('
|
| 1311 |
-
|
| 1312 |
-
break;
|
| 1313 |
} else {
|
| 1314 |
$attr_type = $loadedattr->getFrontendInput();
|
| 1315 |
if ($attr_type == 'select' && count($attribute_values) == 1) {
|
|
@@ -1317,31 +1346,32 @@ class Gec_Customimport_Block_Adminhtml_Customimport extends Gec_Customimport_Blo
|
|
| 1317 |
$option_id = $mapObj->isOptionExistsInAttribute($attribute_values[0], $attr_id);
|
| 1318 |
if ($option_id) {
|
| 1319 |
$product->setData($attribute_code, $option_id);
|
|
|
|
|
|
|
|
|
|
| 1320 |
}
|
| 1321 |
-
}
|
| 1322 |
-
if ($attr_type == 'select' && count($attribute_values) > 1) {
|
| 1323 |
//multiple values for attribute which is not multiselect
|
| 1324 |
-
$this->customHelper->reportError($this->customHelper->__('
|
| 1325 |
-
|
| 1326 |
-
|
| 1327 |
-
}
|
| 1328 |
-
if ($attr_type == 'multiselect') {
|
| 1329 |
$multivalues = array();
|
| 1330 |
foreach ($attribute_values as $value) {
|
| 1331 |
$mapObj = Mage::getModel('customimport/customimport');
|
| 1332 |
$option_id = $mapObj->isOptionExistsInAttribute($value, $attr_id);
|
| 1333 |
if ($option_id) {
|
| 1334 |
$multivalues[] = $option_id;
|
|
|
|
|
|
|
|
|
|
| 1335 |
}
|
| 1336 |
}
|
| 1337 |
$product->addData(array(
|
| 1338 |
$attribute_code => $multivalues
|
| 1339 |
));
|
| 1340 |
-
}
|
| 1341 |
-
|
| 1342 |
-
if ($attr_type == 'text' || $attr_type == 'textarea') {
|
| 1343 |
$product->setData($attribute_code, $attribute_values[1]);
|
| 1344 |
-
}
|
| 1345 |
$optVal = Mage::getSingleton('customimport/customimport')->getOptVal($attribute_values[0]);
|
| 1346 |
if (strtolower($optVal->getValue()) == 'y' || strtolower($optVal->getValue()) == 'yes') {
|
| 1347 |
$attOptVal = 1;
|
|
@@ -1353,45 +1383,40 @@ class Gec_Customimport_Block_Adminhtml_Customimport extends Gec_Customimport_Blo
|
|
| 1353 |
}
|
| 1354 |
}
|
| 1355 |
try {
|
| 1356 |
-
|
| 1357 |
-
|
| 1358 |
-
|
| 1359 |
-
|
| 1360 |
-
|
| 1361 |
-
|
| 1362 |
-
|
| 1363 |
-
|
| 1364 |
-
|
| 1365 |
-
|
| 1366 |
-
|
| 1367 |
-
|
| 1368 |
-
|
| 1369 |
-
|
| 1370 |
-
|
| 1371 |
-
|
| 1372 |
-
|
| 1373 |
-
|
| 1374 |
-
|
| 1375 |
-
|
| 1376 |
-
|
| 1377 |
-
|
| 1378 |
-
|
| 1379 |
-
|
| 1380 |
-
return $productId;
|
| 1381 |
-
} else {
|
| 1382 |
-
$this->customHelper->reportError($this->customHelper->__('NOTICE: Skipped product due to improper attribute values %s', $item->id));
|
| 1383 |
-
}
|
| 1384 |
} else {
|
| 1385 |
-
$this->customHelper->reportError($this->customHelper->__('
|
| 1386 |
}
|
| 1387 |
-
}
|
| 1388 |
-
catch (Mage_Eav_Model_Entity_Attribute_Exception $e) {
|
| 1389 |
$this->customHelper->reportError($e->getMessage());
|
| 1390 |
$this->customHelper->reportError($e->getAttributeCode());
|
| 1391 |
$this->customHelper->sendLogEmail($this->logPath);
|
| 1392 |
}
|
| 1393 |
} else {
|
| 1394 |
-
$this->customHelper->reportError($this->customHelper->__('Attribute set ID # %s is missing. Hence skipped product
|
| 1395 |
}
|
| 1396 |
}
|
| 1397 |
|
|
@@ -1411,8 +1436,8 @@ class Gec_Customimport_Block_Adminhtml_Customimport extends Gec_Customimport_Blo
|
|
| 1411 |
$catalogNewproductDays = Mage::getStoreConfig('catalog/newproduct/days', Mage::app()->getStore());
|
| 1412 |
if (!empty($catalogNewproductDays) && $catalogNewproductDays >= 0) {
|
| 1413 |
$currenDateTime = date("Y-m-d H:i:s", Mage::getModel('core/date')->timestamp(time()));
|
| 1414 |
-
$new_from_date = $currenDateTime;
|
| 1415 |
-
$new_to_date
|
| 1416 |
$product->setNewsFromDate($new_from_date);
|
| 1417 |
$product->setNewsToDate($new_to_date);
|
| 1418 |
}
|
|
@@ -1495,7 +1520,7 @@ class Gec_Customimport_Block_Adminhtml_Customimport extends Gec_Customimport_Blo
|
|
| 1495 |
$this->customHelper->sendLogEmail($this->logPath);
|
| 1496 |
}
|
| 1497 |
} else {
|
| 1498 |
-
$this->customHelper->reportError($this->customHelper->__('Attribute set ID # %s is missing. Hence skipped product
|
| 1499 |
}
|
| 1500 |
}
|
| 1501 |
|
|
@@ -1557,23 +1582,20 @@ class Gec_Customimport_Block_Adminhtml_Customimport extends Gec_Customimport_Blo
|
|
| 1557 |
if (array_key_exists((string) $attr->id, $attributeOcuurance)) {
|
| 1558 |
$multiple_values[(string) $attr->id][] = (string) $attr->valueDefId;
|
| 1559 |
$attributeOcuurance[(string) $attr->id] = (int) $attributeOcuurance[(string) $attr->id] + 1;
|
| 1560 |
-
if($attr_type == 'text' || $attr_type == 'textarea'){
|
| 1561 |
-
$multiple_values[(string) $attr->id][] = (string) $attr->value;
|
| 1562 |
-
}
|
| 1563 |
} else {
|
| 1564 |
$multiple_values[(string) $attr->id][] = (string) $attr->valueDefId;
|
| 1565 |
$attributeOcuurance[(string) $attr->id] = $i;
|
| 1566 |
-
|
| 1567 |
-
|
| 1568 |
-
|
| 1569 |
}
|
| 1570 |
}
|
| 1571 |
-
$skipStatus = 0;
|
| 1572 |
foreach ($multiple_values as $attribute_code => $attribute_values) {
|
| 1573 |
$loadedattr = $model->loadByCode('catalog_product', $attribute_code);
|
| 1574 |
$attr_id = $loadedattr->getAttributeId(); // attribute id of magento
|
| 1575 |
if (!$attr_id) {
|
| 1576 |
-
$this->customHelper->reportError($this->customHelper->__('Attribute %s is not available in magento
|
|
|
|
| 1577 |
} else {
|
| 1578 |
$attr_type = $loadedattr->getFrontendInput();
|
| 1579 |
if ($attr_type == 'select' && count($attribute_values) == 1) {
|
|
@@ -1581,30 +1603,32 @@ class Gec_Customimport_Block_Adminhtml_Customimport extends Gec_Customimport_Blo
|
|
| 1581 |
$option_id = $mapObj->isOptionExistsInAttribute($attribute_values[0], $attr_id);
|
| 1582 |
if ($option_id) {
|
| 1583 |
$product->setData($attribute_code, $option_id);
|
|
|
|
|
|
|
|
|
|
| 1584 |
}
|
| 1585 |
-
}
|
| 1586 |
-
if ($attr_type == 'select' && count($attribute_values) > 1) {
|
| 1587 |
//multiple values for attribute which is not multiselect
|
| 1588 |
-
$this->customHelper->reportError($this->customHelper->__('Attribute %s can not have multiple values. Hence skipping product
|
| 1589 |
-
|
| 1590 |
-
|
| 1591 |
-
}
|
| 1592 |
-
if ($attr_type == 'multiselect') {
|
| 1593 |
$multivalues = array();
|
| 1594 |
foreach ($attribute_values as $value) {
|
| 1595 |
$mapObj = Mage::getModel('customimport/customimport');
|
| 1596 |
$option_id = $mapObj->isOptionExistsInAttribute($value, $attr_id);
|
| 1597 |
if ($option_id) {
|
| 1598 |
$multivalues[] = $option_id;
|
|
|
|
|
|
|
|
|
|
| 1599 |
}
|
| 1600 |
}
|
| 1601 |
$product->addData(array(
|
| 1602 |
$attribute_code => $multivalues
|
| 1603 |
));
|
| 1604 |
-
}
|
| 1605 |
-
if ($attr_type == 'text' || $attr_type == 'textarea') { // if type is text/textarea
|
| 1606 |
$product->setData($attribute_code, $attribute_values[1]);
|
| 1607 |
-
}
|
| 1608 |
$optVal = Mage::getSingleton('customimport/customimport')->getOptVal($attribute_values[0]);
|
| 1609 |
if (strtolower($optVal->getValue()) == 'y' || strtolower($optVal->getValue()) == 'yes') {
|
| 1610 |
$attOptVal = 1;
|
|
@@ -1615,39 +1639,35 @@ class Gec_Customimport_Block_Adminhtml_Customimport extends Gec_Customimport_Blo
|
|
| 1615 |
}
|
| 1616 |
}
|
| 1617 |
}
|
| 1618 |
-
|
| 1619 |
-
|
| 1620 |
-
|
| 1621 |
-
|
| 1622 |
-
|
| 1623 |
-
|
| 1624 |
-
|
| 1625 |
-
|
| 1626 |
-
|
| 1627 |
-
|
| 1628 |
-
|
| 1629 |
-
|
| 1630 |
-
|
| 1631 |
-
|
| 1632 |
-
|
| 1633 |
-
|
| 1634 |
-
|
| 1635 |
-
|
| 1636 |
-
|
| 1637 |
-
|
| 1638 |
-
}
|
| 1639 |
-
} else {
|
| 1640 |
-
$stockItem->setData('use_config_manage_stock', 0);
|
| 1641 |
-
$stockItem->setData('manage_stock', 0); // manage stock to no
|
| 1642 |
}
|
| 1643 |
-
|
| 1644 |
-
Mage::app()->setCurrentStore(Mage_Core_Model_App::ADMIN_STORE_ID);
|
| 1645 |
-
$stockItem->save();
|
| 1646 |
-
unset($product);
|
| 1647 |
-
return $productId;
|
| 1648 |
} else {
|
| 1649 |
-
$
|
|
|
|
| 1650 |
}
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1651 |
} else {
|
| 1652 |
$this->customHelper->reportError($this->customHelper->__('Skipped product due to some error while save : %s', $item->id));
|
| 1653 |
}
|
|
@@ -2210,12 +2230,21 @@ class Gec_Customimport_Block_Adminhtml_Customimport extends Gec_Customimport_Blo
|
|
| 2210 |
return $rowArray['magento_id'];
|
| 2211 |
}
|
| 2212 |
|
| 2213 |
-
private function
|
| 2214 |
{
|
| 2215 |
$product = Mage::getModel('catalog/product');
|
| 2216 |
$product->load($proid);
|
| 2217 |
$product->setVisibility(Mage_Catalog_Model_Product_Visibility::VISIBILITY_NOT_VISIBLE);
|
| 2218 |
$product->save();
|
| 2219 |
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 2220 |
}
|
| 2221 |
?>
|
| 169 |
Mage::throwException($this->customHelper->__('This attribute set no longer exists.'));
|
| 170 |
}
|
| 171 |
$modelSet->setAttributeSetName(trim($attribute_set_name));
|
| 172 |
+
try{
|
| 173 |
$modelSet->validate();
|
| 174 |
$modelSet->save();
|
| 175 |
+
}
|
| 176 |
+
catch(Exception $e) {
|
| 177 |
+
$this->customHelper->reportError($this->customHelper->__('Attribute set name %s with id %s already exists in Magento system with same name', $attribute_set_name, $external_id));
|
| 178 |
}
|
| 179 |
return $attributeSetId;
|
| 180 |
}
|
| 341 |
if ($attributeGroupId) {
|
| 342 |
$setup = new Mage_Eav_Model_Entity_Setup('core_setup');
|
| 343 |
$attribute_id = $setup->getAttributeId('catalog_product', $attribute_code);
|
| 344 |
+
if (!$attribute_id) {
|
| 345 |
+
$this->customHelper->reportError($this->customHelper->__("Attribute code %s is missing during attribute group %s import",$attribute_code, $attribute_group_id));
|
| 346 |
} else {
|
| 347 |
+
|
| 348 |
+
$attribute_exists = $mapobj->isAttributeExistsInGroup($attribute_id, $attributeGroupId);
|
| 349 |
+
if ($attribute_exists) {
|
| 350 |
+
$mapobj->updateSequenceOfAttribute($attributeGroupId, $attribute_id, $attribute_sort_order, $attribute_code, $attribute_group_id);
|
| 351 |
+
} else {
|
| 352 |
+
$setup->addAttributeToGroup('catalog_product', $attributeSetId, $attributeGroupId, $attribute_id, $attribute_sort_order);
|
| 353 |
+
}
|
| 354 |
+
}
|
| 355 |
}
|
| 356 |
}
|
| 357 |
|
| 512 |
$preCrossArray[$prid] = array(
|
| 513 |
'position' => $position
|
| 514 |
);
|
| 515 |
+
} elseif ((string) $association->assocType == 1) {
|
| 516 |
$preUpsellArray[$prid] = array(
|
| 517 |
'position' => $position
|
| 518 |
);
|
| 519 |
+
} elseif ((string) $association->assocType == 2) {
|
| 520 |
$preRelatedArray[$prid] = array(
|
| 521 |
'position' => $position
|
| 522 |
);
|
| 523 |
+
} elseif ((string) $association->assocType == 3) {
|
| 524 |
$preAssociatedArray[] = $prid;
|
| 525 |
+
$this->_hideVisibility($prid);
|
| 526 |
+
} elseif ((string) $association->assocType == 4) {
|
| 527 |
$bundleArray[] = $prid;
|
| 528 |
$bundleQuantityArray[] = (int) $association->quantity;
|
| 529 |
$bundlePositionArray[] = (int) $position;
|
| 530 |
}
|
| 531 |
+
} elseif($prid && strtolower((string) $association->isActive) == 'n') {
|
| 532 |
+
if ((string) $association->assocType == 0) {
|
| 533 |
$crossArray[$prid] = array(
|
| 534 |
'position' => $position
|
| 535 |
);
|
| 536 |
+
} elseif ((string) $association->assocType == 1) {
|
| 537 |
+
$upsellArray[$prid] = array(
|
| 538 |
'position' => $position
|
| 539 |
);
|
| 540 |
+
} elseif ((string) $association->assocType == 2) {
|
| 541 |
+
$relatedArray[$prid] = array(
|
| 542 |
'position' => $position
|
| 543 |
);
|
| 544 |
+
} elseif ((string) $association->assocType == 3) {
|
| 545 |
+
$disAssociateArray[] = $prid;
|
| 546 |
+
$this->_bothVisibility($prid);
|
| 547 |
}
|
| 548 |
}
|
| 549 |
}
|
| 811 |
$isActive = ((string) $subcat->isActive == 'Y') ? 1 : 0;
|
| 812 |
$category->setData('is_active', $isActive);
|
| 813 |
$category->save();
|
| 814 |
+
} elseif ($category_id = $mapObj->isCategoryExists($ext_subid)) {
|
| 815 |
$isActive = ((string) $subcat->isActive);
|
| 816 |
$status = $this->getTreeCategories($category_id, $p_id, $isActive, false);
|
| 817 |
} else {
|
| 848 |
$asid = $itemids["asid"];
|
| 849 |
if (!isset($pid)) {
|
| 850 |
if (!isset($asid)) {
|
| 851 |
+
$this->customHelper->reportError($this->customHelper->__('Cannot create product sku %s ', $item->id));
|
| 852 |
return false;
|
| 853 |
}
|
| 854 |
if ((string) $item->type == 'configurable') {
|
| 855 |
$this->createConfigurableProduct($item, $asid); //create con product
|
| 856 |
+
} elseif ((string) $item->type == 'simple') {
|
| 857 |
$this->createProduct($item, $asid); //create simple product
|
| 858 |
+
} elseif ((string) $item->type == 'bundle') {
|
| 859 |
$this->createBundleProduct($item, $asid); //create bundle product
|
| 860 |
} else {
|
| 861 |
$this->customHelper->reportError($this->customHelper->__('Import function does not support product type of record: %s ', $item->id));
|
| 866 |
try {
|
| 867 |
if ((string) $item->type == 'configurable') {
|
| 868 |
$this->updateConfigurableProduct($item, $pid); //create con product
|
| 869 |
+
} elseif ((string) $item->type == 'simple') {
|
| 870 |
$this->updateProduct($item, $pid); //create simple product
|
| 871 |
+
} elseif ((string) $item->type == 'bundle') {
|
| 872 |
$this->updateBundleProduct($item, $pid); //create simple product
|
| 873 |
}
|
| 874 |
+
} catch (Exception $e) {
|
| 875 |
+
$this->customHelper->reportError($this->customHelper->__('Product update failed for # %s', $item->id));
|
|
|
|
| 876 |
}
|
| 877 |
}
|
| 878 |
} else {
|
| 879 |
+
$this->customHelper->reportInfo($this->customHelper->__('Product import skipped due to some error for # %s ', $item->id));
|
| 880 |
}
|
| 881 |
}
|
| 882 |
|
| 915 |
$product->setSpecialToDate("");
|
| 916 |
}
|
| 917 |
|
| 918 |
+
$product->setWeight((real) $item->weight);
|
| 919 |
$product->setStatus($p_status);
|
| 920 |
$product->setTaxClassId($p_taxclass);
|
| 921 |
$product->setDescription((string) $item->longDescription);
|
| 947 |
}
|
| 948 |
|
| 949 |
foreach ($config_attribute_array as $attr) {
|
|
|
|
| 950 |
$model = Mage::getModel('catalog/resource_eav_attribute');
|
| 951 |
$loadedattr = $model->loadByCode('catalog_product', $attr);
|
| 952 |
$attr_id = $loadedattr->getAttributeId(); // attribute id of magento
|
| 953 |
$attr_type = $loadedattr->getFrontendInput();
|
| 954 |
+
if ($attr_type == 'select' || $attr_type == 'multiselect') {
|
| 955 |
+
$external_id = $configAttributeValue[$attr][0]; // valueDefId from XML for an attribute
|
| 956 |
$mapObj = Mage::getModel('customimport/customimport');
|
| 957 |
$option_id = $mapObj->isOptionExistsInAttribute($external_id, $attr_id);
|
| 958 |
if ($option_id) {
|
| 959 |
$product->setData($attr, $option_id);
|
| 960 |
+
} else {
|
| 961 |
+
$this->customHelper->reportError($this->customHelper->__('Attribute %s has an undefined option value %s. Hence skipping product # %s', $attr, $external_id, $item->id));
|
| 962 |
+
return;
|
| 963 |
+
}
|
| 964 |
+
} elseif ($attr_type == 'text' || $attr_type == 'textarea') {
|
| 965 |
$attr_value = $configAttributeValue[$attr][1];
|
| 966 |
$product->setData($attr, $attr_value);
|
| 967 |
+
} elseif ($attr_type == 'boolean') {
|
| 968 |
+
$optVal = Mage::getSingleton('customimport/customimport')->getOptVal($configAttributeValue[$attr][0]);
|
| 969 |
+
if (strtolower($optVal->getValue()) == 'y' || strtolower($optVal->getValue()) == 'yes') {
|
| 970 |
+
$attOptVal = 1;
|
| 971 |
+
} else {
|
| 972 |
+
$attOptVal = 0;
|
| 973 |
+
}
|
| 974 |
+
$product->setData($attr, $attOptVal);
|
| 975 |
}
|
| 976 |
}
|
| 977 |
|
| 1038 |
$catalogNewproductDays = Mage::getStoreConfig('catalog/newproduct/days', Mage::app()->getStore());
|
| 1039 |
if (!empty($catalogNewproductDays) && $catalogNewproductDays >= 0) {
|
| 1040 |
$currenDateTime = date("Y-m-d H:i:s", Mage::getModel('core/date')->timestamp(time()));
|
| 1041 |
+
$new_from_date = date($format, strtotime('1 days' . $currenDateTime));
|
| 1042 |
+
$new_to_date = date($format, strtotime($catalogNewproductDays . ' days' . $new_from_date));
|
| 1043 |
$product->setNewsFromDate($new_from_date);
|
| 1044 |
$product->setNewsToDate($new_to_date);
|
| 1045 |
}
|
| 1075 |
if (!empty($toDate))
|
| 1076 |
$product->setSpecialToDate(Mage::helper('customimport')->getCurrentLocaleDateTime($item->specialPrice->toDateTime)); //special price to (MM-DD-YYYY)
|
| 1077 |
}
|
| 1078 |
+
$product->setWeight((real) $item->weight);
|
| 1079 |
$product->setStatus($p_status);
|
| 1080 |
$product->setTaxClassId($p_taxclass);
|
| 1081 |
$product->setDescription((string) $item->longDescription);
|
| 1124 |
$model = Mage::getModel('catalog/resource_eav_attribute');
|
| 1125 |
$attr = $model->loadByCode('catalog_product', $attribute_code);
|
| 1126 |
$attr_id = $attr->getAttributeId();
|
| 1127 |
+
if (!$attr_id) {
|
| 1128 |
+
$this->customHelper->reportError($this->customHelper->__('Attribute %s is not available in magento. Hence skipping product # %s', $attribute_code, $item->id));
|
| 1129 |
+
return;
|
| 1130 |
+
}
|
| 1131 |
$ProductAttributeIds[] = $attr_id;
|
| 1132 |
$attribute_label = $attr->getFrontendLabel();
|
| 1133 |
$attr_detail = array(
|
| 1145 |
$product->setConfigurableAttributesData($attribute_detail);
|
| 1146 |
$product->setCanSaveConfigurableAttributes(1);
|
| 1147 |
foreach ($config_attribute_array as $attr) {
|
|
|
|
| 1148 |
$model = Mage::getModel('catalog/resource_eav_attribute');
|
| 1149 |
$loadedattr = $model->loadByCode('catalog_product', $attr);
|
| 1150 |
$attr_id = $loadedattr->getAttributeId(); // attribute id of magento
|
| 1151 |
+
if (!$attr_id) {
|
| 1152 |
+
$this->customHelper->reportError($this->customHelper->__('Attribute %s is not available in magento. Hence skipping product # %s', $attr, $item->id));
|
| 1153 |
+
return;
|
| 1154 |
+
} else {
|
| 1155 |
+
$attr_type = $loadedattr->getFrontendInput();
|
| 1156 |
+
if ($attr_type == 'select' || $attr_type == 'multiselect') {
|
| 1157 |
+
$external_id = $configAttributeValue[$attr][0]; // valueDefId from XML for an attribute
|
| 1158 |
+
$mapObj = Mage::getModel('customimport/customimport');
|
| 1159 |
+
$option_id = $mapObj->isOptionExistsInAttribute($external_id, $attr_id);
|
| 1160 |
+
if ($option_id) {
|
| 1161 |
+
$product->setData($attr, $option_id);
|
| 1162 |
+
} else {
|
| 1163 |
+
$this->customHelper->reportError($this->customHelper->__('Attribute %s has an undefined option value %s. Hence skipping product # %s', $attr, $external_id, $item->id));
|
| 1164 |
+
return;
|
| 1165 |
+
}
|
| 1166 |
+
} elseif ($attr_type == 'text' || $attr_type == 'textarea') {
|
| 1167 |
+
$attr_value = $configAttributeValue[$attr][1];
|
| 1168 |
+
$product->setData($attr, $attr_value);
|
| 1169 |
+
} elseif ($attr_type == 'boolean') {
|
| 1170 |
+
$optVal = Mage::getSingleton('customimport/customimport')->getOptVal($configAttributeValue[$attr][0]);
|
| 1171 |
+
if (strtolower($optVal->getValue()) == 'y' || strtolower($optVal->getValue()) == 'yes') {
|
| 1172 |
+
$attOptVal = 1;
|
| 1173 |
+
} else {
|
| 1174 |
+
$attOptVal = 0;
|
| 1175 |
+
}
|
| 1176 |
+
$product->setData($attr, $attOptVal);
|
| 1177 |
}
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1178 |
}
|
| 1179 |
}
|
| 1180 |
try {
|
| 1207 |
$stockStatus->assignProduct($product);
|
| 1208 |
$stockStatus->saveProductStatus($product->getId(), 1);
|
| 1209 |
$this->_created_num++;
|
| 1210 |
+
} catch (Exception $e) {
|
|
|
|
| 1211 |
$this->customHelper->writeCustomLog('<span style="color:red;">' . $e->getMessage() . '</span>', $this->logPath);
|
| 1212 |
$this->customHelper->sendLogEmail($this->logPath);
|
|
|
|
| 1213 |
}
|
| 1214 |
} else {
|
| 1215 |
+
$this->customHelper->reportError($this->customHelper->__('Could not create super attribute for configurable product from %s. Hence skipped product # %s', array_values($superattribute_array), $item->id));
|
| 1216 |
}
|
| 1217 |
} else {
|
| 1218 |
+
$this->customHelper->reportError($this->customHelper->__('No super attributes defined for configurable product. Hence skipped product # %s', $item->id));
|
| 1219 |
}
|
| 1220 |
} else {
|
| 1221 |
+
$this->customHelper->reportError($this->customHelper->__('Attribute set ID # %s is missing. Hence skipped product # %s', $asid, $item->id));
|
| 1222 |
}
|
| 1223 |
}
|
| 1224 |
|
| 1238 |
$catalogNewproductDays = Mage::getStoreConfig('catalog/newproduct/days', Mage::app()->getStore());
|
| 1239 |
if (!empty($catalogNewproductDays) && $catalogNewproductDays >= 0) {
|
| 1240 |
$currenDateTime = date("Y-m-d H:i:s", Mage::getModel('core/date')->timestamp(time()));
|
| 1241 |
+
$new_from_date = date($format, strtotime('1 days' . $currenDateTime));
|
| 1242 |
+
$new_to_date = date($format, strtotime($catalogNewproductDays . ' days' . $new_from_date));
|
| 1243 |
$product->setNewsFromDate($new_from_date);
|
| 1244 |
$product->setNewsToDate($new_to_date);
|
| 1245 |
}
|
| 1333 |
}
|
| 1334 |
}
|
| 1335 |
}
|
|
|
|
| 1336 |
foreach ($multiple_values as $attribute_code => $attribute_values) {
|
| 1337 |
$loadedattr = $model->loadByCode('catalog_product', $attribute_code);
|
| 1338 |
$attr_id = $loadedattr->getAttributeId(); // attribute id of magento
|
| 1339 |
if (!$attr_id) {
|
| 1340 |
+
$this->customHelper->reportError($this->customHelper->__('Attribute %s is not available in magento. Hence skipping product # %s', $attribute_code, $item->id));
|
| 1341 |
+
return;
|
|
|
|
| 1342 |
} else {
|
| 1343 |
$attr_type = $loadedattr->getFrontendInput();
|
| 1344 |
if ($attr_type == 'select' && count($attribute_values) == 1) {
|
| 1346 |
$option_id = $mapObj->isOptionExistsInAttribute($attribute_values[0], $attr_id);
|
| 1347 |
if ($option_id) {
|
| 1348 |
$product->setData($attribute_code, $option_id);
|
| 1349 |
+
} else {
|
| 1350 |
+
$this->customHelper->reportError($this->customHelper->__('Attribute %s has an undefined option value %s. Hence skipping product # %s', $attribute_code, $attribute_values[0], $item->id));
|
| 1351 |
+
return;
|
| 1352 |
}
|
| 1353 |
+
} elseif ($attr_type == 'select' && count($attribute_values) > 1) {
|
|
|
|
| 1354 |
//multiple values for attribute which is not multiselect
|
| 1355 |
+
$this->customHelper->reportError($this->customHelper->__('Attribute %s can not have multiple values. Hence skipping product # %s', $attribute_code, $item->id));
|
| 1356 |
+
return;
|
| 1357 |
+
} elseif ($attr_type == 'multiselect') {
|
|
|
|
|
|
|
| 1358 |
$multivalues = array();
|
| 1359 |
foreach ($attribute_values as $value) {
|
| 1360 |
$mapObj = Mage::getModel('customimport/customimport');
|
| 1361 |
$option_id = $mapObj->isOptionExistsInAttribute($value, $attr_id);
|
| 1362 |
if ($option_id) {
|
| 1363 |
$multivalues[] = $option_id;
|
| 1364 |
+
} else {
|
| 1365 |
+
$this->customHelper->reportError($this->customHelper->__('Attribute %s has an undefined option value %s. Hence skipping product id %s', $attribute_code, $value, $item->id));
|
| 1366 |
+
return;
|
| 1367 |
}
|
| 1368 |
}
|
| 1369 |
$product->addData(array(
|
| 1370 |
$attribute_code => $multivalues
|
| 1371 |
));
|
| 1372 |
+
} elseif ($attr_type == 'text' || $attr_type == 'textarea') {
|
|
|
|
|
|
|
| 1373 |
$product->setData($attribute_code, $attribute_values[1]);
|
| 1374 |
+
} elseif ($attr_type == 'boolean') {
|
| 1375 |
$optVal = Mage::getSingleton('customimport/customimport')->getOptVal($attribute_values[0]);
|
| 1376 |
if (strtolower($optVal->getValue()) == 'y' || strtolower($optVal->getValue()) == 'yes') {
|
| 1377 |
$attOptVal = 1;
|
| 1383 |
}
|
| 1384 |
}
|
| 1385 |
try {
|
| 1386 |
+
Mage::app()->setCurrentStore(Mage_Core_Model_App::ADMIN_STORE_ID);
|
| 1387 |
+
$productId = $product->save()->getId();
|
| 1388 |
+
if ($manageItem == 'N' || $manageItem == 'n') {
|
| 1389 |
+
$product->setStockData(array(
|
| 1390 |
+
'use_config_backorders' => 0,
|
| 1391 |
+
'is_in_stock' => 1,
|
| 1392 |
+
'manage_stock' => 0
|
| 1393 |
+
));
|
| 1394 |
+
//code for instock while update product
|
| 1395 |
+
$stockItem = Mage::getModel('cataloginventory/stock_item');
|
| 1396 |
+
$stockItem->assignProduct($product);
|
| 1397 |
+
$stockItem->setData('use_config_manage_stock', 0);
|
| 1398 |
+
$stockItem->setData('manage_stock', 0);
|
| 1399 |
+
$stockItem->save();
|
| 1400 |
+
$stockStatus = Mage::getModel('cataloginventory/stock_status');
|
| 1401 |
+
$stockStatus->assignProduct($product);
|
| 1402 |
+
$stockStatus->saveProductStatus($product->getId(), 1);
|
| 1403 |
+
}
|
| 1404 |
+
if ($productId) {
|
| 1405 |
+
$this->_created_num++;
|
| 1406 |
+
unset($product);
|
| 1407 |
+
unset($multiple_values);
|
| 1408 |
+
unset($attributeOcuurance);
|
| 1409 |
+
return $productId;
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1410 |
} else {
|
| 1411 |
+
$this->customHelper->reportError($this->customHelper->__('Skipped product due to some error while saving # %s', $item->id));
|
| 1412 |
}
|
| 1413 |
+
} catch (Mage_Eav_Model_Entity_Attribute_Exception $e) {
|
|
|
|
| 1414 |
$this->customHelper->reportError($e->getMessage());
|
| 1415 |
$this->customHelper->reportError($e->getAttributeCode());
|
| 1416 |
$this->customHelper->sendLogEmail($this->logPath);
|
| 1417 |
}
|
| 1418 |
} else {
|
| 1419 |
+
$this->customHelper->reportError($this->customHelper->__('Attribute set ID # %s is missing. Hence skipped product # %s', $asid, $item->id));
|
| 1420 |
}
|
| 1421 |
}
|
| 1422 |
|
| 1436 |
$catalogNewproductDays = Mage::getStoreConfig('catalog/newproduct/days', Mage::app()->getStore());
|
| 1437 |
if (!empty($catalogNewproductDays) && $catalogNewproductDays >= 0) {
|
| 1438 |
$currenDateTime = date("Y-m-d H:i:s", Mage::getModel('core/date')->timestamp(time()));
|
| 1439 |
+
$new_from_date = date($format, strtotime('1 days' . $currenDateTime));
|
| 1440 |
+
$new_to_date = date($format, strtotime($catalogNewproductDays . ' days' . $new_from_date));
|
| 1441 |
$product->setNewsFromDate($new_from_date);
|
| 1442 |
$product->setNewsToDate($new_to_date);
|
| 1443 |
}
|
| 1520 |
$this->customHelper->sendLogEmail($this->logPath);
|
| 1521 |
}
|
| 1522 |
} else {
|
| 1523 |
+
$this->customHelper->reportError($this->customHelper->__('Attribute set ID # %s is missing. Hence skipped product # %s', $asid, $item->id));
|
| 1524 |
}
|
| 1525 |
}
|
| 1526 |
|
| 1582 |
if (array_key_exists((string) $attr->id, $attributeOcuurance)) {
|
| 1583 |
$multiple_values[(string) $attr->id][] = (string) $attr->valueDefId;
|
| 1584 |
$attributeOcuurance[(string) $attr->id] = (int) $attributeOcuurance[(string) $attr->id] + 1;
|
|
|
|
|
|
|
|
|
|
| 1585 |
} else {
|
| 1586 |
$multiple_values[(string) $attr->id][] = (string) $attr->valueDefId;
|
| 1587 |
$attributeOcuurance[(string) $attr->id] = $i;
|
| 1588 |
+
}
|
| 1589 |
+
if($attr_type == 'text' || $attr_type == 'textarea'){
|
| 1590 |
+
$multiple_values[(string) $attr->id][] = (string) $attr->value;
|
| 1591 |
}
|
| 1592 |
}
|
|
|
|
| 1593 |
foreach ($multiple_values as $attribute_code => $attribute_values) {
|
| 1594 |
$loadedattr = $model->loadByCode('catalog_product', $attribute_code);
|
| 1595 |
$attr_id = $loadedattr->getAttributeId(); // attribute id of magento
|
| 1596 |
if (!$attr_id) {
|
| 1597 |
+
$this->customHelper->reportError($this->customHelper->__('Attribute %s is not available in magento. Hence skipping product # %s', $attribute_code, $item->id));
|
| 1598 |
+
return;
|
| 1599 |
} else {
|
| 1600 |
$attr_type = $loadedattr->getFrontendInput();
|
| 1601 |
if ($attr_type == 'select' && count($attribute_values) == 1) {
|
| 1603 |
$option_id = $mapObj->isOptionExistsInAttribute($attribute_values[0], $attr_id);
|
| 1604 |
if ($option_id) {
|
| 1605 |
$product->setData($attribute_code, $option_id);
|
| 1606 |
+
} else {
|
| 1607 |
+
$this->customHelper->reportError($this->customHelper->__('Attribute %s has an undefined option value %s. Hence skipping product # %s', $attribute_code, $attribute_values[0], $item->id));
|
| 1608 |
+
return;
|
| 1609 |
}
|
| 1610 |
+
} elseif ($attr_type == 'select' && count($attribute_values) > 1) {
|
|
|
|
| 1611 |
//multiple values for attribute which is not multiselect
|
| 1612 |
+
$this->customHelper->reportError($this->customHelper->__('Attribute %s can not have multiple values. Hence skipping product # %s', $attribute_code, $item->id));
|
| 1613 |
+
return;
|
| 1614 |
+
} elseif ($attr_type == 'multiselect') {
|
|
|
|
|
|
|
| 1615 |
$multivalues = array();
|
| 1616 |
foreach ($attribute_values as $value) {
|
| 1617 |
$mapObj = Mage::getModel('customimport/customimport');
|
| 1618 |
$option_id = $mapObj->isOptionExistsInAttribute($value, $attr_id);
|
| 1619 |
if ($option_id) {
|
| 1620 |
$multivalues[] = $option_id;
|
| 1621 |
+
} else {
|
| 1622 |
+
$this->customHelper->reportError($this->customHelper->__('Attribute %s has an undefined option value %s. Hence skipping product # %s', $attribute_code, $value, $item->id));
|
| 1623 |
+
return;
|
| 1624 |
}
|
| 1625 |
}
|
| 1626 |
$product->addData(array(
|
| 1627 |
$attribute_code => $multivalues
|
| 1628 |
));
|
| 1629 |
+
} elseif ($attr_type == 'text' || $attr_type == 'textarea') { // if type is text/textarea
|
|
|
|
| 1630 |
$product->setData($attribute_code, $attribute_values[1]);
|
| 1631 |
+
} elseif ($attr_type == 'boolean') {
|
| 1632 |
$optVal = Mage::getSingleton('customimport/customimport')->getOptVal($attribute_values[0]);
|
| 1633 |
if (strtolower($optVal->getValue()) == 'y' || strtolower($optVal->getValue()) == 'yes') {
|
| 1634 |
$attOptVal = 1;
|
| 1639 |
}
|
| 1640 |
}
|
| 1641 |
}
|
| 1642 |
+
|
| 1643 |
+
Mage::app()->setCurrentStore(Mage_Core_Model_App::ADMIN_STORE_ID);
|
| 1644 |
+
$productId = $product->save()->getId();
|
| 1645 |
+
$this->_updated_num++;
|
| 1646 |
+
$stockItem = Mage::getModel('cataloginventory/stock_item')->loadByProduct($productId);
|
| 1647 |
+
$stockItemId = $stockItem->getId();
|
| 1648 |
+
$inventory = $item->inventory;
|
| 1649 |
+
$manageItem = (string) $inventory->manageStock;
|
| 1650 |
+
$manageItem = strtoupper($manageItem);
|
| 1651 |
+
if ($manageItem == 'Y') { // if product item exist
|
| 1652 |
+
$stockItem->setData('manage_stock', 1);
|
| 1653 |
+
$stockItem->setData('is_in_stock', 1);
|
| 1654 |
+
$stockItem->setData('qty', $inventory->atp);
|
| 1655 |
+
if (strtoupper($inventory->allowBackorders) == 'Y') { // if back order allowed
|
| 1656 |
+
$stockItem->setData('use_config_backorders', 0);
|
| 1657 |
+
$stockItem->setData('backorders', 1);
|
| 1658 |
+
}
|
| 1659 |
+
if (strtoupper($inventory->allowBackorders) == 'N') { // if back order allowed
|
| 1660 |
+
$stockItem->setData('use_config_backorders', 0);
|
| 1661 |
+
$stockItem->setData('backorders', 0);
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1662 |
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1663 |
} else {
|
| 1664 |
+
$stockItem->setData('use_config_manage_stock', 0);
|
| 1665 |
+
$stockItem->setData('manage_stock', 0); // manage stock to no
|
| 1666 |
}
|
| 1667 |
+
|
| 1668 |
+
Mage::app()->setCurrentStore(Mage_Core_Model_App::ADMIN_STORE_ID);
|
| 1669 |
+
$stockItem->save();
|
| 1670 |
+
unset($product);
|
| 1671 |
} else {
|
| 1672 |
$this->customHelper->reportError($this->customHelper->__('Skipped product due to some error while save : %s', $item->id));
|
| 1673 |
}
|
| 2230 |
return $rowArray['magento_id'];
|
| 2231 |
}
|
| 2232 |
|
| 2233 |
+
private function _hideVisibility($proid)
|
| 2234 |
{
|
| 2235 |
$product = Mage::getModel('catalog/product');
|
| 2236 |
$product->load($proid);
|
| 2237 |
$product->setVisibility(Mage_Catalog_Model_Product_Visibility::VISIBILITY_NOT_VISIBLE);
|
| 2238 |
$product->save();
|
| 2239 |
}
|
| 2240 |
+
|
| 2241 |
+
private function _bothVisibility($proid)
|
| 2242 |
+
{
|
| 2243 |
+
$product = Mage::getModel('catalog/product');
|
| 2244 |
+
$product->load($proid);
|
| 2245 |
+
$product->setVisibility(Mage_Catalog_Model_Product_Visibility::VISIBILITY_BOTH);
|
| 2246 |
+
$product->save();
|
| 2247 |
+
}
|
| 2248 |
+
|
| 2249 |
}
|
| 2250 |
?>
|
package.xml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
| 1 |
<?xml version="1.0"?>
|
| 2 |
<package>
|
| 3 |
<name>Gec_Customimport</name>
|
| 4 |
-
<version>2.0.0.
|
| 5 |
<stability>stable</stability>
|
| 6 |
<license uri="http://www.gnu.org/licenses/agpl-3.0.txt">GNU Affero General Public License</license>
|
| 7 |
<channel>community</channel>
|
|
@@ -28,21 +28,14 @@ Supports seed and thereafter incremental import of categories, attributes and pr
|
|
| 28 |
8. Get notified via email when a long batch of catalog import is completed with detailed logs.
|
| 29 |

|
| 30 |
Detailed step-by-step instructions to install and configure this instruction are available <a href="https://github.com/globalera/Magento-Catalog-Import/blob/master/README.md" target="_blank">herein.</a></description>
|
| 31 |
-
<notes>Bug-fix
|
| 32 |
-

|
| 33 |
-
1. Covered a case of a pre-existing attribute set while creating a new one.
|
| 34 |
-

|
| 35 |
-
2. Logging source attribute group id instead of magento attribute group id
|
| 36 |
-

|
| 37 |
-
3. Handled the case when attribute is missing in magento while trying to update the parent attribute group
|
| 38 |
-

|
| 39 |
-
4. Removed importing of weight for a configurable product
|
| 40 |

|
|
|
|
| 41 |
</notes>
|
| 42 |
<authors><author><name>Vince Clark</name><user>vclark</user><email>vclark@globalera.com</email></author><author><name>Shrenik Bhura</name><user>shrenikbhura</user><email>shrenik.bhura@intelliant.net</email></author></authors>
|
| 43 |
-
<date>2015-12-
|
| 44 |
-
<time>
|
| 45 |
-
<contents><target name="magelocal"><dir name="Gec"><dir name="Customimport"><dir name="Block"><dir name="Adminhtml"><file name="Catalogimport.php" hash="e5bc70eecb6a4d56bcb561ab1ce224fa"/><file name="Customimport.php" hash="
|
| 46 |
<compatible/>
|
| 47 |
<dependencies><required><php><min>5.4.0</min><max>5.5.30</max></php><package><name>Mage_Core_Modules</name><channel>community</channel><min>1.7.0.0</min><max>1.9.2.2</max></package><package><name/><channel>connect.magentocommerce.com/core</channel><min/><max/></package></required></dependencies>
|
| 48 |
</package>
|
| 1 |
<?xml version="1.0"?>
|
| 2 |
<package>
|
| 3 |
<name>Gec_Customimport</name>
|
| 4 |
+
<version>2.0.0.6</version>
|
| 5 |
<stability>stable</stability>
|
| 6 |
<license uri="http://www.gnu.org/licenses/agpl-3.0.txt">GNU Affero General Public License</license>
|
| 7 |
<channel>community</channel>
|
| 28 |
8. Get notified via email when a long batch of catalog import is completed with detailed logs.
|
| 29 |

|
| 30 |
Detailed step-by-step instructions to install and configure this instruction are available <a href="https://github.com/globalera/Magento-Catalog-Import/blob/master/README.md" target="_blank">herein.</a></description>
|
| 31 |
+
<notes>Bug-fix (Tested on Magento 1.9.x)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 32 |

|
| 33 |
+
1. Fixed: When an associated simple product transforms into a pure simple product, reset its visibility.
|
| 34 |
</notes>
|
| 35 |
<authors><author><name>Vince Clark</name><user>vclark</user><email>vclark@globalera.com</email></author><author><name>Shrenik Bhura</name><user>shrenikbhura</user><email>shrenik.bhura@intelliant.net</email></author></authors>
|
| 36 |
+
<date>2015-12-26</date>
|
| 37 |
+
<time>13:06:54</time>
|
| 38 |
+
<contents><target name="magelocal"><dir name="Gec"><dir name="Customimport"><dir name="Block"><dir name="Adminhtml"><file name="Catalogimport.php" hash="e5bc70eecb6a4d56bcb561ab1ce224fa"/><file name="Customimport.php" hash="9078aa48f853ea35903df05b9937fc95"/></dir><dir name="Catalog"><dir name="Product"><dir name="Attribute"><dir name="Edit"><dir name="Tab"><file name="Options.php" hash="9cfacd51a457bf80a46e6921020ad48c"/></dir></dir></dir></dir></dir></dir><dir name="Helper"><dir name="Catalog"><file name="Image.php" hash="d7b564a66cf53ffff338912040a5de73"/></dir><file name="Data.php" hash="d448c85b8ee74adbd9f6546e9a11a171"/></dir><dir name="Model"><file name="Attrgroup.php" hash="37a839c588d355f9120ade28bcab50b8"/><file name="Attrsetmapping.php" hash="447a20c2d6f97e78751f12095ae3c2a3"/><dir name="Catalog"><dir name="Resource"><dir name="Eav"><dir name="Mysql4"><file name="Attribute.php" hash="4c7e06ca01df7998826292a00b3d4bfc"/></dir></dir></dir></dir><file name="Catalogentity.php" hash="cd10b2dd5fd227c5abe32b8ea72f824c"/><file name="Customimport.php" hash="b8725e611b54047aef5215856391c14f"/><file name="Eavattributegroup.php" hash="1c3b16c01060005f0a888a85577798ad"/><file name="Eavattributeoption.php" hash="a28bc09b99c5abc6baf657cc9701a03f"/><file name="Eaventityattribute.php" hash="1eb5f719737cda5dc53ac03c39553666"/><file name="Externalcategorymappinginfo.php" hash="7317c11769b748a0e80b137474af9281"/><dir name="Mysql4"><dir name="Attrgroup"><file name="Collection.php" hash="c7d63200d3dad0ecd271936e1d86a682"/></dir><file name="Attrgroup.php" hash="3035d75bb3ec5ecfcda6063daa0e86cb"/><dir name="Attrsetmapping"><file name="Collection.php" hash="442c9d881db2f4199d890c66a435bb14"/></dir><file name="Attrsetmapping.php" hash="77967c75149e806373a4f80ca5a8e7a4"/><dir name="Catalogentity"><file name="Collection.php" hash="4075f2a43e8eda07ba29e0b90c84aa83"/></dir><file name="Catalogentity.php" hash="40a4152376eac631370f5f22e077c5be"/><dir name="Customimport"><file name="Collection.php" hash="a56c6dbf083d3ba78d5693213488b4f2"/></dir><file name="Customimport.php" hash="45db905029ccf17f4ae73fc93197eb54"/><dir name="Eavattributegroup"><file name="Collection.php" hash="3715725d962c2e6520c4886e751ab17c"/></dir><file name="Eavattributegroup.php" hash="efa50980ce6469227fb004fefd9c2e44"/><dir name="Eavattributeoption"><file name="Collection.php" hash="71b08e4161b0bc46a56107e625886c00"/></dir><file name="Eavattributeoption.php" hash="eb3548f3521793ca7567d724a6cb2d1d"/><dir name="Eaventityattribute"><file name="Collection.php" hash="6f627e7a4231e38e947a102633dc9d12"/></dir><file name="Eaventityattribute.php" hash="22e8a22b30e865ae4fb3abe84aeb1a03"/><dir name="Externalcategorymappinginfo"><file name="Collection.php" hash="5f294010519be49c4367417d324e0340"/></dir><file name="Externalcategorymappinginfo.php" hash="6fa227ca2802ec35a4486c370a7f3fe2"/><file name="Setup.php" hash="b2dd43d46f0e87e100d708284139091f"/></dir><file name="Status.php" hash="f9e995fddd5b8059a80be0386b026759"/></dir><dir name="controllers"><dir name="Adminhtml"><file name="IndexController.php" hash="8375ab7d568d39bba8f742ba36c79efc"/></dir></dir><dir name="etc"><file name="adminhtml.xml" hash="0cbf9628390eef3e34fd93fb934e8acd"/><file name="config.xml" hash="1c9c8e5c47621bcae876f85f1376b361"/><file name="system.xml" hash="640f3ec7b8a35f65b9608e8bf246ed52"/></dir><dir name="sql"><dir name="customimport_setup"><file name="mysql4-install-0.1.0.php" hash="f51d9d4d6181e8a70a4d15096a357126"/></dir></dir></dir></dir></target><target name="magedesign"><dir name="adminhtml"><dir name="default"><dir name="default"><dir name="layout"><file name="customimport.xml" hash="58e97b28b754651736288d8f6d0e9231"/></dir><dir name="template"><dir name="gec"><dir name="catalog"><dir name="product"><dir name="attribute"><file name="options.phtml" hash="60f149a04ae1e60094c33b8ed85e51da"/></dir></dir></dir></dir><dir name="customimport"><file name="customimport.phtml" hash="f605decf69dc3aee88acb31ea5932ed6"/></dir></dir></dir></dir></dir></target><target name="mageetc"><dir name="modules"><file name="Gec_Customimport.xml" hash="40656ac88fc7f4129822fc98fa19a10e"/></dir></target></contents>
|
| 39 |
<compatible/>
|
| 40 |
<dependencies><required><php><min>5.4.0</min><max>5.5.30</max></php><package><name>Mage_Core_Modules</name><channel>community</channel><min>1.7.0.0</min><max>1.9.2.2</max></package><package><name/><channel>connect.magentocommerce.com/core</channel><min/><max/></package></required></dependencies>
|
| 41 |
</package>
|
