Version Notes
Bug-fix and improvements (Tested on Magento 1.9.x)
1. Fixed - Existing product-product relations (associations, related, cross-sell, up-sell) were being over-written when updates containing subset of relations were being imported.
2. Updated XML schema to better enclose attributes, attributegroups and attributesets.
3. Fixed import of text and textarea attributes for simple and configurable products and modified attribute value definitions accordingly.
4. Implemented import of position value for attribute options values.
5. Fixed import of non-configurable attributes for configurable products.
Download this release
Release Info
Developer | Vince Clark |
Extension | Gec_Customimport |
Version | 2.0.0.4 |
Comparing to | |
See all releases |
Code changes from version 2.0.0.3 to 2.0.0.4
app/code/local/Gec/Customimport/Block/Adminhtml/Customimport.php
CHANGED
@@ -1,7 +1,8 @@
|
|
1 |
<?php
|
2 |
/**
|
3 |
-
# Copyright (C) 2013 Global Era (http://www.globalera.com). All Rights Reserved
|
4 |
# @author Serenus Infotech <magento@serenusinfotech.com>
|
|
|
5 |
#
|
6 |
# This program is free software: you can redistribute it and/or modify
|
7 |
# it under the terms of the GNU Affero General Public License as
|
@@ -15,7 +16,8 @@
|
|
15 |
#
|
16 |
# You should have received a copy of the GNU Affero General Public License
|
17 |
# along with this program. If not, see <http://www.gnu.org/licenses/>.
|
18 |
-
**/
|
|
|
19 |
class Gec_Customimport_Block_Adminhtml_Customimport extends Gec_Customimport_Block_Adminhtml_Catalogimport
|
20 |
{
|
21 |
protected $customHelper;
|
@@ -96,8 +98,8 @@ class Gec_Customimport_Block_Adminhtml_Customimport extends Gec_Customimport_Blo
|
|
96 |
{
|
97 |
$xmlObj = $this->_xmlObj;
|
98 |
$xmlData = $xmlObj->getNode();
|
99 |
-
if ($xmlData->attributeConfiguration->attribute instanceof Varien_Simplexml_Element) {
|
100 |
-
return $xmlData->attributeConfiguration->attribute;
|
101 |
}
|
102 |
}
|
103 |
|
@@ -115,8 +117,8 @@ class Gec_Customimport_Block_Adminhtml_Customimport extends Gec_Customimport_Blo
|
|
115 |
{
|
116 |
$xmlObj = $this->_xmlObj;
|
117 |
$xmlData = $xmlObj->getNode();
|
118 |
-
if ($xmlData->attributeConfiguration->attributeSet instanceof Varien_Simplexml_Element) {
|
119 |
-
return $xmlData->attributeConfiguration->attributeSet;
|
120 |
}
|
121 |
}
|
122 |
|
@@ -191,8 +193,8 @@ class Gec_Customimport_Block_Adminhtml_Customimport extends Gec_Customimport_Blo
|
|
191 |
{
|
192 |
$xmlObj = $this->_xmlObj;
|
193 |
$xmlData = $xmlObj->getNode();
|
194 |
-
if ($xmlData->attributeConfiguration->attributeGroup instanceof Varien_Simplexml_Element) {
|
195 |
-
return $xmlData->attributeConfiguration->attributeGroup;
|
196 |
}
|
197 |
}
|
198 |
|
@@ -456,6 +458,40 @@ class Gec_Customimport_Block_Adminhtml_Customimport extends Gec_Customimport_Blo
|
|
456 |
$crossArray = array();
|
457 |
$associatedArray = array();
|
458 |
$bundleArray = array();
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
459 |
foreach ($associate->associatedProduct as $association) {
|
460 |
if ($association instanceof Varien_Simplexml_Element) { // if associatedProduct is an object in form of <associatedProduct>
|
461 |
unset($prid);
|
@@ -463,32 +499,73 @@ class Gec_Customimport_Block_Adminhtml_Customimport extends Gec_Customimport_Blo
|
|
463 |
if ($prid && (string) $association->isActive == 'Y') {
|
464 |
$position = (string) $association->position ? (string) $association->position : 0;
|
465 |
if ((string) $association->assocType == 0) {
|
466 |
-
$
|
467 |
'position' => $position
|
468 |
);
|
469 |
} else if ((string) $association->assocType == 1) {
|
470 |
-
$
|
471 |
'position' => $position
|
472 |
);
|
473 |
} else if ((string) $association->assocType == 2) {
|
474 |
-
$
|
475 |
'position' => $position
|
476 |
);
|
477 |
} else if ((string) $association->assocType == 3) {
|
478 |
-
$
|
479 |
$this->_changeVisibility($prid);
|
480 |
} else if ((string) $association->assocType == 4) {
|
481 |
$bundleArray[] = $prid;
|
482 |
$bundleQuantityArray[] = (int) $association->quantity;
|
483 |
$bundlePositionArray[] = (int) $position;
|
484 |
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
485 |
}
|
486 |
}
|
487 |
}
|
488 |
-
|
489 |
-
|
490 |
-
|
491 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
492 |
$proobj = Mage::getModel('catalog/product');
|
493 |
$productbundle = Mage::getModel('catalog/product')->setStoreId(0);
|
494 |
if ($productId) {
|
@@ -846,10 +923,10 @@ class Gec_Customimport_Block_Adminhtml_Customimport extends Gec_Customimport_Blo
|
|
846 |
foreach ($attributeValues->attribute as $attr) {
|
847 |
if (array_key_exists((string) $attr->id, $attributeOcuurance)) {
|
848 |
$attributeOcuurance[(string) $attr->id] = (int) $attributeOcuurance[(string) $attr->id] + 1;
|
849 |
-
$attrPos[(string) $attr->id] = (int) $attr->position;
|
850 |
} else {
|
851 |
$attributeOcuurance[(string) $attr->id] = $i;
|
852 |
-
$configAttributeValue[(string) $attr->id] = (string) $attr->valueDefId;
|
|
|
853 |
}
|
854 |
}
|
855 |
$config_attribute_array = array(); //attributes with single occurance
|
@@ -858,23 +935,23 @@ class Gec_Customimport_Block_Adminhtml_Customimport extends Gec_Customimport_Blo
|
|
858 |
$config_attribute_array[] = $key;
|
859 |
}
|
860 |
}
|
861 |
-
|
862 |
foreach ($config_attribute_array as $attr) {
|
863 |
-
$external_id = $configAttributeValue[$attr]; // valueDefId from XML for an attribute
|
864 |
$model = Mage::getModel('catalog/resource_eav_attribute');
|
865 |
$loadedattr = $model->loadByCode('catalog_product', $attr);
|
866 |
$attr_id = $loadedattr->getAttributeId(); // attribute id of magento
|
867 |
$attr_type = $loadedattr->getFrontendInput();
|
868 |
-
|
869 |
-
if ($attr_type == 'select') {
|
870 |
$mapObj = Mage::getModel('customimport/customimport');
|
871 |
$option_id = $mapObj->isOptionExistsInAttribute($external_id, $attr_id);
|
872 |
-
// $product->setData($attr, (string)$item->name);
|
873 |
if ($option_id) {
|
874 |
$product->setData($attr, $option_id);
|
875 |
}
|
876 |
-
} else
|
877 |
-
|
|
|
|
|
878 |
}
|
879 |
}
|
880 |
|
@@ -997,11 +1074,10 @@ class Gec_Customimport_Block_Adminhtml_Customimport extends Gec_Customimport_Blo
|
|
997 |
foreach ($attributeValues->attribute as $attr) {
|
998 |
if (array_key_exists((string) $attr->id, $attributeOcuurance)) {
|
999 |
$attributeOcuurance[(string) $attr->id] = (int) $attributeOcuurance[(string) $attr->id] + 1;
|
1000 |
-
$attrPos[(string) $attr->id] = (int) $attr->position;
|
1001 |
} else {
|
1002 |
$attributeOcuurance[(string) $attr->id] = $i;
|
1003 |
-
$configAttributeValue[(string) $attr->id] = (string) $attr->valueDefId;
|
1004 |
-
|
1005 |
}
|
1006 |
}
|
1007 |
$superattribute_array = array(); // attributes with multiple occurances
|
@@ -1033,7 +1109,6 @@ class Gec_Customimport_Block_Adminhtml_Customimport extends Gec_Customimport_Blo
|
|
1033 |
$attr_detail = array(
|
1034 |
'id' => NULL,
|
1035 |
'label' => "$attribute_label",
|
1036 |
-
'position' => $attrPos[$attr_id],
|
1037 |
'attribute_id' => $attr_id,
|
1038 |
'attribute_code' => "$attribute_code",
|
1039 |
'frontend_label' => "$attribute_label",
|
@@ -1046,20 +1121,21 @@ class Gec_Customimport_Block_Adminhtml_Customimport extends Gec_Customimport_Blo
|
|
1046 |
$product->setConfigurableAttributesData($attribute_detail);
|
1047 |
$product->setCanSaveConfigurableAttributes(1);
|
1048 |
foreach ($config_attribute_array as $attr) {
|
1049 |
-
$external_id = $configAttributeValue[$attr]; // valueDefId from XML for an attribute
|
1050 |
$model = Mage::getModel('catalog/resource_eav_attribute');
|
1051 |
$loadedattr = $model->loadByCode('catalog_product', $attr);
|
1052 |
$attr_id = $loadedattr->getAttributeId(); // attribute id of magento
|
1053 |
$attr_type = $loadedattr->getFrontendInput();
|
1054 |
-
if ($attr_type == 'select') {
|
1055 |
$mapObj = Mage::getModel('customimport/customimport');
|
1056 |
$option_id = $mapObj->isOptionExistsInAttribute($external_id, $attr_id);
|
1057 |
if ($option_id) {
|
1058 |
$product->setData($attr, $option_id);
|
1059 |
}
|
1060 |
-
} else
|
1061 |
{
|
1062 |
-
|
|
|
1063 |
}
|
1064 |
}
|
1065 |
try {
|
@@ -1202,18 +1278,26 @@ class Gec_Customimport_Block_Adminhtml_Customimport extends Gec_Customimport_Blo
|
|
1202 |
$configAttributeValue = array(); // will use to take value of attributes that ocuures once
|
1203 |
$multiple_values = array(); // stores an array of available values
|
1204 |
$i = 1;
|
|
|
1205 |
foreach ($attributeValues->attribute as $attr) {
|
|
|
|
|
1206 |
if (array_key_exists((string) $attr->id, $attributeOcuurance)) {
|
1207 |
$multiple_values[(string) $attr->id][] = (string) $attr->valueDefId;
|
1208 |
$attributeOcuurance[(string) $attr->id] = (int) $attributeOcuurance[(string) $attr->id] + 1;
|
|
|
|
|
|
|
1209 |
} else {
|
1210 |
$multiple_values[(string) $attr->id][] = (string) $attr->valueDefId;
|
1211 |
$attributeOcuurance[(string) $attr->id] = $i;
|
|
|
|
|
|
|
1212 |
}
|
1213 |
}
|
1214 |
$skipStatus = 0;
|
1215 |
foreach ($multiple_values as $attribute_code => $attribute_values) {
|
1216 |
-
$model = Mage::getModel('catalog/resource_eav_attribute');
|
1217 |
$loadedattr = $model->loadByCode('catalog_product', $attribute_code);
|
1218 |
$attr_id = $loadedattr->getAttributeId(); // attribute id of magento
|
1219 |
if (!$attr_id) {
|
@@ -1250,8 +1334,7 @@ class Gec_Customimport_Block_Adminhtml_Customimport extends Gec_Customimport_Blo
|
|
1250 |
}
|
1251 |
|
1252 |
if ($attr_type == 'text' || $attr_type == 'textarea') {
|
1253 |
-
$
|
1254 |
-
$product->setData($attribute_code, $optVal->getValue());
|
1255 |
} else if ($attr_type == 'boolean') {
|
1256 |
$optVal = Mage::getSingleton('customimport/customimport')->getOptVal($attribute_values[0]);
|
1257 |
if (strtolower($optVal->getValue()) == 'y' || strtolower($optVal->getValue()) == 'yes') {
|
@@ -1461,19 +1544,26 @@ class Gec_Customimport_Block_Adminhtml_Customimport extends Gec_Customimport_Blo
|
|
1461 |
$configAttributeValue = array(); // will use to take value of attributes that ocuures once
|
1462 |
$multiple_values = array();
|
1463 |
$i = 1;
|
|
|
1464 |
foreach ($attributeValues->attribute as $attr) {
|
|
|
|
|
1465 |
if (array_key_exists((string) $attr->id, $attributeOcuurance)) {
|
1466 |
$multiple_values[(string) $attr->id][] = (string) $attr->valueDefId;
|
1467 |
$attributeOcuurance[(string) $attr->id] = (int) $attributeOcuurance[(string) $attr->id] + 1;
|
|
|
|
|
|
|
1468 |
} else {
|
1469 |
$multiple_values[(string) $attr->id][] = (string) $attr->valueDefId;
|
1470 |
$attributeOcuurance[(string) $attr->id] = $i;
|
1471 |
-
|
|
|
|
|
1472 |
}
|
1473 |
}
|
1474 |
$skipStatus = 0;
|
1475 |
foreach ($multiple_values as $attribute_code => $attribute_values) {
|
1476 |
-
$model = Mage::getModel('catalog/resource_eav_attribute');
|
1477 |
$loadedattr = $model->loadByCode('catalog_product', $attribute_code);
|
1478 |
$attr_id = $loadedattr->getAttributeId(); // attribute id of magento
|
1479 |
if (!$attr_id) {
|
@@ -1507,8 +1597,7 @@ class Gec_Customimport_Block_Adminhtml_Customimport extends Gec_Customimport_Blo
|
|
1507 |
));
|
1508 |
}
|
1509 |
if ($attr_type == 'text' || $attr_type == 'textarea') { // if type is text/textarea
|
1510 |
-
$
|
1511 |
-
$product->setData($attribute_code, $optVal->getValue());
|
1512 |
} else if ($attr_type == 'boolean') {
|
1513 |
$optVal = Mage::getSingleton('customimport/customimport')->getOptVal($attribute_values[0]);
|
1514 |
if (strtolower($optVal->getValue()) == 'y' || strtolower($optVal->getValue()) == 'yes') {
|
@@ -2026,18 +2115,17 @@ class Gec_Customimport_Block_Adminhtml_Customimport extends Gec_Customimport_Blo
|
|
2026 |
if ($attr_id != '') {
|
2027 |
$attr->addData($_attribute_data);
|
2028 |
$option['attribute_id'] = $attr_id;
|
2029 |
-
|
2030 |
-
if ($count_value > 0 && ($attribute_type == 'select' || $attribute_type == 'multiselect' || $attribute_type == 'text' || $attribute_type == 'textarea' || $attribute_type == 'boolean')) {
|
2031 |
for ($i = 0; $i < $count_value; $i++) {
|
2032 |
$attrdet = $attr_values['valueDef'][$i];
|
2033 |
$optionId = $mapobj->isOptionExistsInAttribute($attrdet->id, $attr_id);
|
2034 |
if (!isset($optionId)) {
|
2035 |
$option['value']['option_' . $i][0] = $attrdet->value;
|
2036 |
-
$option['order']['option_' . $i] = $
|
2037 |
$option['externalid']['option_' . $i] = $attrdet->id;
|
2038 |
} else {
|
2039 |
$option['value'][$optionId][0] = $attrdet->value;
|
2040 |
-
$option['order'][$optionId] = $
|
2041 |
$option['externalid'][$optionId] = $attrdet->id;
|
2042 |
}
|
2043 |
$attr->setOption($option);
|
@@ -2079,11 +2167,11 @@ class Gec_Customimport_Block_Adminhtml_Customimport extends Gec_Customimport_Blo
|
|
2079 |
$optionId = $mapobj->isOptionExistsInAttribute($attrdet->id, $attr_id);
|
2080 |
if (!isset($optionId)) {
|
2081 |
$option['value']['option_' . $i][0] = $attrdet->value;
|
2082 |
-
$option['order']['option_' . $i] = $
|
2083 |
$option['externalid']['option_' . $i] = $attrdet->id;
|
2084 |
} else {
|
2085 |
$option['value'][$optionId][0] = $attrdet->value;
|
2086 |
-
$option['order'][$optionId] = $
|
2087 |
$option['externalid'][$optionId] = $attrdet->id;
|
2088 |
}
|
2089 |
}
|
1 |
<?php
|
2 |
/**
|
3 |
+
# Copyright (C) 2013-2015 Global Era Commerce (http://www.globalera.com). All Rights Reserved
|
4 |
# @author Serenus Infotech <magento@serenusinfotech.com>
|
5 |
+
# @author Intelliant <magento@intelliant.net>
|
6 |
#
|
7 |
# This program is free software: you can redistribute it and/or modify
|
8 |
# it under the terms of the GNU Affero General Public License as
|
16 |
#
|
17 |
# You should have received a copy of the GNU Affero General Public License
|
18 |
# along with this program. If not, see <http://www.gnu.org/licenses/>.
|
19 |
+
**/
|
20 |
+
|
21 |
class Gec_Customimport_Block_Adminhtml_Customimport extends Gec_Customimport_Block_Adminhtml_Catalogimport
|
22 |
{
|
23 |
protected $customHelper;
|
98 |
{
|
99 |
$xmlObj = $this->_xmlObj;
|
100 |
$xmlData = $xmlObj->getNode();
|
101 |
+
if ($xmlData->attributeConfiguration->attributes->attribute instanceof Varien_Simplexml_Element) {
|
102 |
+
return $xmlData->attributeConfiguration->attributes->attribute;
|
103 |
}
|
104 |
}
|
105 |
|
117 |
{
|
118 |
$xmlObj = $this->_xmlObj;
|
119 |
$xmlData = $xmlObj->getNode();
|
120 |
+
if ($xmlData->attributeConfiguration->attributeSets->attributeSet instanceof Varien_Simplexml_Element) {
|
121 |
+
return $xmlData->attributeConfiguration->attributeSets->attributeSet;
|
122 |
}
|
123 |
}
|
124 |
|
193 |
{
|
194 |
$xmlObj = $this->_xmlObj;
|
195 |
$xmlData = $xmlObj->getNode();
|
196 |
+
if ($xmlData->attributeConfiguration->attributeGroups->attributeGroup instanceof Varien_Simplexml_Element) {
|
197 |
+
return $xmlData->attributeConfiguration->attributeGroups->attributeGroup;
|
198 |
}
|
199 |
}
|
200 |
|
458 |
$crossArray = array();
|
459 |
$associatedArray = array();
|
460 |
$bundleArray = array();
|
461 |
+
$preAssociatedArray = array();
|
462 |
+
$disAssociateArray = array();
|
463 |
+
$preRelatedArray = array();
|
464 |
+
$preUpsellArray = array();
|
465 |
+
$preCrossArray = array();
|
466 |
+
|
467 |
+
if ($mainProduct->getTypeId() == "configurable") {
|
468 |
+
$configurable = Mage::getModel('catalog/product_type_configurable')->setProduct($mainProduct);
|
469 |
+
$simpleCollection = $configurable->getUsedProductCollection()->addAttributeToSelect('*')->addFilterByRequiredOptions();
|
470 |
+
foreach($simpleCollection as $simpleProduct){
|
471 |
+
$preAssociatedArray[] = $simpleProduct->getId();
|
472 |
+
}
|
473 |
+
}
|
474 |
+
|
475 |
+
$relatedCollection = $mainProduct->getRelatedLinkCollection();
|
476 |
+
foreach($relatedCollection as $item){
|
477 |
+
$preRelatedArray[$item->getLinkedProductId()] = array(
|
478 |
+
'position' => $item->getPosition()
|
479 |
+
);
|
480 |
+
}
|
481 |
+
|
482 |
+
$upsellCollection = $mainProduct->getUpSellLinkCollection();
|
483 |
+
foreach($upsellCollection as $item){
|
484 |
+
$preUpsellArray[$item->getLinkedProductId()] = array(
|
485 |
+
'position' => $item->getPosition()
|
486 |
+
);
|
487 |
+
}
|
488 |
+
|
489 |
+
$crossCollection = $mainProduct->getCrossSellLinkCollection();
|
490 |
+
foreach($crossCollection as $item){
|
491 |
+
$preCrossArray[$item->getLinkedProductId()] = array(
|
492 |
+
'position' => $item->getPosition()
|
493 |
+
);
|
494 |
+
}
|
495 |
foreach ($associate->associatedProduct as $association) {
|
496 |
if ($association instanceof Varien_Simplexml_Element) { // if associatedProduct is an object in form of <associatedProduct>
|
497 |
unset($prid);
|
499 |
if ($prid && (string) $association->isActive == 'Y') {
|
500 |
$position = (string) $association->position ? (string) $association->position : 0;
|
501 |
if ((string) $association->assocType == 0) {
|
502 |
+
$preCrossArray[$prid] = array(
|
503 |
'position' => $position
|
504 |
);
|
505 |
} else if ((string) $association->assocType == 1) {
|
506 |
+
$preUpsellArray[$prid] = array(
|
507 |
'position' => $position
|
508 |
);
|
509 |
} else if ((string) $association->assocType == 2) {
|
510 |
+
$preRelatedArray[$prid] = array(
|
511 |
'position' => $position
|
512 |
);
|
513 |
} else if ((string) $association->assocType == 3) {
|
514 |
+
$preAssociatedArray[] = $prid;
|
515 |
$this->_changeVisibility($prid);
|
516 |
} else if ((string) $association->assocType == 4) {
|
517 |
$bundleArray[] = $prid;
|
518 |
$bundleQuantityArray[] = (int) $association->quantity;
|
519 |
$bundlePositionArray[] = (int) $position;
|
520 |
}
|
521 |
+
} else if($prid && strtolower((string) $association->isActive) == 'n') {
|
522 |
+
if ((string) $association->assocType == 0) {
|
523 |
+
$crossArray[$prid] = array(
|
524 |
+
'position' => $position
|
525 |
+
);
|
526 |
+
} else if ((string) $association->assocType == 1) {
|
527 |
+
$upsellArray[$prid] = array(
|
528 |
+
'position' => $position
|
529 |
+
);
|
530 |
+
} else if ((string) $association->assocType == 2) {
|
531 |
+
$relatedArray[$prid] = array(
|
532 |
+
'position' => $position
|
533 |
+
);
|
534 |
+
} else if ((string) $association->assocType == 3) {
|
535 |
+
$disAssociateArray[] = $prid;
|
536 |
+
}
|
537 |
}
|
538 |
}
|
539 |
}
|
540 |
+
|
541 |
+
if(is_array($preAssociatedArray) && count($preAssociatedArray) > 0){
|
542 |
+
$associatedArray = array_unique(array_diff($preAssociatedArray, $disAssociateArray));
|
543 |
+
}
|
544 |
+
|
545 |
+
foreach($preRelatedArray as $preRelatedkey => $relatedPro){
|
546 |
+
if (array_key_exists($preRelatedkey,$relatedArray)){
|
547 |
+
unset($preRelatedArray[$preRelatedkey]);
|
548 |
+
}
|
549 |
+
}
|
550 |
+
|
551 |
+
foreach($preUpsellArray as $preUpsellkey => $upsellPro){
|
552 |
+
if (array_key_exists($preUpsellkey,$upsellArray)){
|
553 |
+
unset($preUpsellArray[$preUpsellkey]);
|
554 |
+
}
|
555 |
+
}
|
556 |
+
|
557 |
+
foreach($preCrossArray as $preCrosskey => $crossPro){
|
558 |
+
if (array_key_exists($preCrosskey,$crossArray)){
|
559 |
+
unset($preCrossArray[$preCrosskey]);
|
560 |
+
}
|
561 |
+
}
|
562 |
+
|
563 |
+
$mainProduct->setCrossSellLinkData($preCrossArray);
|
564 |
+
$mainProduct->setUpSellLinkData($preUpsellArray);
|
565 |
+
$mainProduct->setRelatedLinkData($preRelatedArray);
|
566 |
+
$mainProduct->save();
|
567 |
+
|
568 |
+
if (count($bundleArray) > 0) {
|
569 |
$proobj = Mage::getModel('catalog/product');
|
570 |
$productbundle = Mage::getModel('catalog/product')->setStoreId(0);
|
571 |
if ($productId) {
|
923 |
foreach ($attributeValues->attribute as $attr) {
|
924 |
if (array_key_exists((string) $attr->id, $attributeOcuurance)) {
|
925 |
$attributeOcuurance[(string) $attr->id] = (int) $attributeOcuurance[(string) $attr->id] + 1;
|
|
|
926 |
} else {
|
927 |
$attributeOcuurance[(string) $attr->id] = $i;
|
928 |
+
$configAttributeValue[(string) $attr->id][] = (string) $attr->valueDefId;
|
929 |
+
$configAttributeValue[(string) $attr->id][] = (string) $attr->value;
|
930 |
}
|
931 |
}
|
932 |
$config_attribute_array = array(); //attributes with single occurance
|
935 |
$config_attribute_array[] = $key;
|
936 |
}
|
937 |
}
|
938 |
+
|
939 |
foreach ($config_attribute_array as $attr) {
|
940 |
+
$external_id = $configAttributeValue[$attr][0]; // valueDefId from XML for an attribute
|
941 |
$model = Mage::getModel('catalog/resource_eav_attribute');
|
942 |
$loadedattr = $model->loadByCode('catalog_product', $attr);
|
943 |
$attr_id = $loadedattr->getAttributeId(); // attribute id of magento
|
944 |
$attr_type = $loadedattr->getFrontendInput();
|
945 |
+
if ($attr_type == 'select' || $attr_type == 'multiselect' || $attr_type == 'boolean') {
|
|
|
946 |
$mapObj = Mage::getModel('customimport/customimport');
|
947 |
$option_id = $mapObj->isOptionExistsInAttribute($external_id, $attr_id);
|
|
|
948 |
if ($option_id) {
|
949 |
$product->setData($attr, $option_id);
|
950 |
}
|
951 |
+
} else if ($attr_type == 'text' || $attr_type == 'textarea')
|
952 |
+
{
|
953 |
+
$attr_value = $configAttributeValue[$attr][1];
|
954 |
+
$product->setData($attr, $attr_value);
|
955 |
}
|
956 |
}
|
957 |
|
1074 |
foreach ($attributeValues->attribute as $attr) {
|
1075 |
if (array_key_exists((string) $attr->id, $attributeOcuurance)) {
|
1076 |
$attributeOcuurance[(string) $attr->id] = (int) $attributeOcuurance[(string) $attr->id] + 1;
|
|
|
1077 |
} else {
|
1078 |
$attributeOcuurance[(string) $attr->id] = $i;
|
1079 |
+
$configAttributeValue[(string) $attr->id][] = (string) $attr->valueDefId;
|
1080 |
+
$configAttributeValue[(String) $attr->id][] = (String) $attr->value;
|
1081 |
}
|
1082 |
}
|
1083 |
$superattribute_array = array(); // attributes with multiple occurances
|
1109 |
$attr_detail = array(
|
1110 |
'id' => NULL,
|
1111 |
'label' => "$attribute_label",
|
|
|
1112 |
'attribute_id' => $attr_id,
|
1113 |
'attribute_code' => "$attribute_code",
|
1114 |
'frontend_label' => "$attribute_label",
|
1121 |
$product->setConfigurableAttributesData($attribute_detail);
|
1122 |
$product->setCanSaveConfigurableAttributes(1);
|
1123 |
foreach ($config_attribute_array as $attr) {
|
1124 |
+
$external_id = $configAttributeValue[$attr][0]; // valueDefId from XML for an attribute
|
1125 |
$model = Mage::getModel('catalog/resource_eav_attribute');
|
1126 |
$loadedattr = $model->loadByCode('catalog_product', $attr);
|
1127 |
$attr_id = $loadedattr->getAttributeId(); // attribute id of magento
|
1128 |
$attr_type = $loadedattr->getFrontendInput();
|
1129 |
+
if ($attr_type == 'select' || $attr_type == 'multiselect' || $attr_type == 'boolean') {
|
1130 |
$mapObj = Mage::getModel('customimport/customimport');
|
1131 |
$option_id = $mapObj->isOptionExistsInAttribute($external_id, $attr_id);
|
1132 |
if ($option_id) {
|
1133 |
$product->setData($attr, $option_id);
|
1134 |
}
|
1135 |
+
} else if ($attr_type == 'text' || $attr_type == 'textarea')
|
1136 |
{
|
1137 |
+
$attr_value = $configAttributeValue[$attr][1];
|
1138 |
+
$product->setData($attr, $attr_value);
|
1139 |
}
|
1140 |
}
|
1141 |
try {
|
1278 |
$configAttributeValue = array(); // will use to take value of attributes that ocuures once
|
1279 |
$multiple_values = array(); // stores an array of available values
|
1280 |
$i = 1;
|
1281 |
+
$model = Mage::getModel('catalog/resource_eav_attribute');
|
1282 |
foreach ($attributeValues->attribute as $attr) {
|
1283 |
+
$loadedattr = $model->loadByCode('catalog_product', (string) $attr->id);
|
1284 |
+
$attr_type = $loadedattr->getFrontendInput();
|
1285 |
if (array_key_exists((string) $attr->id, $attributeOcuurance)) {
|
1286 |
$multiple_values[(string) $attr->id][] = (string) $attr->valueDefId;
|
1287 |
$attributeOcuurance[(string) $attr->id] = (int) $attributeOcuurance[(string) $attr->id] + 1;
|
1288 |
+
if($attr_type == 'text' || $attr_type == 'textarea'){
|
1289 |
+
$multiple_values[(string) $attr->id][] = (string) $attr->value;
|
1290 |
+
}
|
1291 |
} else {
|
1292 |
$multiple_values[(string) $attr->id][] = (string) $attr->valueDefId;
|
1293 |
$attributeOcuurance[(string) $attr->id] = $i;
|
1294 |
+
if($attr_type == 'text' || $attr_type == 'textarea'){
|
1295 |
+
$multiple_values[(string) $attr->id][] = (string) $attr->value;
|
1296 |
+
}
|
1297 |
}
|
1298 |
}
|
1299 |
$skipStatus = 0;
|
1300 |
foreach ($multiple_values as $attribute_code => $attribute_values) {
|
|
|
1301 |
$loadedattr = $model->loadByCode('catalog_product', $attribute_code);
|
1302 |
$attr_id = $loadedattr->getAttributeId(); // attribute id of magento
|
1303 |
if (!$attr_id) {
|
1334 |
}
|
1335 |
|
1336 |
if ($attr_type == 'text' || $attr_type == 'textarea') {
|
1337 |
+
$product->setData($attribute_code, $attribute_values[1]);
|
|
|
1338 |
} else if ($attr_type == 'boolean') {
|
1339 |
$optVal = Mage::getSingleton('customimport/customimport')->getOptVal($attribute_values[0]);
|
1340 |
if (strtolower($optVal->getValue()) == 'y' || strtolower($optVal->getValue()) == 'yes') {
|
1544 |
$configAttributeValue = array(); // will use to take value of attributes that ocuures once
|
1545 |
$multiple_values = array();
|
1546 |
$i = 1;
|
1547 |
+
$model = Mage::getModel('catalog/resource_eav_attribute');
|
1548 |
foreach ($attributeValues->attribute as $attr) {
|
1549 |
+
$loadedattr = $model->loadByCode('catalog_product', (string) $attr->id);
|
1550 |
+
$attr_type = $loadedattr->getFrontendInput();
|
1551 |
if (array_key_exists((string) $attr->id, $attributeOcuurance)) {
|
1552 |
$multiple_values[(string) $attr->id][] = (string) $attr->valueDefId;
|
1553 |
$attributeOcuurance[(string) $attr->id] = (int) $attributeOcuurance[(string) $attr->id] + 1;
|
1554 |
+
if($attr_type == 'text' || $attr_type == 'textarea'){
|
1555 |
+
$multiple_values[(string) $attr->id][] = (string) $attr->value;
|
1556 |
+
}
|
1557 |
} else {
|
1558 |
$multiple_values[(string) $attr->id][] = (string) $attr->valueDefId;
|
1559 |
$attributeOcuurance[(string) $attr->id] = $i;
|
1560 |
+
if($attr_type == 'text' || $attr_type == 'textarea'){
|
1561 |
+
$multiple_values[(string) $attr->id][] = (string) $attr->value;
|
1562 |
+
}
|
1563 |
}
|
1564 |
}
|
1565 |
$skipStatus = 0;
|
1566 |
foreach ($multiple_values as $attribute_code => $attribute_values) {
|
|
|
1567 |
$loadedattr = $model->loadByCode('catalog_product', $attribute_code);
|
1568 |
$attr_id = $loadedattr->getAttributeId(); // attribute id of magento
|
1569 |
if (!$attr_id) {
|
1597 |
));
|
1598 |
}
|
1599 |
if ($attr_type == 'text' || $attr_type == 'textarea') { // if type is text/textarea
|
1600 |
+
$product->setData($attribute_code, $attribute_values[1]);
|
|
|
1601 |
} else if ($attr_type == 'boolean') {
|
1602 |
$optVal = Mage::getSingleton('customimport/customimport')->getOptVal($attribute_values[0]);
|
1603 |
if (strtolower($optVal->getValue()) == 'y' || strtolower($optVal->getValue()) == 'yes') {
|
2115 |
if ($attr_id != '') {
|
2116 |
$attr->addData($_attribute_data);
|
2117 |
$option['attribute_id'] = $attr_id;
|
2118 |
+
if ($count_value > 0 && ($attribute_type == 'select' || $attribute_type == 'multiselect' || $attribute_type == 'boolean')) {
|
|
|
2119 |
for ($i = 0; $i < $count_value; $i++) {
|
2120 |
$attrdet = $attr_values['valueDef'][$i];
|
2121 |
$optionId = $mapobj->isOptionExistsInAttribute($attrdet->id, $attr_id);
|
2122 |
if (!isset($optionId)) {
|
2123 |
$option['value']['option_' . $i][0] = $attrdet->value;
|
2124 |
+
$option['order']['option_' . $i] = $attrdet->position;
|
2125 |
$option['externalid']['option_' . $i] = $attrdet->id;
|
2126 |
} else {
|
2127 |
$option['value'][$optionId][0] = $attrdet->value;
|
2128 |
+
$option['order'][$optionId] = $attrdet->position;
|
2129 |
$option['externalid'][$optionId] = $attrdet->id;
|
2130 |
}
|
2131 |
$attr->setOption($option);
|
2167 |
$optionId = $mapobj->isOptionExistsInAttribute($attrdet->id, $attr_id);
|
2168 |
if (!isset($optionId)) {
|
2169 |
$option['value']['option_' . $i][0] = $attrdet->value;
|
2170 |
+
$option['order']['option_' . $i] = $attrdet->position;
|
2171 |
$option['externalid']['option_' . $i] = $attrdet->id;
|
2172 |
} else {
|
2173 |
$option['value'][$optionId][0] = $attrdet->value;
|
2174 |
+
$option['order'][$optionId] = $attrdet->position;
|
2175 |
$option['externalid'][$optionId] = $attrdet->id;
|
2176 |
}
|
2177 |
}
|
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,34 +28,21 @@ 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>
|
32 |

|
33 |
-
|
34 |

|
35 |
-
|
36 |

|
37 |
-
|
38 |

|
39 |
-
|
40 |

|
41 |
-
|
42 |
-

|
43 |
-
1. Default turning off visibility in search results for simple products associated to configurable ones.
|
44 |
-

|
45 |
-
2. Import of special price and related dates to enable scheduling of sale pricing.
|
46 |
-

|
47 |
-
3. Inventory control - ATP quantity and ability to control back-ordering of products.
|
48 |
-

|
49 |
-
4. Several major logging improvements.
|
50 |
-

|
51 |
-
5. Improved error-handling, data error tolerance and reporting for missing elements in the import file. Report the issue and continue with the next element instead of aborting the process.
|
52 |
-

|
53 |
-
6. Performance improvements related to categories and attributes import.
|
54 |
-
</notes>
|
55 |
<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>
|
56 |
-
<date>2015-12-
|
57 |
-
<time>
|
58 |
-
<contents><target name="magelocal"><dir name="Gec"><dir name="Customimport"><dir name="Block"><dir name="Adminhtml"><file name="Catalogimport.php" hash="ee6d4d26cb3e2761c73384b5e64c2076"/><file name="Customimport.php" hash="
|
59 |
<compatible/>
|
60 |
-
<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
|
61 |
</package>
|
1 |
<?xml version="1.0"?>
|
2 |
<package>
|
3 |
<name>Gec_Customimport</name>
|
4 |
+
<version>2.0.0.4</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 and improvements (Tested on Magento 1.9.x)
|
32 |

|
33 |
+
1. Fixed - Existing product-product relations (associations, related, cross-sell, up-sell) were being over-written when updates containing subset of relations were being imported.
|
34 |

|
35 |
+
2. Updated XML schema to better enclose attributes, attributegroups and attributesets.
|
36 |

|
37 |
+
3. Fixed import of text and textarea attributes for simple and configurable products and modified attribute value definitions accordingly.
|
38 |

|
39 |
+
4. Implemented import of position value for attribute options values.
|
40 |

|
41 |
+
5. Fixed import of non-configurable attributes for configurable products.</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-12</date>
|
44 |
+
<time>07:47:32</time>
|
45 |
+
<contents><target name="magelocal"><dir name="Gec"><dir name="Customimport"><dir name="Block"><dir name="Adminhtml"><file name="Catalogimport.php" hash="ee6d4d26cb3e2761c73384b5e64c2076"/><file name="Customimport.php" hash="fe74c3469c0644cce2488bf139e8a09b"/></dir><dir name="Catalog"><dir name="Product"><dir name="Attribute"><dir name="Edit"><dir name="Tab"><file name="Options.php" hash="48eb00080ff3d4a2dabf9f6ed3c4f0de"/></dir></dir></dir></dir></dir></dir><dir name="Helper"><dir name="Catalog"><file name="Image.php" hash="c259ada8399c0a869a051d1b7c547c10"/></dir><file name="Data.php" hash="8490506d8a9b9938cacfaad66362ab89"/></dir><dir name="Model"><file name="Attrgroup.php" hash="86a327bf1a25b7eba1ad80562f2c501f"/><file name="Attrsetmapping.php" hash="62331110f2ca033c9f5ce2153156e6ba"/><dir name="Catalog"><dir name="Resource"><dir name="Eav"><dir name="Mysql4"><file name="Attribute.php" hash="4d76fa412eb1ab2ebf985ffc1c47aba3"/></dir></dir></dir></dir><file name="Catalogentity.php" hash="2d13b0be393feb623bda33ecc2d41e8e"/><file name="Customimport.php" hash="a1220c38c4dba8837ee81cc050d7bb36"/><file name="Eavattributegroup.php" hash="9bba68ded711a3310787a7578a613d29"/><file name="Eavattributeoption.php" hash="bb6b70ae5077607ce8a2d3494696eb0f"/><file name="Eaventityattribute.php" hash="af01fe556787a14cfa4528bbc77c2cf8"/><file name="Externalcategorymappinginfo.php" hash="6463a500908e4f4fc56640afe950bd72"/><dir name="Mysql4"><dir name="Attrgroup"><file name="Collection.php" hash="cf2aeb119b1a00bda6fbb9ec4400e22e"/></dir><file name="Attrgroup.php" hash="e6eef5397a72447494313f5aa08b6396"/><dir name="Attrsetmapping"><file name="Collection.php" hash="82fb958991fd44cd09fd3f1bc8542704"/></dir><file name="Attrsetmapping.php" hash="b249625624c986eaed9fa16bfe700d03"/><dir name="Catalogentity"><file name="Collection.php" hash="1bd3fb627e7d204528fe9f147aff289e"/></dir><file name="Catalogentity.php" hash="d22449c6577a4601cd72c2c9e7eb8a1a"/><dir name="Customimport"><file name="Collection.php" hash="1e898a23cac9c3dce0bae079576c3647"/></dir><file name="Customimport.php" hash="8e1b5d21a29149d7b705d55252087d0d"/><dir name="Eavattributegroup"><file name="Collection.php" hash="d4f41930aabd0f9bffe144a8300aac97"/></dir><file name="Eavattributegroup.php" hash="77039ce31e5368e8b18a951cb1fac8ce"/><dir name="Eavattributeoption"><file name="Collection.php" hash="faa0ba2294bca2e74063ac869215bcbe"/></dir><file name="Eavattributeoption.php" hash="c8d9f44e390d64bd1af0e8c4dc86e8f6"/><dir name="Eaventityattribute"><file name="Collection.php" hash="8dd0dd41e5c4df79963dcba325e2e7f3"/></dir><file name="Eaventityattribute.php" hash="ee92de3640f29e66622af0b58eec56a7"/><dir name="Externalcategorymappinginfo"><file name="Collection.php" hash="503471182e7f4babf340e0bb08bb6311"/></dir><file name="Externalcategorymappinginfo.php" hash="4548556d997eb8f08ad9a141c9dc11dc"/><file name="Setup.php" hash="1e5b593b53599d605774d31d3fa63bb2"/></dir><file name="Status.php" hash="b241452a94455ceb89afc7ed17252b84"/></dir><dir name="controllers"><dir name="Adminhtml"><file name="IndexController.php" hash="0196d4ba3d36abba756e60f9d75cb5d1"/></dir></dir><dir name="etc"><file name="adminhtml.xml" hash="5b20522ba1ad223a13a6b193b0312ebb"/><file name="config.xml" hash="0006aa368de798444a99be27293ce47f"/><file name="system.xml" hash="b87fa034807a671992b211d6cbfd1d7b"/></dir><dir name="sql"><dir name="customimport_setup"><file name="mysql4-install-0.1.0.php" hash="cc714904399b6ad061834b36857fdca9"/></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="10940f1e0d06ca177755254d39d499a4"/></dir></dir></dir></dir><dir name="customimport"><file name="customimport.phtml" hash="1e68c8e3cb71abf09b16c474ffef1ae4"/></dir></dir></dir></dir></dir></target><target name="mageetc"><dir name="modules"><file name="Gec_Customimport.xml" hash="f2da24afaca09dc23fcf34d9ee3dd8c5"/></dir></target></contents>
|
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>
|