Version Notes
First Preview Release
Download this release
Release Info
| Developer | Soham Chakraborty |
| Extension | Gec_Customimport |
| Version | 1.0.0.1 |
| Comparing to | |
| See all releases | |
Version 1.0.0.1
- app/code/community/Gec/Customimport/Block/Catalog/Product/Attribute/Edit/Tab/Options.php +86 -0
- app/code/community/Gec/Customimport/Block/Catalogimport.php +41 -0
- app/code/community/Gec/Customimport/Block/Customimport.php +1563 -0
- app/code/community/Gec/Customimport/Helper/Catalog/Image.php +141 -0
- app/code/community/Gec/Customimport/Helper/Data.php +23 -0
- app/code/community/Gec/Customimport/Model/Attrgroup.php +30 -0
- app/code/community/Gec/Customimport/Model/Attrsetmapping.php +30 -0
- app/code/community/Gec/Customimport/Model/Catalog/Resource/Eav/Mysql4/Attribute.php +105 -0
- app/code/community/Gec/Customimport/Model/Catalogentity.php +30 -0
- app/code/community/Gec/Customimport/Model/Customimport.php +140 -0
- app/code/community/Gec/Customimport/Model/Eavattributegroup.php +30 -0
- app/code/community/Gec/Customimport/Model/Eavattributeoption.php +30 -0
- app/code/community/Gec/Customimport/Model/Eaventityattribute.php +30 -0
- app/code/community/Gec/Customimport/Model/Externalcategorymappinginfo.php +30 -0
- app/code/community/Gec/Customimport/Model/Mysql4/Attrgroup.php +28 -0
- app/code/community/Gec/Customimport/Model/Mysql4/Attrgroup/Collection.php +26 -0
- app/code/community/Gec/Customimport/Model/Mysql4/Attrsetmapping.php +32 -0
- app/code/community/Gec/Customimport/Model/Mysql4/Attrsetmapping/Collection.php +26 -0
- app/code/community/Gec/Customimport/Model/Mysql4/Catalogentity.php +31 -0
- app/code/community/Gec/Customimport/Model/Mysql4/Catalogentity/Collection.php +26 -0
- app/code/community/Gec/Customimport/Model/Mysql4/Customimport.php +27 -0
- app/code/community/Gec/Customimport/Model/Mysql4/Customimport/Collection.php +26 -0
- app/code/community/Gec/Customimport/Model/Mysql4/Eavattributegroup.php +29 -0
- app/code/community/Gec/Customimport/Model/Mysql4/Eavattributegroup/Collection.php +26 -0
- app/code/community/Gec/Customimport/Model/Mysql4/Eavattributeoption.php +31 -0
- app/code/community/Gec/Customimport/Model/Mysql4/Eavattributeoption/Collection.php +26 -0
- app/code/community/Gec/Customimport/Model/Mysql4/Eaventityattribute.php +31 -0
- app/code/community/Gec/Customimport/Model/Mysql4/Eaventityattribute/Collection.php +26 -0
- app/code/community/Gec/Customimport/Model/Mysql4/Externalcategorymappinginfo.php +31 -0
- app/code/community/Gec/Customimport/Model/Mysql4/Externalcategorymappinginfo/Collection.php +26 -0
- app/code/community/Gec/Customimport/Model/Mysql4/Setup.php +22 -0
- app/code/community/Gec/Customimport/Model/Status.php +39 -0
- app/code/community/Gec/Customimport/controllers/IndexController.php +29 -0
- app/code/community/Gec/Customimport/etc/config.xml +135 -0
- app/code/community/Gec/Customimport/sql/customimport_setup/mysql4-install-0.1.0.php +192 -0
- app/design/adminhtml/default/default/template/gec/catalog/product/attribute/options.phtml +203 -0
- app/design/frontend/default/default/layout/customimport.xml +64 -0
- app/design/frontend/default/default/template/customimport/catalog/category/view.phtml +66 -0
- app/design/frontend/default/default/template/customimport/catalog/product/view/media.phtml +102 -0
- app/design/frontend/default/default/template/customimport/customimport.phtml +102 -0
- app/etc/modules/Gec_Customimport.xml +29 -0
- package.xml +21 -0
app/code/community/Gec/Customimport/Block/Catalog/Product/Attribute/Edit/Tab/Options.php
ADDED
|
@@ -0,0 +1,86 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 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
|
| 8 |
+
# published by the Free Software Foundation, either version 3 of the
|
| 9 |
+
# License, or (at your option) any later version.
|
| 10 |
+
#
|
| 11 |
+
# This program is distributed in the hope that it will be useful,
|
| 12 |
+
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
| 13 |
+
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
| 14 |
+
# GNU Affero General Public License for more details.
|
| 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 |
+
|
| 20 |
+
class Gec_Customimport_Block_Catalog_Product_Attribute_Edit_Tab_Options extends Mage_Adminhtml_Block_Catalog_Product_Attribute_Edit_Tab_Options
|
| 21 |
+
{
|
| 22 |
+
public function __construct()
|
| 23 |
+
{
|
| 24 |
+
parent::__construct();
|
| 25 |
+
$this->setTemplate('gec/catalog/product/attribute/options.phtml');
|
| 26 |
+
}
|
| 27 |
+
|
| 28 |
+
public function getOptionValues()
|
| 29 |
+
{
|
| 30 |
+
$attributeType = $this->getAttributeObject()->getFrontendInput();
|
| 31 |
+
$defaultValues = $this->getAttributeObject()->getDefaultValue();
|
| 32 |
+
if ($attributeType == 'select' || $attributeType == 'multiselect') {
|
| 33 |
+
$defaultValues = explode(',', $defaultValues);
|
| 34 |
+
} else {
|
| 35 |
+
$defaultValues = array();
|
| 36 |
+
}
|
| 37 |
+
|
| 38 |
+
switch ($attributeType) {
|
| 39 |
+
case 'select':
|
| 40 |
+
$inputType = 'radio';
|
| 41 |
+
break;
|
| 42 |
+
case 'multiselect':
|
| 43 |
+
$inputType = 'checkbox';
|
| 44 |
+
break;
|
| 45 |
+
default:
|
| 46 |
+
$inputType = '';
|
| 47 |
+
break;
|
| 48 |
+
}
|
| 49 |
+
|
| 50 |
+
$values = $this->getData('option_values');
|
| 51 |
+
if (is_null($values)) {
|
| 52 |
+
$values = array();
|
| 53 |
+
$optionCollection = Mage::getResourceModel('eav/entity_attribute_option_collection')
|
| 54 |
+
->setAttributeFilter($this->getAttributeObject()->getId())
|
| 55 |
+
->setPositionOrder('desc', true)
|
| 56 |
+
->load();
|
| 57 |
+
|
| 58 |
+
foreach ($optionCollection as $option) {
|
| 59 |
+
$value = array();
|
| 60 |
+
if (in_array($option->getId(), $defaultValues)) {
|
| 61 |
+
$value['checked'] = 'checked="checked"';
|
| 62 |
+
} else {
|
| 63 |
+
$value['checked'] = '';
|
| 64 |
+
}
|
| 65 |
+
|
| 66 |
+
$value['intype'] = $inputType;
|
| 67 |
+
$value['id'] = $option->getId();
|
| 68 |
+
$value['sort_order'] = $option->getSortOrder();
|
| 69 |
+
$value['externalid'] = $option->getExternalid();
|
| 70 |
+
foreach ($this->getStores() as $store) {
|
| 71 |
+
$storeValues = $this->getStoreOptionValues($store->getId());
|
| 72 |
+
if (isset($storeValues[$option->getId()])) {
|
| 73 |
+
$value['store'.$store->getId()] = htmlspecialchars($storeValues[$option->getId()]);
|
| 74 |
+
}
|
| 75 |
+
else {
|
| 76 |
+
$value['store'.$store->getId()] = '';
|
| 77 |
+
}
|
| 78 |
+
}
|
| 79 |
+
$values[] = new Varien_Object($value);
|
| 80 |
+
}
|
| 81 |
+
$this->setData('option_values', $values);
|
| 82 |
+
}
|
| 83 |
+
|
| 84 |
+
return $values;
|
| 85 |
+
}
|
| 86 |
+
}
|
app/code/community/Gec/Customimport/Block/Catalogimport.php
ADDED
|
@@ -0,0 +1,41 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 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
|
| 8 |
+
# published by the Free Software Foundation, either version 3 of the
|
| 9 |
+
# License, or (at your option) any later version.
|
| 10 |
+
#
|
| 11 |
+
# This program is distributed in the hope that it will be useful,
|
| 12 |
+
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
| 13 |
+
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
| 14 |
+
# GNU Affero General Public License for more details.
|
| 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 |
+
|
| 20 |
+
class Gec_Customimport_Block_Catalogimport extends Mage_Core_Block_Template
|
| 21 |
+
{
|
| 22 |
+
public $_log_array = array();
|
| 23 |
+
public $_xmlObj;
|
| 24 |
+
public $default_asid;
|
| 25 |
+
public $_product_list;
|
| 26 |
+
public $_category_list;
|
| 27 |
+
public $_cat_relation;
|
| 28 |
+
public $_current_row = 1;
|
| 29 |
+
public $_curitemids = array("sku"=>null);
|
| 30 |
+
public $_optidcache = null;
|
| 31 |
+
public $_dstore = array();
|
| 32 |
+
public $_same;
|
| 33 |
+
public $mode = "create";
|
| 34 |
+
public $prod_etype = 4;
|
| 35 |
+
public $_updated_num = 0;
|
| 36 |
+
public $_created_num = 0;
|
| 37 |
+
public $attributeGroupsGlobal = array();
|
| 38 |
+
public $_store_id;
|
| 39 |
+
public $_default_category_id;
|
| 40 |
+
}
|
| 41 |
+
?>
|
app/code/community/Gec/Customimport/Block/Customimport.php
ADDED
|
@@ -0,0 +1,1563 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 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
|
| 8 |
+
# published by the Free Software Foundation, either version 3 of the
|
| 9 |
+
# License, or (at your option) any later version.
|
| 10 |
+
#
|
| 11 |
+
# This program is distributed in the hope that it will be useful,
|
| 12 |
+
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
| 13 |
+
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
| 14 |
+
# GNU Affero General Public License for more details.
|
| 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 |
+
|
| 20 |
+
class Gec_Customimport_Block_Customimport extends Gec_Customimport_Block_Catalogimport
|
| 21 |
+
{
|
| 22 |
+
public function parseXml($xmlPath){
|
| 23 |
+
$this->_store_id = Mage::app()->getWebsite()->getDefaultGroup()->getDefaultStoreId();
|
| 24 |
+
$this->_default_category_id = Mage::app()->getStore()->getRootCategoryId();
|
| 25 |
+
$xmlObj = new Varien_Simplexml_Config($xmlPath);
|
| 26 |
+
$this->_xmlObj = $xmlObj;
|
| 27 |
+
}
|
| 28 |
+
|
| 29 |
+
public function showCategory(){
|
| 30 |
+
$xmlObj = $this->_xmlObj;
|
| 31 |
+
$xmlData = $xmlObj->getNode();
|
| 32 |
+
|
| 33 |
+
if( $xmlData->categories->category instanceof Varien_Simplexml_Element)
|
| 34 |
+
{
|
| 35 |
+
return $xmlData->categories->category;
|
| 36 |
+
}
|
| 37 |
+
else{
|
| 38 |
+
return false;
|
| 39 |
+
}
|
| 40 |
+
}
|
| 41 |
+
|
| 42 |
+
public function countAll(){
|
| 43 |
+
$xmlObj = $this->_xmlObj;
|
| 44 |
+
$xmlData = $xmlObj->getNode();
|
| 45 |
+
// $this->_category_list = $xmlData->categories->category;
|
| 46 |
+
$this->_category_list = $xmlData->productAssociations->association;
|
| 47 |
+
$this->lookup($this->_category_list );
|
| 48 |
+
}
|
| 49 |
+
|
| 50 |
+
public function countCategory(){
|
| 51 |
+
$xmlObj = $this->_xmlObj;
|
| 52 |
+
$xmlData = $xmlObj->getNode();
|
| 53 |
+
$this->_category_list = $xmlData->categories->category;
|
| 54 |
+
return $this->lookup($this->_category_list );
|
| 55 |
+
}
|
| 56 |
+
|
| 57 |
+
public function countProduct(){
|
| 58 |
+
$xmlObj = $this->_xmlObj;
|
| 59 |
+
$xmlData = $xmlObj->getNode();
|
| 60 |
+
$this->_product_list = $xmlData->products->product;
|
| 61 |
+
return $this->lookup($this->_product_list);
|
| 62 |
+
}
|
| 63 |
+
|
| 64 |
+
public function showProducts(){
|
| 65 |
+
$xmlObj = $this->_xmlObj;
|
| 66 |
+
$xmlData = $xmlObj->getNode();
|
| 67 |
+
$this->_product_list = $xmlData->products->product;
|
| 68 |
+
if( $this->_product_list instanceof Varien_Simplexml_Element){
|
| 69 |
+
return $this->_product_list;
|
| 70 |
+
}else{
|
| 71 |
+
return false;
|
| 72 |
+
}
|
| 73 |
+
}
|
| 74 |
+
|
| 75 |
+
public function reindexDB($val){
|
| 76 |
+
$process = Mage::getModel('index/process')->load($val);
|
| 77 |
+
$process->reindexAll();
|
| 78 |
+
}
|
| 79 |
+
|
| 80 |
+
public function importAllProducts($products){
|
| 81 |
+
$item = array();
|
| 82 |
+
foreach($products as $product){
|
| 83 |
+
$this->_current_row++;
|
| 84 |
+
$this->importItem($product);
|
| 85 |
+
}
|
| 86 |
+
$this->createLog("Successfully created products: {$this->_created_num}");
|
| 87 |
+
$this->createLog("Successfully updated products: {$this->_updated_num}");
|
| 88 |
+
$this->_created_num = 0;
|
| 89 |
+
$this->_updated_num = 0;
|
| 90 |
+
}
|
| 91 |
+
|
| 92 |
+
public function importAllCategory($categories){
|
| 93 |
+
$this->_created_num = 0;
|
| 94 |
+
$this->_updated_num = 0;
|
| 95 |
+
foreach($categories as $category){
|
| 96 |
+
$this->importCategory($category);
|
| 97 |
+
}
|
| 98 |
+
$this->createLog("Successfully created categories: {$this->_created_num}");
|
| 99 |
+
$this->createLog("Successfully updated categories: {$this->_updated_num}");
|
| 100 |
+
Mage::log("Successfully created categories: {$this->_created_num} Successfully updated categories: {$this->_updated_num}",null,'mylog.log');
|
| 101 |
+
$this->_created_num = 0;
|
| 102 |
+
$this->_updated_num = 0;
|
| 103 |
+
}
|
| 104 |
+
|
| 105 |
+
public function parseAllCategoryRelation(){
|
| 106 |
+
$xmlObj = $this->_xmlObj;
|
| 107 |
+
$xmlData = $xmlObj->getNode();
|
| 108 |
+
$this->_cat_relation = $xmlData->categoryRelations->categoryRelation;
|
| 109 |
+
|
| 110 |
+
foreach($this->_cat_relation as $catRelation){
|
| 111 |
+
$parent = (string)$catRelation->parentId;
|
| 112 |
+
$externall = $this->checkExternalId($parent);
|
| 113 |
+
if($externall){ //check if parent id exists.
|
| 114 |
+
if(count($externall) == 1){
|
| 115 |
+
reset($externall); //to take 1st key of array
|
| 116 |
+
$first_key = key($externall);
|
| 117 |
+
foreach($catRelation->subCategory as $sub){
|
| 118 |
+
$this->updateCategoryRelation($sub,$first_key,$parent);
|
| 119 |
+
}
|
| 120 |
+
}
|
| 121 |
+
else{
|
| 122 |
+
foreach($externall as $systemCatid => $v){
|
| 123 |
+
foreach($catRelation->subCategory as $sub){
|
| 124 |
+
$this->updateCategoryRelation($sub, $systemCatid, $parent);
|
| 125 |
+
}
|
| 126 |
+
}
|
| 127 |
+
}
|
| 128 |
+
}
|
| 129 |
+
else{
|
| 130 |
+
echo $parent.' category not found to associate products';
|
| 131 |
+
Mage::log('category not found: '.$parent,null,'catalogimport.log');
|
| 132 |
+
}
|
| 133 |
+
}
|
| 134 |
+
}
|
| 135 |
+
|
| 136 |
+
protected function duplicateCategory($categoryId, $parentId, $status){ //duplicating categoryid
|
| 137 |
+
$default_root_category = $this->_default_category_id;
|
| 138 |
+
$parent_id = ($parentId)?$parentId:$default_root_category;
|
| 139 |
+
$isActive = ($status == 'Y')?1:0;
|
| 140 |
+
$category = Mage::getModel('catalog/category')->setStoreId($this->_store_id)->load($categoryId); //load category to duplicate
|
| 141 |
+
$duplicate_category = Mage::getModel('catalog/category')
|
| 142 |
+
->setStoreId($this->_store_id);
|
| 143 |
+
$parent_category = $this->_initCategory($parentId, $this->_store_id);
|
| 144 |
+
if (!$parent_category->getId()) {
|
| 145 |
+
exit;
|
| 146 |
+
}
|
| 147 |
+
$duplicate_category->addData(array('path'=>implode('/', $parent_category->getPathIds())));
|
| 148 |
+
$duplicate_category->setParentId($parent_category->getId());
|
| 149 |
+
$duplicate_category ->setAttributeSetId($duplicate_category->getDefaultAttributeSetId());
|
| 150 |
+
|
| 151 |
+
$duplicate_category->setData('name', $category->getName());
|
| 152 |
+
$duplicate_category->setData('include_in_menu', 1);
|
| 153 |
+
$duplicate_category->setData('meta_title', $category->getmetaTitle());
|
| 154 |
+
$duplicate_category->setData('meta_keywords', $category->getmetaKeywords());
|
| 155 |
+
$duplicate_category->setData('meta_description', $category->getmetaDescription());
|
| 156 |
+
$duplicate_category->setData('description', $category->getdescription());
|
| 157 |
+
$duplicate_category->setData('available_sort_by','position');
|
| 158 |
+
$duplicate_category->setData('default_sort_by','position');
|
| 159 |
+
$duplicate_category->setData('is_active',$isActive);
|
| 160 |
+
$duplicate_category->setData('external_id',$category->getexternalId());
|
| 161 |
+
$duplicate_category->setData('external_cat_image',$category->getexternalCatImage());
|
| 162 |
+
try {
|
| 163 |
+
$validate = $duplicate_category->validate();
|
| 164 |
+
if ($validate !== true) {
|
| 165 |
+
foreach ($validate as $code => $error) {
|
| 166 |
+
if ($error === true) {
|
| 167 |
+
Mage::throwException(Mage::helper('catalog')->__('Attribute "%s" is required.', $code));
|
| 168 |
+
}
|
| 169 |
+
else {
|
| 170 |
+
Mage::throwException($error);
|
| 171 |
+
}
|
| 172 |
+
}
|
| 173 |
+
}
|
| 174 |
+
$duplicate_category->save();
|
| 175 |
+
return $duplicate_category->getId();
|
| 176 |
+
}
|
| 177 |
+
catch (Exception $e){
|
| 178 |
+
echo $e->getMessage();
|
| 179 |
+
}
|
| 180 |
+
return false;
|
| 181 |
+
}
|
| 182 |
+
|
| 183 |
+
public function getTreeCategories($category_id, $p_id, $isActive, $isChild){ //$parentId, $isChild
|
| 184 |
+
$duplicatedCategoryId = $this->duplicateCategory($category_id, $p_id, $isActive);
|
| 185 |
+
$mapObj = Mage::getModel('customimport/customimport');
|
| 186 |
+
$sub_category = Mage::getModel('catalog/category')->setStoreId($this->_store_id)->load($duplicatedCategoryId);
|
| 187 |
+
$parent_category = Mage::getModel('catalog/category')->setStoreId($this->_store_id)->load($p_id);
|
| 188 |
+
$ext_subid = $sub_category->getExternalId();
|
| 189 |
+
$parent_external_id = $parent_category->getExternalId();
|
| 190 |
+
$mapObj->updateCategoryMappingInfo($ext_subid,$duplicatedCategoryId,$parent_external_id,$p_id);
|
| 191 |
+
|
| 192 |
+
$allCats = Mage::getModel('catalog/category')->getCollection()
|
| 193 |
+
->addAttributeToSelect('*')
|
| 194 |
+
->addAttributeToFilter('parent_id',array('eq' => $category_id));
|
| 195 |
+
foreach($allCats as $category){
|
| 196 |
+
$subcats = $category->getChildren();
|
| 197 |
+
$isActive = 'N';
|
| 198 |
+
$status_cat = $category->getData('is_active');
|
| 199 |
+
if($status_cat == 1){
|
| 200 |
+
$isActive = 'Y';
|
| 201 |
+
}
|
| 202 |
+
if($subcats != ''){
|
| 203 |
+
$this->getTreeCategories($category->getId(), $duplicatedCategoryId, $isActive, true);
|
| 204 |
+
}else{
|
| 205 |
+
$duplicatedSubcategoryId = $this->duplicateCategory($category->getId(), $duplicatedCategoryId, $isActive); // duplicated category id is parent for current subcategory
|
| 206 |
+
if($duplicatedSubcategoryId){
|
| 207 |
+
$sub_category = Mage::getModel('catalog/category')->setStoreId($this->_store_id)->load($duplicatedSubcategoryId);
|
| 208 |
+
$parent_category = Mage::getModel('catalog/category')->setStoreId($this->_store_id)->load($duplicatedCategoryId);
|
| 209 |
+
$ext_subid = $sub_category->getExternalId();
|
| 210 |
+
$parent_external_id = $parent_category->getExternalId();
|
| 211 |
+
$mapObj->updateCategoryMappingInfo($ext_subid, $duplicatedSubcategoryId, $parent_external_id, $duplicatedCategoryId);
|
| 212 |
+
}else{
|
| 213 |
+
echo 'got some error while duplicating';
|
| 214 |
+
}
|
| 215 |
+
}
|
| 216 |
+
}
|
| 217 |
+
}
|
| 218 |
+
|
| 219 |
+
public function updateCategoryRelation($subcat, $p_id, $parent_external_id){
|
| 220 |
+
$ext_subid = (string)$subcat->id;
|
| 221 |
+
$actualSubId = $this->checkExternalId($ext_subid);
|
| 222 |
+
$mapObj = Mage::getModel('customimport/customimport');
|
| 223 |
+
|
| 224 |
+
if($actualSubId){
|
| 225 |
+
if(count($actualSubId) == 1){
|
| 226 |
+
reset($actualSubId); //to take 1st key of array
|
| 227 |
+
$subcat_id = key($actualSubId);
|
| 228 |
+
$category_id = $mapObj->isSubcategoryExists($ext_subid, $p_id); // external subcat id , parent magento id
|
| 229 |
+
|
| 230 |
+
if($category_id){
|
| 231 |
+
$category = Mage::getModel('catalog/category')
|
| 232 |
+
->setStoreId($this->_store_id)
|
| 233 |
+
->load($subcat_id);
|
| 234 |
+
|
| 235 |
+
$isActive = ((string)$subcat->isActive == 'Y')?1:0;
|
| 236 |
+
$category->setData('is_active',$isActive);
|
| 237 |
+
$category->save();
|
| 238 |
+
}
|
| 239 |
+
else{
|
| 240 |
+
$category_id = $mapObj->isCategoryExists($ext_subid);
|
| 241 |
+
if($category_id){
|
| 242 |
+
$isActive = ((string)$subcat->isActive);
|
| 243 |
+
$status = $this->getTreeCategories($category_id,$p_id, $isActive,false);
|
| 244 |
+
}else{
|
| 245 |
+
// category is not under any other parent , move
|
| 246 |
+
$category = Mage::getModel('catalog/category')
|
| 247 |
+
->setStoreId($this->_store_id)
|
| 248 |
+
->load($subcat_id);
|
| 249 |
+
$category->move($p_id, 0);
|
| 250 |
+
$isActive = ((string)$subcat->isActive == 'Y')?1:0;
|
| 251 |
+
$category->setData('is_active',$isActive);
|
| 252 |
+
$category->save();
|
| 253 |
+
$mapObj->updateParent($p_id,$subcat_id);
|
| 254 |
+
$mapObj->updateCategoryMappingInfo($ext_subid,$subcat_id, $parent_external_id, $p_id);
|
| 255 |
+
}
|
| 256 |
+
}
|
| 257 |
+
}
|
| 258 |
+
else{
|
| 259 |
+
$category_id = $mapObj->isSubcategoryExists($ext_subid, $p_id);
|
| 260 |
+
if($category_id){
|
| 261 |
+
// echo 'subcat present in this cat '.$ext_subid;
|
| 262 |
+
$category = Mage::getModel('catalog/category')->setStoreId($this->_store_id)->load($category_id);
|
| 263 |
+
$isActive = ((string)$subcat->isActive == 'Y')?1:0;
|
| 264 |
+
$category->setData('is_active', $isActive);
|
| 265 |
+
$category->save();
|
| 266 |
+
}
|
| 267 |
+
else if($category_id = $mapObj->isCategoryExists($ext_subid)){
|
| 268 |
+
$isActive = ((string)$subcat->isActive);
|
| 269 |
+
$status = $this->getTreeCategories($category_id, $p_id, $isActive, false);
|
| 270 |
+
}else{
|
| 271 |
+
// category is not under any other parent , move
|
| 272 |
+
echo 'block will never execute';
|
| 273 |
+
}
|
| 274 |
+
}
|
| 275 |
+
}
|
| 276 |
+
else{
|
| 277 |
+
if(count($externall) == 0){
|
| 278 |
+
Mage::log('subcategory id not found:'.$ext_subid, null, 'catalogimport.log');
|
| 279 |
+
}
|
| 280 |
+
}
|
| 281 |
+
}
|
| 282 |
+
|
| 283 |
+
public function importItem( &$item){
|
| 284 |
+
$missingInfoRow = $this->_current_row -1;
|
| 285 |
+
if(!isset($item->id) || trim($item->id)==''){
|
| 286 |
+
$this->createLog('sku not found for product row # '.$missingInfoRow, "error");
|
| 287 |
+
// Mage::log('sku not found for product record #:'.$this->_current_row, null, 'catalogimport.log');
|
| 288 |
+
return false;
|
| 289 |
+
}
|
| 290 |
+
if(!isset($item->attributeSetId) || trim($item->attributeSetId)==''){
|
| 291 |
+
$this->createLog('AttributesetId not found for product Id # '.$item->id, "error");
|
| 292 |
+
// Mage::log('AttributesetId not found for product record #:'.$this->_current_row, null, 'catalogimport.log');
|
| 293 |
+
return false;
|
| 294 |
+
}
|
| 295 |
+
if(!isset($item->type) || trim($item->type)==''){
|
| 296 |
+
$this->createLog('Product type not found for product record # '.$item->id, "error");
|
| 297 |
+
// Mage::log('Product type not found for product record #:'.$this->_current_row, null, 'catalogimport.log');
|
| 298 |
+
return false;
|
| 299 |
+
}
|
| 300 |
+
$itemids = $this->getItemIds($item);
|
| 301 |
+
$pid = $itemids["pid"];
|
| 302 |
+
$asid = $itemids["asid"];
|
| 303 |
+
|
| 304 |
+
if(!isset($pid))
|
| 305 |
+
{
|
| 306 |
+
if(!isset($asid)){
|
| 307 |
+
$this->createLog('cannot create product sku:'.(string)$item->id.', mentioned attributeset id is not available.product row id: #'.$missingInfoRow,'error');
|
| 308 |
+
// Mage::log('cannot create product sku:'.(string)$item->id,null,'catalogimport.log');
|
| 309 |
+
return false;
|
| 310 |
+
}
|
| 311 |
+
if((string)$item->type == 'configurable'){
|
| 312 |
+
$this->createConfigurableProduct($item, $asid); //create con product
|
| 313 |
+
}
|
| 314 |
+
else if((string)$item->type == 'simple'){
|
| 315 |
+
$this->createProduct($item, $asid); //create simple product
|
| 316 |
+
}
|
| 317 |
+
else{
|
| 318 |
+
$this->createLog("Import function does not support product type of record: {$item->id}");
|
| 319 |
+
}
|
| 320 |
+
$this->_curitemids["pid"] = $pid;
|
| 321 |
+
$isnew = true;
|
| 322 |
+
}
|
| 323 |
+
else{
|
| 324 |
+
if((string)$item->type == 'configurable'){
|
| 325 |
+
$this->updateConfigurableProduct($item, $pid); //create con product
|
| 326 |
+
}
|
| 327 |
+
else if((string)$item->type == 'simple'){
|
| 328 |
+
$this->updateProduct($item, $pid); //create simple product
|
| 329 |
+
}
|
| 330 |
+
}
|
| 331 |
+
}
|
| 332 |
+
|
| 333 |
+
public function updateConfigurableProduct(&$item, $pid){
|
| 334 |
+
$p_status = ((string)$item->isActive == 'Y')?1:2;
|
| 335 |
+
$p_taxclass = ((string)$item->isTaxable == 'Y')?2:0;
|
| 336 |
+
$SKU = (string)$item->id;
|
| 337 |
+
$product = Mage::getModel('catalog/product')->loadByAttribute('sku', $SKU);
|
| 338 |
+
|
| 339 |
+
if ($product){
|
| 340 |
+
$product->setData('name', (string)$item->name);
|
| 341 |
+
$product->setPrice((real)$item->price);
|
| 342 |
+
$product->setWeight((real)$item->weight);
|
| 343 |
+
$product->setStatus($p_status);
|
| 344 |
+
$product->setTaxClassId($p_taxclass);
|
| 345 |
+
|
| 346 |
+
$product->setDescription((string)$item->longDescription);
|
| 347 |
+
$product->setShortDescription((string)$item->shortDescription);
|
| 348 |
+
$product->setMetaTitle((string)$item->pageTitle);
|
| 349 |
+
$product->setMetaKeyword((string)$item->metaKeywords);
|
| 350 |
+
$product->setMetaDescription((string)$item->metaDescription);
|
| 351 |
+
$product->setExternalImage((string)$item->originalImageUrl);
|
| 352 |
+
$product->setExternalSmallImage((string)$item->largeImageUrl);
|
| 353 |
+
$product->setExternalThumbnail((string)$item->smallImageUrl);
|
| 354 |
+
|
| 355 |
+
$attributeValues = $item->attributeValues;
|
| 356 |
+
$attributeOcuurance = array(); //stores no. of occurance for all attributes
|
| 357 |
+
$configAttributeValue = array(); // will use to take value of attributes that ocuures once
|
| 358 |
+
$i =1;
|
| 359 |
+
foreach($attributeValues->attribute as $attr){
|
| 360 |
+
if(array_key_exists((string)$attr->id , $attributeOcuurance)){
|
| 361 |
+
$attributeOcuurance[(string)$attr->id] = (int)$attributeOcuurance[(string)$attr->id] + 1;
|
| 362 |
+
}
|
| 363 |
+
else{
|
| 364 |
+
$attributeOcuurance[(string)$attr->id] = $i;
|
| 365 |
+
$configAttributeValue[(string)$attr->id] = (string)$attr->valueDefId;
|
| 366 |
+
}
|
| 367 |
+
}
|
| 368 |
+
$config_attribute_array = array(); //attributes with single occurance
|
| 369 |
+
foreach($attributeOcuurance as $key=>$val){
|
| 370 |
+
if($val == 1){
|
| 371 |
+
$config_attribute_array[] = $key;
|
| 372 |
+
}
|
| 373 |
+
}
|
| 374 |
+
|
| 375 |
+
foreach($config_attribute_array as $attr){
|
| 376 |
+
$external_id = $configAttributeValue[$attr]; // valueDefId from XML for an attribute
|
| 377 |
+
$model = Mage::getModel('catalog/resource_eav_attribute');
|
| 378 |
+
$loadedattr = $model->loadByCode('catalog_product', $attr);
|
| 379 |
+
$attr_id = $loadedattr->getAttributeId(); // attribute id of magento
|
| 380 |
+
$attr_type = $loadedattr->getFrontendInput();
|
| 381 |
+
if($attr_type == 'select'){
|
| 382 |
+
$mapObj = Mage::getModel('customimport/customimport');
|
| 383 |
+
$option_id = $mapObj->isOptionExistsInAttribute($external_id, $attr_id);
|
| 384 |
+
// $product->setData($attr, (string)$item->name);
|
| 385 |
+
if($option_id){
|
| 386 |
+
$product->setData($attr, $option_id);
|
| 387 |
+
}
|
| 388 |
+
}else{ //if attribute is textfield direct insert value
|
| 389 |
+
$product->setData($attr, $external_id);
|
| 390 |
+
}
|
| 391 |
+
|
| 392 |
+
}
|
| 393 |
+
try{
|
| 394 |
+
$product->save();
|
| 395 |
+
$stockItem = Mage::getModel('cataloginventory/stock_item');
|
| 396 |
+
$stockItem->assignProduct($product);
|
| 397 |
+
$stockItem->setData('stock_id', (int)1);
|
| 398 |
+
|
| 399 |
+
$stockItem->setData('use_config_manage_stock', (int)1);
|
| 400 |
+
$stockItem->setData('min_qty', (int)0);
|
| 401 |
+
$stockItem->setData('is_decimal_divided', (int)0);
|
| 402 |
+
|
| 403 |
+
$stockItem->setData('qty', (int)0);
|
| 404 |
+
$stockItem->setData('use_config_min_qty', 1);
|
| 405 |
+
$stockItem->setData('use_config_backorders', 1);
|
| 406 |
+
$stockItem->setData('min_sale_qty', 1);
|
| 407 |
+
$stockItem->setData('use_config_min_sale_qty', 1);
|
| 408 |
+
$stockItem->setData('use_config_max_sale_qty', 1);
|
| 409 |
+
$stockItem->setData('is_in_stock', 1);
|
| 410 |
+
$stockItem->setData('use_config_notify_stock_qty', 1);
|
| 411 |
+
$stockItem->setData('manage_stock', 0);
|
| 412 |
+
$stockItem->save();
|
| 413 |
+
$stockStatus = Mage::getModel('cataloginventory/stock_status');
|
| 414 |
+
$stockStatus->assignProduct($product);
|
| 415 |
+
$stockStatus->saveProductStatus($product->getId(), 1);
|
| 416 |
+
// echo "updated\n";
|
| 417 |
+
}
|
| 418 |
+
catch (Exception $e){
|
| 419 |
+
echo " not added\n";
|
| 420 |
+
echo "exception:$e";
|
| 421 |
+
}
|
| 422 |
+
$this->_updated_num++;
|
| 423 |
+
unset($product);
|
| 424 |
+
return $productId;
|
| 425 |
+
}else{
|
| 426 |
+
return false;
|
| 427 |
+
}
|
| 428 |
+
}
|
| 429 |
+
|
| 430 |
+
public function createConfigurableProduct(&$item, $asid){
|
| 431 |
+
$p_status = ((string)$item->isActive == 'Y')?1:2;
|
| 432 |
+
$p_taxclass = ((string)$item->isTaxable == 'Y')?2:0;
|
| 433 |
+
|
| 434 |
+
$product = new Mage_Catalog_Model_Product();
|
| 435 |
+
$product->setTypeId('configurable');
|
| 436 |
+
$product->setVisibility(Mage_Catalog_Model_Product_Visibility::VISIBILITY_BOTH);
|
| 437 |
+
|
| 438 |
+
$product->setSku((string)$item->id); //Product custom id
|
| 439 |
+
$product->setWebsiteIds(array(Mage::app()->getStore(true)->getWebsite()->getId()));
|
| 440 |
+
$product->setStoreIDs(array($this->_store_id)); // Default store id .
|
| 441 |
+
|
| 442 |
+
$product->setAttributeSetId($asid);
|
| 443 |
+
$product->setData('name', (string)$item->name);
|
| 444 |
+
$product->setPrice((real)$item->price);
|
| 445 |
+
$product->setWeight((real)$item->weight);
|
| 446 |
+
$product->setStatus($p_status);
|
| 447 |
+
$product->setTaxClassId($p_taxclass);
|
| 448 |
+
|
| 449 |
+
$product->setDescription((string)$item->longDescription);
|
| 450 |
+
$product->setShortDescription((string)$item->shortDescription);
|
| 451 |
+
$product->setMetaTitle((string)$item->pageTitle);
|
| 452 |
+
$product->setMetaKeyword((string)$item->metaKeywords);
|
| 453 |
+
$product->setMetaDescription((string)$item->metaDescription);
|
| 454 |
+
$product->setExternalImage((string)$item->originalImageUrl);
|
| 455 |
+
$product->setExternalSmallImage((string)$item->largeImageUrl);
|
| 456 |
+
$product->setExternalThumbnail((string)$item->smallImageUrl);
|
| 457 |
+
|
| 458 |
+
$attributeValues = $item->attributeValues;
|
| 459 |
+
$attributeOcuurance = array(); //stores no. of occurance for all attributes
|
| 460 |
+
$configAttributeValue = array(); // will use to take value of attributes that ocuures once
|
| 461 |
+
$i =1;
|
| 462 |
+
|
| 463 |
+
foreach($attributeValues->attribute as $attr){
|
| 464 |
+
if(array_key_exists((string)$attr->id, $attributeOcuurance)){
|
| 465 |
+
$attributeOcuurance[(string)$attr->id] = (int)$attributeOcuurance[(string)$attr->id] + 1;
|
| 466 |
+
}
|
| 467 |
+
else{
|
| 468 |
+
$attributeOcuurance[(string)$attr->id] = $i;
|
| 469 |
+
$configAttributeValue[(string)$attr->id] = (string)$attr->valueDefId;
|
| 470 |
+
}
|
| 471 |
+
}
|
| 472 |
+
$superattribute_array = array(); // attributes with multiple occurances
|
| 473 |
+
$config_attribute_array = array(); //attributes with single occurance
|
| 474 |
+
foreach($attributeOcuurance as $key => $val){
|
| 475 |
+
if($val > 1){
|
| 476 |
+
$superattribute_array[] = $key;
|
| 477 |
+
}
|
| 478 |
+
else{
|
| 479 |
+
$config_attribute_array[] = $key;
|
| 480 |
+
}
|
| 481 |
+
}
|
| 482 |
+
$attributes_array = array();
|
| 483 |
+
if(count($superattribute_array) > 0){
|
| 484 |
+
$super_attribute_created = $this->makeAttributeConfigurable($superattribute_array);
|
| 485 |
+
if($super_attribute_created){
|
| 486 |
+
foreach($superattribute_array as $attr){
|
| 487 |
+
$attributes_array[] = $attr; // contains attribute codes
|
| 488 |
+
}
|
| 489 |
+
$ProductAttributeIds = array(); // array stores only super attribute id's
|
| 490 |
+
$attribute_detail = array(); // stores super attribute's detail
|
| 491 |
+
$attrnum = 0;
|
| 492 |
+
foreach($attributes_array as $attribute_code){
|
| 493 |
+
$model = Mage::getModel('catalog/resource_eav_attribute');
|
| 494 |
+
$attr = $model->loadByCode('catalog_product', $attribute_code);
|
| 495 |
+
$attr_id = $attr->getAttributeId();
|
| 496 |
+
$ProductAttributeIds[] = $attr_id;
|
| 497 |
+
$attribute_label = $attr->getFrontendLabel();
|
| 498 |
+
$attr_detail = array('id'=>NULL, 'label' => "$attribute_label", 'position' => NULL, 'attribute_id' => $attr_id, 'attribute_code' => "$attribute_code", 'frontend_label' => "$attribute_label",
|
| 499 |
+
'html_id' => "config_super_product__attribute_$attrnum");
|
| 500 |
+
$attribute_detail[] = $attr_detail;
|
| 501 |
+
$attrnum++;
|
| 502 |
+
}
|
| 503 |
+
$product->getTypeInstance()->setUsedProductAttributeIds($ProductAttributeIds);
|
| 504 |
+
$product->setConfigurableAttributesData($attribute_detail);
|
| 505 |
+
$product->setCanSaveConfigurableAttributes(1);
|
| 506 |
+
|
| 507 |
+
foreach($config_attribute_array as $attr){
|
| 508 |
+
$external_id = $configAttributeValue[$attr]; // valueDefId from XML for an attribute
|
| 509 |
+
$model = Mage::getModel('catalog/resource_eav_attribute');
|
| 510 |
+
$loadedattr = $model->loadByCode('catalog_product', $attr);
|
| 511 |
+
$attr_id = $loadedattr->getAttributeId(); // attribute id of magento
|
| 512 |
+
$attr_type = $loadedattr->getFrontendInput();
|
| 513 |
+
if($attr_type == 'select'){
|
| 514 |
+
$mapObj = Mage::getModel('customimport/customimport');
|
| 515 |
+
$option_id = $mapObj->isOptionExistsInAttribute($external_id, $attr_id);
|
| 516 |
+
if($option_id){
|
| 517 |
+
$product->setData($attr, $option_id);
|
| 518 |
+
}
|
| 519 |
+
}else{ //if attribute is textfield direct insert value
|
| 520 |
+
$product->setData($attr, $external_id);
|
| 521 |
+
}
|
| 522 |
+
|
| 523 |
+
}
|
| 524 |
+
try{
|
| 525 |
+
$product->save();
|
| 526 |
+
$stockItem = Mage::getModel('cataloginventory/stock_item');
|
| 527 |
+
$stockItem->assignProduct($product);
|
| 528 |
+
$stockItem->setData('stock_id', (int)1);
|
| 529 |
+
|
| 530 |
+
$stockItem->setData('use_config_manage_stock', (int)1);
|
| 531 |
+
$stockItem->setData('min_qty', (int)0);
|
| 532 |
+
$stockItem->setData('is_decimal_divided', (int)0);
|
| 533 |
+
|
| 534 |
+
$stockItem->setData('qty', (int)0);
|
| 535 |
+
$stockItem->setData('use_config_min_qty', 1);
|
| 536 |
+
$stockItem->setData('use_config_backorders', 1);
|
| 537 |
+
$stockItem->setData('min_sale_qty', 1);
|
| 538 |
+
$stockItem->setData('use_config_min_sale_qty', 1);
|
| 539 |
+
$stockItem->setData('use_config_max_sale_qty', 1);
|
| 540 |
+
$stockItem->setData('is_in_stock', 1);
|
| 541 |
+
$stockItem->setData('use_config_notify_stock_qty', 1);
|
| 542 |
+
$stockItem->setData('manage_stock', 0);
|
| 543 |
+
$stockItem->save();
|
| 544 |
+
$stockStatus = Mage::getModel('cataloginventory/stock_status');
|
| 545 |
+
$stockStatus->assignProduct($product);
|
| 546 |
+
$stockStatus->saveProductStatus($product->getId(), 1);
|
| 547 |
+
}
|
| 548 |
+
catch (Exception $e){
|
| 549 |
+
echo "exception:$e";
|
| 550 |
+
}
|
| 551 |
+
}else{
|
| 552 |
+
echo 'Could not get super attribute for product. Hence skipped product' .(string)$item->id ;
|
| 553 |
+
}
|
| 554 |
+
}else{
|
| 555 |
+
echo 'Super attribute is missing. Hence skipped product' .(string)$item->id ;
|
| 556 |
+
}
|
| 557 |
+
}
|
| 558 |
+
|
| 559 |
+
public function createProduct(&$item, $asid){
|
| 560 |
+
$p_status = ((string)$item->isActive == 'Y')?1:2;
|
| 561 |
+
$p_taxclass = ((string)$item->isTaxable == 'Y')?2:0;
|
| 562 |
+
|
| 563 |
+
$product = new Mage_Catalog_Model_Product();
|
| 564 |
+
$product->setTypeId('simple');
|
| 565 |
+
$product->setVisibility(Mage_Catalog_Model_Product_Visibility::VISIBILITY_BOTH);
|
| 566 |
+
|
| 567 |
+
$product->setSku((string)$item->id); //Product custom id
|
| 568 |
+
$product->setWebsiteIds(array(Mage::app()->getStore(true)->getWebsite()->getId())); //Default website (main website) ?? To Do : make it dynamic
|
| 569 |
+
$product->setStoreIDs(array($this->_store_id)); // Default store id .
|
| 570 |
+
$product->setStockData(array( // Getting no info for quantity, hence statically using 100 for now
|
| 571 |
+
'is_in_stock' => 1,
|
| 572 |
+
'qty' => 100,
|
| 573 |
+
'manage_stock' => 1));
|
| 574 |
+
$product->setAttributeSetId($asid);
|
| 575 |
+
$product->setData('name', (string)$item->name);
|
| 576 |
+
$product->setPrice((real)$item->price);
|
| 577 |
+
$product->setWeight((real)$item->weight);
|
| 578 |
+
$product->setStatus($p_status);
|
| 579 |
+
$product->setTaxClassId($p_taxclass);
|
| 580 |
+
|
| 581 |
+
$product->setDescription((string)$item->longDescription);
|
| 582 |
+
$product->setShortDescription((string)$item->shortDescription);
|
| 583 |
+
$product->setMetaTitle((string)$item->pageTitle);
|
| 584 |
+
$product->setMetaKeyword((string)$item->metaKeywords);
|
| 585 |
+
$product->setMetaDescription((string)$item->metaDescription);
|
| 586 |
+
$product->setExternalImage((string)$item->originalImageUrl);
|
| 587 |
+
$product->setExternalSmallImage((string)$item->largeImageUrl);
|
| 588 |
+
$product->setExternalThumbnail((string)$item->smallImageUrl);
|
| 589 |
+
|
| 590 |
+
$attributeValues = $item->attributeValues;
|
| 591 |
+
$attributeOcuurance = array(); //stores no. of occurance for all attributes
|
| 592 |
+
$configAttributeValue = array(); // will use to take value of attributes that ocuures once
|
| 593 |
+
$multiple_values = array(); // stores an array of available values
|
| 594 |
+
$i =1;
|
| 595 |
+
foreach($attributeValues->attribute as $attr){
|
| 596 |
+
if(array_key_exists((string)$attr->id ,$attributeOcuurance)){
|
| 597 |
+
$multiple_values[(string)$attr->id][] = (string)$attr->valueDefId;
|
| 598 |
+
$attributeOcuurance[(string)$attr->id] = (int)$attributeOcuurance[(string)$attr->id] + 1;
|
| 599 |
+
}
|
| 600 |
+
else{
|
| 601 |
+
$multiple_values[(string)$attr->id][] = (string)$attr->valueDefId;
|
| 602 |
+
$attributeOcuurance[(string)$attr->id] = $i;
|
| 603 |
+
}
|
| 604 |
+
}
|
| 605 |
+
$skipStatus = 0;
|
| 606 |
+
foreach($multiple_values as $attribute_code=>$attribute_values){
|
| 607 |
+
$model = Mage::getModel('catalog/resource_eav_attribute');
|
| 608 |
+
$loadedattr = $model->loadByCode('catalog_product', $attribute_code);
|
| 609 |
+
$attr_id = $loadedattr->getAttributeId(); // attribute id of magento
|
| 610 |
+
if(!$attr_id){
|
| 611 |
+
// echo 'attribute '.$attribute_code . 'is not available in magento database.';
|
| 612 |
+
$this->createLog("Skipped product {$item->id}, attribute is not available in magento database.: {$attribute_code}");
|
| 613 |
+
$skipStatus = 1;
|
| 614 |
+
break;
|
| 615 |
+
}
|
| 616 |
+
else{
|
| 617 |
+
$attr_type = $loadedattr->getFrontendInput();
|
| 618 |
+
if($attr_type =='select' && count($attribute_values) == 1){
|
| 619 |
+
$mapObj = Mage::getModel('customimport/customimport');
|
| 620 |
+
$option_id = $mapObj->isOptionExistsInAttribute($attribute_values[0], $attr_id);
|
| 621 |
+
if($option_id){
|
| 622 |
+
$product->setData($attribute_code, $option_id);
|
| 623 |
+
}
|
| 624 |
+
}
|
| 625 |
+
if($attr_type =='select' && count($attribute_values)>1){
|
| 626 |
+
//multiple values for attribute which is not multiselect
|
| 627 |
+
// echo 'Attribute '. $attribute_code. 'can not have multiple values. Hence skipping product having id' . (string)$item->id;
|
| 628 |
+
$skipStatus = 1;
|
| 629 |
+
break;
|
| 630 |
+
}
|
| 631 |
+
if($attr_type =='multiselect'){
|
| 632 |
+
$multivalues = array();
|
| 633 |
+
foreach($attribute_values as $value){
|
| 634 |
+
$mapObj = Mage::getModel('customimport/customimport');
|
| 635 |
+
$option_id = $mapObj->isOptionExistsInAttribute($value, $attr_id);
|
| 636 |
+
if($option_id){
|
| 637 |
+
$multivalues[] = $option_id;
|
| 638 |
+
}
|
| 639 |
+
}
|
| 640 |
+
$product->addData( array($attribute_code => $multivalues) );
|
| 641 |
+
}
|
| 642 |
+
if($attr_type =='text' || $attr_type =='textarea'){ // if type is text/textarea
|
| 643 |
+
$product->setData($attribute_code, $attribute_values[0]);
|
| 644 |
+
}
|
| 645 |
+
}
|
| 646 |
+
}
|
| 647 |
+
try{
|
| 648 |
+
if($skipStatus == 0){
|
| 649 |
+
$productId = $product->save()->getId();
|
| 650 |
+
if ($productId) {
|
| 651 |
+
$this->_created_num++;
|
| 652 |
+
unset($product);
|
| 653 |
+
unset($multiple_values);
|
| 654 |
+
unset($attributeOcuurance);
|
| 655 |
+
return $productId;
|
| 656 |
+
}
|
| 657 |
+
else{
|
| 658 |
+
echo 'Skipped product due to improper attribute values :'.(string)$item->id;
|
| 659 |
+
// Mage::log('Skipped product due to improper attribute values :'.(string)$item->id,null,'catalogimport.log');
|
| 660 |
+
}
|
| 661 |
+
}else{
|
| 662 |
+
echo 'Skipped product due to some error while save :'.(string)$item->id;
|
| 663 |
+
// Mage::log('Skipped product due to some error while save :'.(string)$item->id,null,'catalogimport.log');
|
| 664 |
+
}
|
| 665 |
+
}
|
| 666 |
+
catch(Mage_Eav_Model_Entity_Attribute_Exception $e){
|
| 667 |
+
echo $e->getAttributeCode();
|
| 668 |
+
echo $e->getMessage();
|
| 669 |
+
}
|
| 670 |
+
}
|
| 671 |
+
|
| 672 |
+
public function updateProduct(&$item, $pid){
|
| 673 |
+
$p_status = ((string)$item->isActive == 'Y')?1:2;
|
| 674 |
+
$p_taxclass = ((string)$item->isTaxable == 'Y')?2:0;
|
| 675 |
+
$SKU = (string)$item->id;
|
| 676 |
+
$product = Mage::getModel('catalog/product')->loadByAttribute('sku', $SKU);
|
| 677 |
+
|
| 678 |
+
if ($product){
|
| 679 |
+
//Product found, so we need to update it in Magento.
|
| 680 |
+
$product->setData('name', (string)$item->name);
|
| 681 |
+
$product->setPrice((real)$item->price);
|
| 682 |
+
$product->setWeight((real)$item->weight);
|
| 683 |
+
$product->setStatus($p_status);
|
| 684 |
+
$product->setTaxClassId($p_taxclass);
|
| 685 |
+
|
| 686 |
+
$product->setDescription((string)$item->longDescription);
|
| 687 |
+
$product->setShortDescription((string)$item->shortDescription);
|
| 688 |
+
$product->setMetaTitle((string)$item->pageTitle);
|
| 689 |
+
$product->setMetaKeyword((string)$item->metaKeywords);
|
| 690 |
+
$product->setMetaDescription((string)$item->metaDescription);
|
| 691 |
+
$product->setExternalImage((string)$item->originalImageUrl);
|
| 692 |
+
$product->setExternalSmallImage((string)$item->largeImageUrl);
|
| 693 |
+
$product->setExternalThumbnail((string)$item->smallImageUrl);
|
| 694 |
+
|
| 695 |
+
$attributeValues = $item->attributeValues;
|
| 696 |
+
$attributeOcuurance = array(); //stores no. of occurance for all attributes
|
| 697 |
+
$configAttributeValue = array(); // will use to take value of attributes that ocuures once
|
| 698 |
+
$multiple_values = array();
|
| 699 |
+
$i =1;
|
| 700 |
+
foreach($attributeValues->attribute as $attr){
|
| 701 |
+
if(array_key_exists((string)$attr->id ,$attributeOcuurance)){
|
| 702 |
+
$multiple_values[(string)$attr->id][] = (string)$attr->valueDefId;
|
| 703 |
+
$attributeOcuurance[(string)$attr->id] = (int)$attributeOcuurance[(string)$attr->id] + 1;
|
| 704 |
+
}
|
| 705 |
+
else{
|
| 706 |
+
$multiple_values[(string)$attr->id][] = (string)$attr->valueDefId;
|
| 707 |
+
$attributeOcuurance[(string)$attr->id] = $i;
|
| 708 |
+
// $configAttributeValue[(string)$attr->id] = (string)$attr->valueDefId;
|
| 709 |
+
}
|
| 710 |
+
}
|
| 711 |
+
$skipStatus = 0;
|
| 712 |
+
foreach($multiple_values as $attribute_code => $attribute_values){
|
| 713 |
+
$model = Mage::getModel('catalog/resource_eav_attribute');
|
| 714 |
+
$loadedattr = $model->loadByCode('catalog_product', $attribute_code);
|
| 715 |
+
$attr_id = $loadedattr->getAttributeId(); // attribute id of magento
|
| 716 |
+
if(!$attr_id){
|
| 717 |
+
echo 'attribute '.$attribute_code . 'is not available in magento database.Hence skipping product having id' . (string)$item->id;
|
| 718 |
+
}
|
| 719 |
+
else{
|
| 720 |
+
$attr_type = $loadedattr->getFrontendInput();
|
| 721 |
+
if($attr_type =='select' && count($attribute_values) == 1){
|
| 722 |
+
$mapObj = Mage::getModel('customimport/customimport');
|
| 723 |
+
$option_id = $mapObj->isOptionExistsInAttribute($attribute_values[0], $attr_id);
|
| 724 |
+
if($option_id){
|
| 725 |
+
$product->setData($attribute_code, $option_id);
|
| 726 |
+
}
|
| 727 |
+
}
|
| 728 |
+
if($attr_type =='select' && count($attribute_values)>1){
|
| 729 |
+
//multiple values for attribute which is not multiselect
|
| 730 |
+
echo 'Attribute '. $attribute_code. 'can not have multiple values. Hence skipping product having id' . (string)$item->id;
|
| 731 |
+
$skipStatus = 1;
|
| 732 |
+
break;
|
| 733 |
+
}
|
| 734 |
+
if($attr_type =='multiselect'){
|
| 735 |
+
$multivalues = array();
|
| 736 |
+
foreach($attribute_values as $value){
|
| 737 |
+
$mapObj = Mage::getModel('customimport/customimport');
|
| 738 |
+
$option_id = $mapObj->isOptionExistsInAttribute($value, $attr_id);
|
| 739 |
+
if($option_id){
|
| 740 |
+
$multivalues[] = $option_id;
|
| 741 |
+
}
|
| 742 |
+
}
|
| 743 |
+
$product->addData( array($attribute_code => $multivalues) );
|
| 744 |
+
}
|
| 745 |
+
if($attr_type =='text' || $attr_type =='textarea'){ // if type is text/textarea
|
| 746 |
+
$product->setData($attribute_code, $attribute_values[0]);
|
| 747 |
+
}
|
| 748 |
+
}
|
| 749 |
+
}
|
| 750 |
+
if($skipStatus == 0){
|
| 751 |
+
$productId = $product->save()->getId();
|
| 752 |
+
$this->_updated_num++;
|
| 753 |
+
// $productId = $product->getId();
|
| 754 |
+
$stockItem =Mage::getModel('cataloginventory/stock_item')->loadByProduct($productId);
|
| 755 |
+
$stockItemId = $stockItem->getId();
|
| 756 |
+
$stockItem->setData('manage_stock', 1);
|
| 757 |
+
$stockItem->setData('qty', 100);
|
| 758 |
+
$stockItem->save();
|
| 759 |
+
unset($product);
|
| 760 |
+
return $productId;
|
| 761 |
+
}else{
|
| 762 |
+
// echo 'Skipped product due to improper attribute values :'.(string)$item->id;
|
| 763 |
+
// Mage::log('Skipped product due to improper attribute values :'.(string)$item->id,null,'catalogimport.log');
|
| 764 |
+
}
|
| 765 |
+
|
| 766 |
+
}else{
|
| 767 |
+
echo 'Skipped product due to some error while save :'.(string)$item->id;
|
| 768 |
+
// Mage::log('Skipped product due to some error while save :'.(string)$item->id,null,'catalogimport.log');
|
| 769 |
+
}
|
| 770 |
+
}
|
| 771 |
+
|
| 772 |
+
public function getAttributeSetId($attrSetName){
|
| 773 |
+
$attributeSetId = Mage::getModel('eav/entity_attribute_set')
|
| 774 |
+
->getCollection()
|
| 775 |
+
->setEntityTypeFilter(4) // 4is entity type id...4= product
|
| 776 |
+
->addFieldToFilter('attribute_set_name', $attrSetName)
|
| 777 |
+
->getFirstItem()
|
| 778 |
+
->getAttributeSetId();
|
| 779 |
+
|
| 780 |
+
return $attributeSetId;
|
| 781 |
+
}
|
| 782 |
+
|
| 783 |
+
public function getItemIds($item){
|
| 784 |
+
$external_set_id = (string)$item->attributeSetId;
|
| 785 |
+
$mapObj = Mage::getModel('customimport/customimport');
|
| 786 |
+
$magento_set_id = $mapObj->getAttributeSetIdByExternalId($external_set_id);
|
| 787 |
+
|
| 788 |
+
$sku=(string)$item->id;
|
| 789 |
+
if($sku!= $this->_curitemids["sku"]){
|
| 790 |
+
//try to find item ids in db
|
| 791 |
+
$cids = $this->getProductIds($sku);
|
| 792 |
+
if($cids!==false){
|
| 793 |
+
//if found use it
|
| 794 |
+
$this->_curitemids=$cids;
|
| 795 |
+
}else{
|
| 796 |
+
//only sku & attribute set id from datasource otherwise.
|
| 797 |
+
// $this->_curitemids=array("pid"=>null,"sku"=>$sku,"asid"=>isset($magento_set_id)?$magento_set_id:$this->getAttributeSetId('Default'));
|
| 798 |
+
$this->_curitemids=array("pid"=>null,"sku"=>$sku,"asid"=>isset($magento_set_id)?$magento_set_id:null);
|
| 799 |
+
}
|
| 800 |
+
//do not reset values for existing if non admin
|
| 801 |
+
$this->onNewSku($sku,($cids!==false));
|
| 802 |
+
unset($cids);
|
| 803 |
+
}else{
|
| 804 |
+
$this->onSameSku($sku);
|
| 805 |
+
}
|
| 806 |
+
return $this->_curitemids;
|
| 807 |
+
}
|
| 808 |
+
|
| 809 |
+
|
| 810 |
+
public function getProductIds($sku){
|
| 811 |
+
$toReturn = array();
|
| 812 |
+
$product1 = Mage::getModel('catalog/product');
|
| 813 |
+
$productCollection = $product1->getCollection()
|
| 814 |
+
->addAttributeToSelect('sku','entity_id','attribute_set_id')
|
| 815 |
+
->addAttributeToFilter('sku', $sku)
|
| 816 |
+
->load();
|
| 817 |
+
if(count($productCollection)>0){
|
| 818 |
+
foreach($productCollection as $product){
|
| 819 |
+
$productArr = $product->getData();
|
| 820 |
+
$toReturn['pid'] = $productArr['entity_id'];
|
| 821 |
+
$toReturn['asid'] = $productArr['attribute_set_id'];
|
| 822 |
+
return $toReturn;
|
| 823 |
+
}
|
| 824 |
+
}else{
|
| 825 |
+
return false;
|
| 826 |
+
}
|
| 827 |
+
}
|
| 828 |
+
|
| 829 |
+
public function clearOptCache(){
|
| 830 |
+
unset($this->_optidcache);
|
| 831 |
+
$this->_optidcache=array();
|
| 832 |
+
}
|
| 833 |
+
|
| 834 |
+
public function onNewSku($sku,$existing){
|
| 835 |
+
$this->clearOptCache();
|
| 836 |
+
//only assign values to store 0 by default in create mode for new sku
|
| 837 |
+
//for store related options
|
| 838 |
+
if(!$existing)
|
| 839 |
+
{
|
| 840 |
+
$this->_dstore=array(0);
|
| 841 |
+
}
|
| 842 |
+
else
|
| 843 |
+
{
|
| 844 |
+
$this->_dstore=array();
|
| 845 |
+
}
|
| 846 |
+
$this->_same=false;
|
| 847 |
+
}
|
| 848 |
+
|
| 849 |
+
public function onSameSku($sku){
|
| 850 |
+
unset($this->_dstore);
|
| 851 |
+
$this->_dstore=array();
|
| 852 |
+
$this->_same=true;
|
| 853 |
+
}
|
| 854 |
+
|
| 855 |
+
public function createLog($msg){
|
| 856 |
+
$this->_log_array[] = $msg;
|
| 857 |
+
}
|
| 858 |
+
|
| 859 |
+
|
| 860 |
+
public function lookup($listType){
|
| 861 |
+
$t0=microtime(true);
|
| 862 |
+
// echo "Performing Datasouce Lookup...startup";
|
| 863 |
+
$count = count($listType);
|
| 864 |
+
$this->_item_num = $count;
|
| 865 |
+
$t1 = microtime(true);
|
| 866 |
+
$time = $t1-$t0;
|
| 867 |
+
$this->createLog("Found $count records","startup");
|
| 868 |
+
// echo '<br /> memory:'. $mem;
|
| 869 |
+
}
|
| 870 |
+
|
| 871 |
+
/*
|
| 872 |
+
* create category
|
| 873 |
+
* */
|
| 874 |
+
protected function createCategory($item){
|
| 875 |
+
$default_root_category = $this->_default_category_id;
|
| 876 |
+
$parent_id = ((string)$item->isRoot == 'Y')?1:$default_root_category;
|
| 877 |
+
$isActive = ((string)$item->isActive == 'Y')?1:0;
|
| 878 |
+
|
| 879 |
+
$category = Mage::getModel('catalog/category')
|
| 880 |
+
->setStoreId($this->_store_id);
|
| 881 |
+
$parent_category = $this->_initCategory($parent_id, $this->_store_id);
|
| 882 |
+
if (!$parent_category->getId()) {
|
| 883 |
+
exit;
|
| 884 |
+
}
|
| 885 |
+
$category->addData(array('path'=>implode('/',$parent_category->getPathIds())));
|
| 886 |
+
/* @var $validator Mage_Catalog_Model_Api2_Product_Validator_Product */
|
| 887 |
+
$category->setParentId($parent_category->getId());
|
| 888 |
+
$category ->setAttributeSetId($category->getDefaultAttributeSetId());
|
| 889 |
+
$category->setData('name',(string)$item->name);
|
| 890 |
+
$category->setData('include_in_menu',1);
|
| 891 |
+
$category->setData('meta_title',(string)$item->pageTitle);
|
| 892 |
+
$category->setData('meta_keywords',(string)$item->metaKeywords);
|
| 893 |
+
$category->setData('meta_description',(string)$item->metaDescription);
|
| 894 |
+
$category->setData('description',(string)$item->description);
|
| 895 |
+
|
| 896 |
+
|
| 897 |
+
$category->setData('available_sort_by','position');
|
| 898 |
+
$category->setData('default_sort_by','position');
|
| 899 |
+
$category->setData('is_active',$isActive);
|
| 900 |
+
$category->setData('external_id',(string)$item->id);
|
| 901 |
+
$category->setData('external_cat_image',(string)$item->imageUrl);
|
| 902 |
+
try {
|
| 903 |
+
$validate = $category->validate();
|
| 904 |
+
if ($validate !== true) {
|
| 905 |
+
foreach ($validate as $code => $error) {
|
| 906 |
+
if ($error === true) {
|
| 907 |
+
Mage::throwException(Mage::helper('catalog')->__('Attribute "%s" is required.', $code));
|
| 908 |
+
}
|
| 909 |
+
else {
|
| 910 |
+
Mage::throwException($error);
|
| 911 |
+
}
|
| 912 |
+
}
|
| 913 |
+
}
|
| 914 |
+
$category->save();
|
| 915 |
+
}
|
| 916 |
+
catch (Exception $e){
|
| 917 |
+
echo $e->getMessage();
|
| 918 |
+
}
|
| 919 |
+
}
|
| 920 |
+
|
| 921 |
+
protected function updateCategory($item,$categoryId){
|
| 922 |
+
$category = Mage::getModel('catalog/category')->load($categoryId);
|
| 923 |
+
$isActive = ((string)$item->isActive == 'Y')?1:0;
|
| 924 |
+
$category->setData('name',(string)$item->name);
|
| 925 |
+
$category->setData('include_in_menu',1);
|
| 926 |
+
$category->setData('meta_title',(string)$item->pageTitle);
|
| 927 |
+
$category->setData('meta_keywords',(string)$item->metaKeywords);
|
| 928 |
+
$category->setData('meta_description',(string)$item->metaDescription);
|
| 929 |
+
$category->setData('description',(string)$item->description);
|
| 930 |
+
$category->setData('is_active',$isActive);
|
| 931 |
+
$category->setData('external_cat_image',(string)$item->imageUrl);
|
| 932 |
+
$category->save();
|
| 933 |
+
}
|
| 934 |
+
|
| 935 |
+
/**
|
| 936 |
+
* main function to import category
|
| 937 |
+
*/
|
| 938 |
+
protected function importCategory($item){
|
| 939 |
+
$externalId = (string)$item->id;
|
| 940 |
+
$externall = $this->checkExternalId($externalId);
|
| 941 |
+
|
| 942 |
+
if($externall){
|
| 943 |
+
if(count($externall) == 1){
|
| 944 |
+
//update already existing category with this id
|
| 945 |
+
reset($externall); //to take 1st key of array
|
| 946 |
+
$first_key = key($externall);
|
| 947 |
+
$this->updateCategory($item,$first_key);
|
| 948 |
+
$this->_updated_num++;
|
| 949 |
+
}
|
| 950 |
+
else{
|
| 951 |
+
foreach($externall as $systemCatid=>$v){
|
| 952 |
+
$this->updateCategory($item,$systemCatid);
|
| 953 |
+
}
|
| 954 |
+
}
|
| 955 |
+
}else{
|
| 956 |
+
if(count($externall) == 0){ // category is not available hence create new
|
| 957 |
+
$this->createCategory($item);
|
| 958 |
+
$this->_created_num++;
|
| 959 |
+
}
|
| 960 |
+
}
|
| 961 |
+
}
|
| 962 |
+
|
| 963 |
+
/**
|
| 964 |
+
* checks for a category existance using external id
|
| 965 |
+
* @param external id of category
|
| 966 |
+
*/
|
| 967 |
+
|
| 968 |
+
protected function checkExternalId($externalId){
|
| 969 |
+
$catsWithCustomAttr = array();
|
| 970 |
+
$collection = Mage::getModel('catalog/category')->getCollection();
|
| 971 |
+
$collection->addAttributeToSelect("external_id");
|
| 972 |
+
//Do a left join, and get values that aren't null - you could add other conditions in the second parameter also (check out all options in the _getConditionSql method of lib/Varien/Data/Collection/Db.php
|
| 973 |
+
$collection->addAttributeToFilter('external_id', $externalId, 'left');
|
| 974 |
+
foreach($collection as $category){
|
| 975 |
+
$catsWithCustomAttr[$category->getId()] = $category->getExternalId(); //Or you could say $category->getData('your_custom_category_attribute')
|
| 976 |
+
}
|
| 977 |
+
|
| 978 |
+
return $catsWithCustomAttr;
|
| 979 |
+
}
|
| 980 |
+
|
| 981 |
+
/**
|
| 982 |
+
* loads a category, if exists
|
| 983 |
+
* @param category id
|
| 984 |
+
*/
|
| 985 |
+
|
| 986 |
+
protected function _initCategory($categoryId, $store = null){
|
| 987 |
+
try{
|
| 988 |
+
$category = Mage::getModel('catalog/category')
|
| 989 |
+
->setStoreId($store)
|
| 990 |
+
->load($categoryId);
|
| 991 |
+
if (!$category->getId()) {
|
| 992 |
+
Mage::throwException(Mage::helper('catalog')->__('Parent category "%s" is not available.', $categoryId));
|
| 993 |
+
}
|
| 994 |
+
}
|
| 995 |
+
catch (Exception $e){
|
| 996 |
+
echo $e->getMessage();
|
| 997 |
+
}
|
| 998 |
+
return $category;
|
| 999 |
+
}
|
| 1000 |
+
|
| 1001 |
+
|
| 1002 |
+
public function getCurrentRow(){
|
| 1003 |
+
return $this->_current_row;
|
| 1004 |
+
}
|
| 1005 |
+
|
| 1006 |
+
public function setCurrentRow($cnum){
|
| 1007 |
+
$this->_current_row=$cnum;
|
| 1008 |
+
}
|
| 1009 |
+
|
| 1010 |
+
/**
|
| 1011 |
+
* parses <categoryProducts> block , and returns <categoryProducts><categoryProduct> block
|
| 1012 |
+
*/
|
| 1013 |
+
public function associatedProductsCategory(){
|
| 1014 |
+
$xmlObj = $this->_xmlObj;
|
| 1015 |
+
$xmlData = $xmlObj->getNode();
|
| 1016 |
+
|
| 1017 |
+
if( $xmlData->categoryProducts->categoryProduct instanceof Varien_Simplexml_Element){
|
| 1018 |
+
return $xmlData->categoryProducts->categoryProduct;
|
| 1019 |
+
}else{
|
| 1020 |
+
return 'no data ';
|
| 1021 |
+
}
|
| 1022 |
+
}
|
| 1023 |
+
|
| 1024 |
+
/*
|
| 1025 |
+
* associates a product with a category
|
| 1026 |
+
* */
|
| 1027 |
+
|
| 1028 |
+
public function associateProductToCategory( $productDetail,$catId){ //actual id of category
|
| 1029 |
+
$cat_api = new Mage_Catalog_Model_Category_Api;
|
| 1030 |
+
$newProduct = Mage::getModel('catalog/product')->loadByAttribute('sku',(string)$productDetail->id);
|
| 1031 |
+
if($newProduct){
|
| 1032 |
+
$category = Mage::getModel('catalog/category')
|
| 1033 |
+
->setStoreId($this->_store_id)
|
| 1034 |
+
->load($catId);
|
| 1035 |
+
$positions = $category->getProductsPosition();
|
| 1036 |
+
$productDetail->position;
|
| 1037 |
+
if( (string)$productDetail->isActive == 'Y'){
|
| 1038 |
+
// assignproduct is default function of magento, to assign product in a category
|
| 1039 |
+
$cat_api->assignProduct($catId, $newProduct->getId(),(real)$productDetail->position);
|
| 1040 |
+
}else{
|
| 1041 |
+
if(isset($positions[$newProduct->getId()])){
|
| 1042 |
+
// removeProduct is default function of magento, to remove product from a category
|
| 1043 |
+
$cat_api->removeProduct($catId, $newProduct->getId());
|
| 1044 |
+
}else{
|
| 1045 |
+
//echo 'does not';
|
| 1046 |
+
}
|
| 1047 |
+
}
|
| 1048 |
+
}else{
|
| 1049 |
+
echo (string)$productDetail->id.' product does not exists';
|
| 1050 |
+
Mage::log('product does not exists :'.(string)$productDetail->id,null,'catalogimport.log');
|
| 1051 |
+
}
|
| 1052 |
+
}
|
| 1053 |
+
|
| 1054 |
+
public function associateProducts($association){
|
| 1055 |
+
foreach($association as $associate){
|
| 1056 |
+
$parent = (string)$associate->categoryId;
|
| 1057 |
+
$externall = $this->checkExternalId($parent);
|
| 1058 |
+
if($externall){
|
| 1059 |
+
if(count($externall) == 1){
|
| 1060 |
+
reset($externall);
|
| 1061 |
+
$first_key = key($externall);
|
| 1062 |
+
foreach($associate->product as $product){
|
| 1063 |
+
$this->associateProductToCategory($product,$first_key);
|
| 1064 |
+
}
|
| 1065 |
+
}
|
| 1066 |
+
else{
|
| 1067 |
+
foreach($externall as $systemCatid=>$v){
|
| 1068 |
+
foreach($associate->product as $product){
|
| 1069 |
+
$this->associateProductToCategory($product,$systemCatid);
|
| 1070 |
+
}
|
| 1071 |
+
}
|
| 1072 |
+
}
|
| 1073 |
+
}
|
| 1074 |
+
else{
|
| 1075 |
+
if(count($externall) == 0){
|
| 1076 |
+
$this->createLog('category id not found: # '.$parent, "error");
|
| 1077 |
+
Mage::log('category id not found: '.$parent,null,'catalogimport.log');
|
| 1078 |
+
}
|
| 1079 |
+
}
|
| 1080 |
+
}
|
| 1081 |
+
}
|
| 1082 |
+
public function associatePdtPdt($association){
|
| 1083 |
+
foreach($association as $associate){
|
| 1084 |
+
$mainProduct = Mage::getModel('catalog/product')->loadByAttribute('sku',(string)$associate->productIdFrom);
|
| 1085 |
+
if ($mainProduct) {
|
| 1086 |
+
$productId = $mainProduct->getId();
|
| 1087 |
+
$relatedArray=array();
|
| 1088 |
+
$upsellArray=array();
|
| 1089 |
+
$crossArray=array();
|
| 1090 |
+
$associatedArray = array();
|
| 1091 |
+
foreach($associate->associatedProduct as $association){
|
| 1092 |
+
if( $association instanceof Varien_Simplexml_Element){ // if associatedProduct is an object in form of <associatedProduct>
|
| 1093 |
+
unset($prid);
|
| 1094 |
+
$prid = Mage::getModel('catalog/product')->getIdBySku((string)$association->id); // get id of associated product
|
| 1095 |
+
if($prid && (string)$association->isActive == 'Y') {
|
| 1096 |
+
$position = (string)$association->position ? (string)$association->position : 0;
|
| 1097 |
+
if((string)$association->assocType == 0){
|
| 1098 |
+
$crossArray[$prid]=array('position'=>$position);
|
| 1099 |
+
}
|
| 1100 |
+
else if((string)$association->assocType == 1){
|
| 1101 |
+
$upsellArray[$prid]=array('position'=>$position);
|
| 1102 |
+
}
|
| 1103 |
+
else if((string)$association->assocType == 2){
|
| 1104 |
+
$relatedArray[$prid]=array('position'=>$position);
|
| 1105 |
+
}else if((string)$association->assocType == 3){
|
| 1106 |
+
$associatedArray[] = $prid;
|
| 1107 |
+
}
|
| 1108 |
+
}
|
| 1109 |
+
}
|
| 1110 |
+
}
|
| 1111 |
+
$mainProduct->setCrossSellLinkData($crossArray);
|
| 1112 |
+
$mainProduct->setUpSellLinkData($upsellArray);
|
| 1113 |
+
$mainProduct->setRelatedLinkData($relatedArray);
|
| 1114 |
+
$mainProduct->save();
|
| 1115 |
+
|
| 1116 |
+
if(count($associatedArray) > 0){
|
| 1117 |
+
Mage::getResourceModel('catalog/product_type_configurable')
|
| 1118 |
+
->saveProducts( $mainProduct, $associatedArray );
|
| 1119 |
+
}
|
| 1120 |
+
unset($crossArray);
|
| 1121 |
+
unset($upsellArray);
|
| 1122 |
+
unset($relatedArray);
|
| 1123 |
+
unset($associatedArray);
|
| 1124 |
+
}else{
|
| 1125 |
+
$this->createLog('product not found for association: # '.$associate->productIdFrom, "error");
|
| 1126 |
+
Mage::log('product not found for association: # '.$associate->productIdFrom,null,'catalogimport.log');
|
| 1127 |
+
}
|
| 1128 |
+
}
|
| 1129 |
+
}
|
| 1130 |
+
|
| 1131 |
+
public function associatedProductsProducts(){
|
| 1132 |
+
$xmlObj = $this->_xmlObj;
|
| 1133 |
+
$xmlData = $xmlObj->getNode();
|
| 1134 |
+
if( $xmlData->productAssociations->association instanceof Varien_Simplexml_Element){
|
| 1135 |
+
return $xmlData->productAssociations->association;
|
| 1136 |
+
}else{
|
| 1137 |
+
Mage::log('Associatation block is empty',null,'catalogimport.log');
|
| 1138 |
+
$this->createLog('Associatation block is empty: # ');
|
| 1139 |
+
}
|
| 1140 |
+
}
|
| 1141 |
+
|
| 1142 |
+
public function makeAttributeConfigurable($superattribute_array){
|
| 1143 |
+
$result = false;
|
| 1144 |
+
$model = Mage::getModel('catalog/resource_eav_attribute');
|
| 1145 |
+
|
| 1146 |
+
foreach($superattribute_array as $attribute_id){
|
| 1147 |
+
$attr = $model->loadByCode('catalog_product',$attribute_id);
|
| 1148 |
+
$attr_id = $attr->getAttributeId();
|
| 1149 |
+
if($attr_id){
|
| 1150 |
+
if($attr_configurable = $attr->getIsConfigurable()){
|
| 1151 |
+
$result = true;
|
| 1152 |
+
}else{
|
| 1153 |
+
$attribute_type = $attr->getFrontendInput();
|
| 1154 |
+
$_attribute_data = array();
|
| 1155 |
+
if($attribute_type == 'select'){
|
| 1156 |
+
$_attribute_data['is_configurable'] = 1;
|
| 1157 |
+
$model->addData($_attribute_data);
|
| 1158 |
+
$attr->save();
|
| 1159 |
+
$result = true;
|
| 1160 |
+
}else{
|
| 1161 |
+
echo 'attribute '.$attribute_id. ' can not be updated to become superattribute';
|
| 1162 |
+
|
| 1163 |
+
$result = false;
|
| 1164 |
+
}
|
| 1165 |
+
}
|
| 1166 |
+
}else{
|
| 1167 |
+
echo 'attribute '.$attribute_id.' does not exists';
|
| 1168 |
+
$result = false;
|
| 1169 |
+
}
|
| 1170 |
+
}
|
| 1171 |
+
|
| 1172 |
+
return $result;
|
| 1173 |
+
}
|
| 1174 |
+
|
| 1175 |
+
public function createAttribute($attribute){
|
| 1176 |
+
$mapobj = Mage::getModel('customimport/customimport');
|
| 1177 |
+
$attr_values = (array)$attribute->values;
|
| 1178 |
+
|
| 1179 |
+
$attribute_type = 'select';
|
| 1180 |
+
if(isset($attribute->type)){
|
| 1181 |
+
$att_type = (string)$attribute->type;
|
| 1182 |
+
$magento_array_values = array('text','textarea','date','boolean','multiselect','select','price','media_image','weee');
|
| 1183 |
+
if (in_array($att_type, $magento_array_values)) {
|
| 1184 |
+
$attribute_type = $att_type;
|
| 1185 |
+
}
|
| 1186 |
+
}
|
| 1187 |
+
$count_value = count($attr_values['valueDef']);
|
| 1188 |
+
$_attribute_data = array(
|
| 1189 |
+
'attribute_code' => (string)$attribute->id,
|
| 1190 |
+
'is_global' => '1',
|
| 1191 |
+
'frontend_input' => $attribute_type, //'text/select',
|
| 1192 |
+
'default_value_text' => '',
|
| 1193 |
+
'default_value_yesno' => '0',
|
| 1194 |
+
'default_value_date' => '',
|
| 1195 |
+
'default_value_textarea' => '',
|
| 1196 |
+
'is_unique' => '0',
|
| 1197 |
+
'is_required' => '0',
|
| 1198 |
+
'apply_to' => array('simple','configurable'), //array('grouped')
|
| 1199 |
+
'is_configurable' => '0',
|
| 1200 |
+
'is_searchable' => '0',
|
| 1201 |
+
'is_visible_in_advanced_search' => '0',
|
| 1202 |
+
'is_comparable' => '0',
|
| 1203 |
+
'is_used_for_price_rules' => '0',
|
| 1204 |
+
'is_wysiwyg_enabled' => '0',
|
| 1205 |
+
'is_html_allowed_on_front' => '1',
|
| 1206 |
+
'is_visible_on_front' => '1',
|
| 1207 |
+
'used_in_product_listing' => '0',
|
| 1208 |
+
'used_for_sort_by' => '0',
|
| 1209 |
+
'frontend_label' => array((string)$attribute->name)
|
| 1210 |
+
);
|
| 1211 |
+
|
| 1212 |
+
$model = Mage::getModel('catalog/resource_eav_attribute');
|
| 1213 |
+
// $attr = Mage::getModel('eav/entity_attribute')->loadByCode('catalog_product', (string)$attribute->id);
|
| 1214 |
+
//Load the particular attribute by id
|
| 1215 |
+
$attr = $model->loadByCode('catalog_product',(string)$attribute->id);
|
| 1216 |
+
$attr_id = $attr->getAttributeId();
|
| 1217 |
+
|
| 1218 |
+
if($attr_id !=''){
|
| 1219 |
+
$attr->addData($_attribute_data);
|
| 1220 |
+
$option['attribute_id'] = $attr_id;
|
| 1221 |
+
|
| 1222 |
+
if($count_value > 0 && ($attribute_type == 'select' || $attribute_type == 'multiselect')){
|
| 1223 |
+
for($i =0; $i<$count_value ; $i++){
|
| 1224 |
+
$attrdet = $attr_values['valueDef'][$i];
|
| 1225 |
+
$optionId = $mapobj->isOptionExistsInAttribute($attrdet->id,$attr_id);
|
| 1226 |
+
if(!isset($optionId)){
|
| 1227 |
+
$option['value']['option_'.$i][0] = $attrdet->value;
|
| 1228 |
+
$option['order']['option_'.$i] = $i;
|
| 1229 |
+
$option['externalid']['option_'.$i] = $attrdet->id;
|
| 1230 |
+
}
|
| 1231 |
+
else{
|
| 1232 |
+
$option['value'][$optionId][0] = $attrdet->value;
|
| 1233 |
+
$option['order'][$optionId] = $i;
|
| 1234 |
+
$option['externalid'][$optionId] = $attrdet->id;
|
| 1235 |
+
}
|
| 1236 |
+
$attr->setOption($option);
|
| 1237 |
+
}
|
| 1238 |
+
}
|
| 1239 |
+
$attr->save();
|
| 1240 |
+
}
|
| 1241 |
+
else{
|
| 1242 |
+
if (!isset($_attribute_data['is_configurable'])) {
|
| 1243 |
+
$_attribute_data['is_configurable'] = 0;
|
| 1244 |
+
}
|
| 1245 |
+
if (!isset($_attribute_data['is_filterable'])) {
|
| 1246 |
+
$_attribute_data['is_filterable'] = 0;
|
| 1247 |
+
}
|
| 1248 |
+
if (!isset($_attribute_data['is_filterable_in_search'])) {
|
| 1249 |
+
$_attribute_data['is_filterable_in_search'] = 0;
|
| 1250 |
+
}
|
| 1251 |
+
if (is_null($model->getIsUserDefined()) || $model->getIsUserDefined() != 0) {
|
| 1252 |
+
$_attribute_data['backend_type'] = $model->getBackendTypeByInput($_attribute_data['frontend_input']);
|
| 1253 |
+
}
|
| 1254 |
+
$defaultValueField = $model->getDefaultValueByInput($_attribute_data['frontend_input']);
|
| 1255 |
+
if ($defaultValueField) {
|
| 1256 |
+
$_attribute_data['default_value'] = $this->getRequest()->getParam($defaultValueField);
|
| 1257 |
+
}
|
| 1258 |
+
$model->addData($_attribute_data);
|
| 1259 |
+
$model->setEntityTypeId(Mage::getModel('eav/entity')->setType('catalog_product')->getTypeId());
|
| 1260 |
+
$model->setIsUserDefined(1);
|
| 1261 |
+
try {
|
| 1262 |
+
$model->save();
|
| 1263 |
+
unset($model);
|
| 1264 |
+
if($count_value > 0){
|
| 1265 |
+
$model = Mage::getModel('catalog/resource_eav_attribute');
|
| 1266 |
+
$attr = $model->loadByCode('catalog_product',(string)$attribute->id);
|
| 1267 |
+
$attr_id = $attr->getAttributeId();
|
| 1268 |
+
$option['attribute_id'] = $attr_id;
|
| 1269 |
+
|
| 1270 |
+
for($i =0; $i<$count_value ; $i++){
|
| 1271 |
+
$attrdet = $attr_values['valueDef'][$i];
|
| 1272 |
+
$optionId = $mapobj->isOptionExistsInAttribute($attrdet->id,$attr_id);
|
| 1273 |
+
if(!isset($optionId)){
|
| 1274 |
+
$option['value']['option_'.$i][0] = $attrdet->value;
|
| 1275 |
+
$option['order']['option_'.$i] = $i;
|
| 1276 |
+
$option['externalid']['option_'.$i] = $attrdet->id;
|
| 1277 |
+
}
|
| 1278 |
+
else{
|
| 1279 |
+
$option['value'][$optionId][0] = $attrdet->value;
|
| 1280 |
+
$option['order'][$optionId] = $i;
|
| 1281 |
+
$option['externalid'][$optionId] = $attrdet->id;
|
| 1282 |
+
}
|
| 1283 |
+
}
|
| 1284 |
+
$attr->setOption($option);
|
| 1285 |
+
$attr->save();
|
| 1286 |
+
}
|
| 1287 |
+
} catch (Exception $e) {
|
| 1288 |
+
echo '<p>Sorry, error occured while trying to save the attribute. Error: '.$e->getMessage().'</p>';
|
| 1289 |
+
}
|
| 1290 |
+
}
|
| 1291 |
+
}
|
| 1292 |
+
|
| 1293 |
+
public function importAttribute($parsedAttribute){
|
| 1294 |
+
foreach($parsedAttribute as $attribute){
|
| 1295 |
+
$this->createAttribute($attribute);
|
| 1296 |
+
}
|
| 1297 |
+
$this->reindexDB(7); // 7 is used after attribute creation.
|
| 1298 |
+
}
|
| 1299 |
+
|
| 1300 |
+
public function parseAttribute(){
|
| 1301 |
+
$xmlObj = $this->_xmlObj;
|
| 1302 |
+
$xmlData = $xmlObj->getNode();
|
| 1303 |
+
if( $xmlData->attributeConfiguration->attribute instanceof Varien_Simplexml_Element){
|
| 1304 |
+
return $xmlData->attributeConfiguration->attribute;
|
| 1305 |
+
}
|
| 1306 |
+
}
|
| 1307 |
+
|
| 1308 |
+
public function parseAttributeSet(){
|
| 1309 |
+
$xmlObj = $this->_xmlObj;
|
| 1310 |
+
$xmlData = $xmlObj->getNode();
|
| 1311 |
+
if( $xmlData->attributeConfiguration->attributeSet instanceof Varien_Simplexml_Element){
|
| 1312 |
+
return $xmlData->attributeConfiguration->attributeSet;
|
| 1313 |
+
}
|
| 1314 |
+
}
|
| 1315 |
+
|
| 1316 |
+
public function importAttributeSet($parsedAttributeSet){
|
| 1317 |
+
$attributeSet_groups = array();
|
| 1318 |
+
$attributeSet_groups['status'] = array();
|
| 1319 |
+
$attributeSet_groups['id'] = array();
|
| 1320 |
+
|
| 1321 |
+
$attributegroup_id = array();
|
| 1322 |
+
$attributegroup_status = array();
|
| 1323 |
+
|
| 1324 |
+
foreach($parsedAttributeSet as $set){
|
| 1325 |
+
$attributeSetId = (string)$set->id;
|
| 1326 |
+
$attributeSetName = (string)$set->name;
|
| 1327 |
+
|
| 1328 |
+
if($attributeSetName == ''){
|
| 1329 |
+
$attributeSetName = $attributeSetId;
|
| 1330 |
+
}
|
| 1331 |
+
$attributeGrp = $set->attributeGroups->attributeGroup;
|
| 1332 |
+
$attribute_set_id = $this->createAttributeSet($attributeSetName,$attributeSetId);
|
| 1333 |
+
|
| 1334 |
+
foreach($attributeGrp as $attrgroup){
|
| 1335 |
+
$attributegroup_id = (string)$attrgroup->id;
|
| 1336 |
+
$attributegroup_status = (string)$attrgroup->isActive;
|
| 1337 |
+
$attributeSet_groups['id'][$attributegroup_id][] = $attribute_set_id ;
|
| 1338 |
+
$attributeSet_groups['status'][$attributegroup_id][] = $attributegroup_status ;
|
| 1339 |
+
}
|
| 1340 |
+
unset($attributegroup_status);
|
| 1341 |
+
unset($attributegroup_id);
|
| 1342 |
+
}
|
| 1343 |
+
$this->attributeGroupsGlobal = $attributeSet_groups;
|
| 1344 |
+
}
|
| 1345 |
+
|
| 1346 |
+
|
| 1347 |
+
public function createAttributeSet($attribute_set_name, $external_id ) {
|
| 1348 |
+
$helper = Mage::helper('adminhtml');
|
| 1349 |
+
$mapobj = Mage::getModel('customimport/customimport');
|
| 1350 |
+
$attributeSetId = $mapobj->getAttributeSetIdByExternalId($external_id);
|
| 1351 |
+
|
| 1352 |
+
$entityTypeId = $this->getEntityTypeId();
|
| 1353 |
+
$modelSet = Mage::getModel('eav/entity_attribute_set')
|
| 1354 |
+
->setEntityTypeId($entityTypeId);
|
| 1355 |
+
|
| 1356 |
+
if(isset($attributeSetId) && !empty($attributeSetId)) {
|
| 1357 |
+
$modelSet->load($attributeSetId);
|
| 1358 |
+
if (!$modelSet->getId()) {
|
| 1359 |
+
Mage::throwException(Mage::helper('catalog')->__('This attribute set no longer exists.'));
|
| 1360 |
+
}
|
| 1361 |
+
//filter html tags
|
| 1362 |
+
$modelSet->setAttributeSetName(trim($attribute_set_name));
|
| 1363 |
+
$modelSet->validate();
|
| 1364 |
+
$modelSet->save();
|
| 1365 |
+
return $attributeSetId;
|
| 1366 |
+
}
|
| 1367 |
+
// to add attribute set
|
| 1368 |
+
$modelSet->setAttributeSetName($attribute_set_name);
|
| 1369 |
+
|
| 1370 |
+
$defaultAttributeSetId = $this->getAttributeSetId('Default');
|
| 1371 |
+
try{
|
| 1372 |
+
if ($modelSet->validate()) {
|
| 1373 |
+
$attributeSetId = $modelSet->save()->getAttributeSetId();
|
| 1374 |
+
$modelSet->initFromSkeleton($defaultAttributeSetId)->save();
|
| 1375 |
+
}
|
| 1376 |
+
}catch(Exception $e){
|
| 1377 |
+
echo 'already exists';
|
| 1378 |
+
}
|
| 1379 |
+
// $attributeSetId = $this->getAttributeSetId($attribute_set_name);
|
| 1380 |
+
$mapobj->mapAttributeSet($external_id,$attributeSetId);
|
| 1381 |
+
return $attributeSetId;
|
| 1382 |
+
}
|
| 1383 |
+
|
| 1384 |
+
public function parseAttributegrp(){
|
| 1385 |
+
$xmlObj = $this->_xmlObj;
|
| 1386 |
+
$xmlData = $xmlObj->getNode();
|
| 1387 |
+
|
| 1388 |
+
if( $xmlData->attributeConfiguration->attributeGroup instanceof Varien_Simplexml_Element){
|
| 1389 |
+
return $xmlData->attributeConfiguration->attributeGroup;
|
| 1390 |
+
}
|
| 1391 |
+
}
|
| 1392 |
+
|
| 1393 |
+
public function importAttributeGrp($parsedAttribute){
|
| 1394 |
+
$setOfGroups = $this->attributeGroupsGlobal;
|
| 1395 |
+
foreach($parsedAttribute as $attribute){
|
| 1396 |
+
$attributeSets = array();
|
| 1397 |
+
|
| 1398 |
+
$attributesOfGroup = array(); // array to store attribute detail info of attribute group
|
| 1399 |
+
$attributesIdOfGroup = array();
|
| 1400 |
+
$attributesStatusOfGroup = array();
|
| 1401 |
+
$attributesSequenceOfGroup = array();
|
| 1402 |
+
|
| 1403 |
+
$groupAttributes = $attribute->groupedAttributes->attribute;
|
| 1404 |
+
foreach($groupAttributes as $grp){
|
| 1405 |
+
$attributesIdOfGroup[] = (string)$grp->id;
|
| 1406 |
+
$attributesStatusOfGroup[] = (string)$grp->isActive ? (string)$grp->isActive : 'Y';
|
| 1407 |
+
$attributesSequenceOfGroup[] = (string)$grp->position ? (string)$grp->position : 0;
|
| 1408 |
+
}
|
| 1409 |
+
$attributesOfGroup['attr_ids'] = $attributesIdOfGroup;
|
| 1410 |
+
$attributesOfGroup['attr_status'] = $attributesStatusOfGroup;
|
| 1411 |
+
$attributesOfGroup['attr_sequence'] = $attributesSequenceOfGroup;
|
| 1412 |
+
|
| 1413 |
+
$groupId = (string)$attribute->id;
|
| 1414 |
+
$groupName = (string)$attribute->name;
|
| 1415 |
+
|
| 1416 |
+
if($groupName ==''){
|
| 1417 |
+
$groupName = $groupId;
|
| 1418 |
+
}
|
| 1419 |
+
$attributeSets['set_ids'] = $setOfGroups['id'][$groupId];
|
| 1420 |
+
$attributeSets['set_status'] = $setOfGroups['status'][$groupId];
|
| 1421 |
+
|
| 1422 |
+
$this->manageAttributeGroup($groupName,$groupId,$attributeSets,$attributesOfGroup);
|
| 1423 |
+
unset($attributeSets);
|
| 1424 |
+
unset($attributesOfGroup);
|
| 1425 |
+
unset($attributesIdOfGroup);
|
| 1426 |
+
unset($attributesStatusOfGroup);
|
| 1427 |
+
unset($attributesSequenceOfGroup);
|
| 1428 |
+
}
|
| 1429 |
+
}
|
| 1430 |
+
|
| 1431 |
+
|
| 1432 |
+
public function manageAttributeGroup($attribute_group_name,$attribute_group_id,$attribute_set_ids,$attributesOfGroup) { // setname and group are arrays , $attribute_group_id is external group id
|
| 1433 |
+
foreach($attribute_set_ids['set_ids'] as $k=>$set_id){ // loop for attribute sets
|
| 1434 |
+
if($attribute_set_ids['set_status'][$k] == 'Y'){
|
| 1435 |
+
//create group here
|
| 1436 |
+
$res = $this->createAttributeGroup($attribute_group_name ,$attribute_group_id, $set_id);
|
| 1437 |
+
foreach($attributesOfGroup['attr_ids'] as $k=>$attribute_code){ // loop for all attributes
|
| 1438 |
+
if($attributesOfGroup['attr_status'][$k] == 'Y'){
|
| 1439 |
+
// insert attributes inside group
|
| 1440 |
+
$attributeSortOrder = 0;
|
| 1441 |
+
if (isset($attributesOfGroup['attr_sequence'])) {
|
| 1442 |
+
$attributeSortOrder = $attributesOfGroup['attr_sequence'][$k];
|
| 1443 |
+
}
|
| 1444 |
+
$this->importAttributeInsideGroup($attribute_group_id, $set_id , $attribute_code,$attributeSortOrder);
|
| 1445 |
+
|
| 1446 |
+
}else{
|
| 1447 |
+
$this->removeAttributeFromGroup($attribute_group_id, $set_id , $attribute_code);
|
| 1448 |
+
}
|
| 1449 |
+
}
|
| 1450 |
+
}
|
| 1451 |
+
else{
|
| 1452 |
+
// remove group from this set
|
| 1453 |
+
$this->removeAttributeGroup($attribute_group_name ,$attribute_group_id, $set_id);
|
| 1454 |
+
|
| 1455 |
+
}
|
| 1456 |
+
}
|
| 1457 |
+
}
|
| 1458 |
+
|
| 1459 |
+
public function removeAttributeFromGroup($attribute_group_id, $attributeSetId , $attribute_code){
|
| 1460 |
+
$mapobj = Mage::getModel('customimport/customimport');
|
| 1461 |
+
$attributeGroupId = $mapobj->getAttributeGroupByExternalId($attribute_group_id, $attributeSetId); // $attribute_group_id is external group id
|
| 1462 |
+
|
| 1463 |
+
if($attributeGroupId){
|
| 1464 |
+
$setup = new Mage_Eav_Model_Entity_Setup('core_setup');
|
| 1465 |
+
$attribute_id=$setup->getAttributeId('catalog_product', $attribute_code);
|
| 1466 |
+
|
| 1467 |
+
$attribute_exists = $mapobj->isAttributeExistsInGroup($attribute_id,$attributeGroupId);
|
| 1468 |
+
if($attribute_exists){
|
| 1469 |
+
$installer = $this->getInstaller();
|
| 1470 |
+
$installer->startSetup();
|
| 1471 |
+
$installer->deleteTableRow('eav/entity_attribute', 'attribute_id', $attribute_id, 'attribute_set_id', $attributeSetId);
|
| 1472 |
+
|
| 1473 |
+
$installer->endSetup();
|
| 1474 |
+
}else{
|
| 1475 |
+
// do nothing
|
| 1476 |
+
|
| 1477 |
+
}
|
| 1478 |
+
}
|
| 1479 |
+
}
|
| 1480 |
+
|
| 1481 |
+
public function removeAttributeGroup($attribute_group_name ,$attribute_group_id, $attributeSetId){
|
| 1482 |
+
$setup = new Mage_Eav_Model_Entity_Setup('core_setup');
|
| 1483 |
+
$mapobj = Mage::getModel('customimport/customimport');
|
| 1484 |
+
$attributeGroupId = $mapobj->getAttributeGroupByExternalId($attribute_group_id, $attributeSetId);
|
| 1485 |
+
if($attributeGroupId){
|
| 1486 |
+
// echo '<br/>found group, delete this group';
|
| 1487 |
+
$setup->removeAttributeGroup('catalog_product',$attributeSetId,$attributeGroupId);
|
| 1488 |
+
// $model->load($attributeGroupId)->delete(); it also works
|
| 1489 |
+
}else{
|
| 1490 |
+
echo 'group not available';
|
| 1491 |
+
}
|
| 1492 |
+
}
|
| 1493 |
+
|
| 1494 |
+
public function createAttributeGroup($attribute_group_name ,$attribute_group_id, $attributeSetId) {
|
| 1495 |
+
$model = Mage::getModel('eav/entity_attribute_group');
|
| 1496 |
+
$mapobj = Mage::getModel('customimport/customimport');
|
| 1497 |
+
$attributeGroupId = $mapobj->getAttributeGroupByExternalId($attribute_group_id, $attributeSetId);
|
| 1498 |
+
if(isset($attributeGroupId) && !empty($attributeGroupId)) {
|
| 1499 |
+
$model->load($attributeGroupId);
|
| 1500 |
+
$oldGroupName = $model->getAttributeGroupName();
|
| 1501 |
+
if($oldGroupName != $attribute_group_name){ // if name has been updated
|
| 1502 |
+
$model->setAttributeGroupName($attribute_group_name);
|
| 1503 |
+
if(!$model->itemExists()){
|
| 1504 |
+
$model->save();
|
| 1505 |
+
}
|
| 1506 |
+
}
|
| 1507 |
+
}
|
| 1508 |
+
else{
|
| 1509 |
+
$model->setAttributeGroupName($attribute_group_name)
|
| 1510 |
+
->setAttributeSetId($attributeSetId);
|
| 1511 |
+
if( $model->itemExists() ) {
|
| 1512 |
+
} else {
|
| 1513 |
+
try {
|
| 1514 |
+
// $model->save()->getAttributeGroupId();
|
| 1515 |
+
$model->save();
|
| 1516 |
+
} catch (Exception $e) {
|
| 1517 |
+
Mage::getSingleton('adminhtml/session')->addError(Mage::helper('catalog')->__('An error occurred while saving this group.'));
|
| 1518 |
+
}
|
| 1519 |
+
}
|
| 1520 |
+
$attributeGroupId = $mapobj->getGroupIdUsingSetId($attribute_group_name,$attributeSetId);
|
| 1521 |
+
$mapobj->mapAttributeGroup($attribute_group_id,$attributeGroupId,$attributeSetId); // externalid, magentoid
|
| 1522 |
+
}
|
| 1523 |
+
}
|
| 1524 |
+
public function importAttributeInsideGroup($attribute_group_id, $attributeSetId , $attribute_code,$attribute_sort_order) {
|
| 1525 |
+
$mapobj = Mage::getModel('customimport/customimport');
|
| 1526 |
+
$attributeGroupId = $mapobj->getAttributeGroupByExternalId($attribute_group_id, $attributeSetId); // $attribute_group_id is external group id
|
| 1527 |
+
|
| 1528 |
+
if($attributeGroupId){
|
| 1529 |
+
$setup = new Mage_Eav_Model_Entity_Setup('core_setup');
|
| 1530 |
+
$attribute_id=$setup->getAttributeId('catalog_product', $attribute_code);
|
| 1531 |
+
$attribute_exists = $mapobj->isAttributeExistsInGroup($attribute_id, $attributeGroupId);
|
| 1532 |
+
if($attribute_exists){
|
| 1533 |
+
$mapobj->updateSequenceOfAttribute($attributeGroupId, $attribute_id, $attribute_sort_order);
|
| 1534 |
+
}else{
|
| 1535 |
+
$setup->addAttributeToGroup('catalog_product', $attributeSetId, $attributeGroupId, $attribute_id, $attribute_sort_order);
|
| 1536 |
+
}
|
| 1537 |
+
}
|
| 1538 |
+
}
|
| 1539 |
+
|
| 1540 |
+
public function getAttributeGroupId($attribute_group_name , $attribute_set_name) {
|
| 1541 |
+
$entityTypeId = $this->getEntityTypeId();
|
| 1542 |
+
$attributeSetId = $this->getAttributeSetId($attribute_set_name);
|
| 1543 |
+
$installer = $this->getInstaller();//new Mage_Eav_Model_Entity_Setup(‘core_setup’);
|
| 1544 |
+
$attributeGroupObject = new Varien_Object($installer->getAttributeGroup($entityTypeId ,$attributeSetId, $attribute_group_name));
|
| 1545 |
+
return $attributeGroupId = $attributeGroupObject->getAttributeGroupId();
|
| 1546 |
+
}
|
| 1547 |
+
|
| 1548 |
+
public function getGroupIdUsingSetId($attribute_group_name , $attributeSetId) {
|
| 1549 |
+
$entityTypeId = $this->getEntityTypeId();
|
| 1550 |
+
$installer = $this->getInstaller();//new Mage_Eav_Model_Entity_Setup(‘core_setup’);
|
| 1551 |
+
$attributeGroupObject = new Varien_Object($installer->getAttributeGroup($entityTypeId ,$attributeSetId, $attribute_group_name));
|
| 1552 |
+
return $attributeGroupId = $attributeGroupObject->getAttributeGroupId();
|
| 1553 |
+
}
|
| 1554 |
+
|
| 1555 |
+
public function getEntityTypeId() {
|
| 1556 |
+
return $entityTypeId = Mage::getModel('catalog/product')->getResource()->getTypeId();
|
| 1557 |
+
}
|
| 1558 |
+
|
| 1559 |
+
public function getInstaller() {
|
| 1560 |
+
return new Mage_Catalog_Model_Resource_Eav_Mysql4_Setup('core_setup');
|
| 1561 |
+
}
|
| 1562 |
+
}
|
| 1563 |
+
?>
|
app/code/community/Gec/Customimport/Helper/Catalog/Image.php
ADDED
|
@@ -0,0 +1,141 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 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
|
| 8 |
+
# published by the Free Software Foundation, either version 3 of the
|
| 9 |
+
# License, or (at your option) any later version.
|
| 10 |
+
#
|
| 11 |
+
# This program is distributed in the hope that it will be useful,
|
| 12 |
+
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
| 13 |
+
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
| 14 |
+
# GNU Affero General Public License for more details.
|
| 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 |
+
|
| 20 |
+
class Gec_Customimport_Helper_Catalog_Image extends Mage_Catalog_Helper_Image
|
| 21 |
+
{
|
| 22 |
+
|
| 23 |
+
protected $_requestedImage;
|
| 24 |
+
|
| 25 |
+
/**
|
| 26 |
+
* Reset all previous data
|
| 27 |
+
*
|
| 28 |
+
* @return Mage_Catalog_Helper_Image
|
| 29 |
+
*/
|
| 30 |
+
protected function _reset()
|
| 31 |
+
{
|
| 32 |
+
$this->_model = null;
|
| 33 |
+
$this->_scheduleResize = false;
|
| 34 |
+
$this->_scheduleRotate = false;
|
| 35 |
+
$this->_angle = null;
|
| 36 |
+
$this->_watermark = null;
|
| 37 |
+
$this->_watermarkPosition = null;
|
| 38 |
+
$this->_watermarkSize = null;
|
| 39 |
+
$this->_watermarkImageOpacity = null;
|
| 40 |
+
$this->_product = null;
|
| 41 |
+
$this->_imageFile = null;
|
| 42 |
+
$this->_requestedImage = null;
|
| 43 |
+
return $this;
|
| 44 |
+
}
|
| 45 |
+
|
| 46 |
+
/**
|
| 47 |
+
* Initialize Helper to work with Image
|
| 48 |
+
*
|
| 49 |
+
* @param Mage_Catalog_Model_Product $product
|
| 50 |
+
* @param string $attributeName
|
| 51 |
+
* @param mixed $imageFile
|
| 52 |
+
* @return Mage_Catalog_Helper_Image
|
| 53 |
+
*/
|
| 54 |
+
public function init(Mage_Catalog_Model_Product $product, $attributeName, $imageFile=null)
|
| 55 |
+
{
|
| 56 |
+
$this->_reset();
|
| 57 |
+
$this->_setModel(Mage::getModel('catalog/product_image'));
|
| 58 |
+
$this->_getModel()->setDestinationSubdir($attributeName);
|
| 59 |
+
$this->setProduct($product);
|
| 60 |
+
|
| 61 |
+
$this->_requestedImage = $attributeName;
|
| 62 |
+
|
| 63 |
+
$this->setWatermark(
|
| 64 |
+
Mage::getStoreConfig("design/watermark/{$this->_getModel()->getDestinationSubdir()}_image")
|
| 65 |
+
);
|
| 66 |
+
$this->setWatermarkImageOpacity(
|
| 67 |
+
Mage::getStoreConfig("design/watermark/{$this->_getModel()->getDestinationSubdir()}_imageOpacity")
|
| 68 |
+
);
|
| 69 |
+
$this->setWatermarkPosition(
|
| 70 |
+
Mage::getStoreConfig("design/watermark/{$this->_getModel()->getDestinationSubdir()}_position")
|
| 71 |
+
);
|
| 72 |
+
$this->setWatermarkSize(
|
| 73 |
+
Mage::getStoreConfig("design/watermark/{$this->_getModel()->getDestinationSubdir()}_size")
|
| 74 |
+
);
|
| 75 |
+
|
| 76 |
+
if ($imageFile) {
|
| 77 |
+
$this->setImageFile($imageFile);
|
| 78 |
+
} else {
|
| 79 |
+
// add for work original size
|
| 80 |
+
$this->_getModel()->setBaseFile($this->getProduct()->getData($this->_getModel()->getDestinationSubdir()));
|
| 81 |
+
}
|
| 82 |
+
return $this;
|
| 83 |
+
}
|
| 84 |
+
|
| 85 |
+
/**
|
| 86 |
+
* Return Image URL
|
| 87 |
+
*
|
| 88 |
+
* @return string
|
| 89 |
+
*/
|
| 90 |
+
public function __toString()
|
| 91 |
+
{
|
| 92 |
+
try {
|
| 93 |
+
// echo $this->_requestedImage;
|
| 94 |
+
|
| 95 |
+
$model = $this->_getModel();
|
| 96 |
+
if ($this->getImageFile()) {
|
| 97 |
+
$model->setBaseFile($this->getImageFile());
|
| 98 |
+
} else {
|
| 99 |
+
$model->setBaseFile($this->getProduct()->getData($model->getDestinationSubdir()));
|
| 100 |
+
}
|
| 101 |
+
|
| 102 |
+
if($this->_requestedImage == 'image' || $this->_requestedImage == 'small_image' || $this->_requestedImage == 'thumbnail'){
|
| 103 |
+
$external_attribute = 'external_'.$this->_requestedImage;
|
| 104 |
+
$_product = Mage::getModel('catalog/product')->load($this->getProduct()->getId());
|
| 105 |
+
$externalImg = $_product->getData($external_attribute);
|
| 106 |
+
|
| 107 |
+
}
|
| 108 |
+
|
| 109 |
+
|
| 110 |
+
if ($model->isCached()) {
|
| 111 |
+
// return 'http://staging.serenusinfotech.com/smikum/gec/skin/frontend/default/default/images/media/col_left_callout.jpg';
|
| 112 |
+
if($externalImg){
|
| 113 |
+
return $externalImg;
|
| 114 |
+
}
|
| 115 |
+
return $model->getUrl();
|
| 116 |
+
} else {
|
| 117 |
+
if ($this->_scheduleRotate) {
|
| 118 |
+
$model->rotate($this->getAngle());
|
| 119 |
+
}
|
| 120 |
+
|
| 121 |
+
if ($this->_scheduleResize) {
|
| 122 |
+
$model->resize();
|
| 123 |
+
}
|
| 124 |
+
|
| 125 |
+
if ($this->getWatermark()) {
|
| 126 |
+
$model->setWatermark($this->getWatermark());
|
| 127 |
+
}
|
| 128 |
+
|
| 129 |
+
$url = $model->saveFile()->getUrl();
|
| 130 |
+
if($externalImg){
|
| 131 |
+
$url = $externalImg;
|
| 132 |
+
}
|
| 133 |
+
}
|
| 134 |
+
} catch (Exception $e) {
|
| 135 |
+
$url = Mage::getDesign()->getSkinUrl($this->getPlaceholder());
|
| 136 |
+
}
|
| 137 |
+
return $url;
|
| 138 |
+
// return 'http://staging.serenusinfotech.com/smikum/gec/skin/frontend/default/default/images/media/col_left_callout.jpg';
|
| 139 |
+
}
|
| 140 |
+
|
| 141 |
+
}
|
app/code/community/Gec/Customimport/Helper/Data.php
ADDED
|
@@ -0,0 +1,23 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 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
|
| 8 |
+
# published by the Free Software Foundation, either version 3 of the
|
| 9 |
+
# License, or (at your option) any later version.
|
| 10 |
+
#
|
| 11 |
+
# This program is distributed in the hope that it will be useful,
|
| 12 |
+
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
| 13 |
+
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
| 14 |
+
# GNU Affero General Public License for more details.
|
| 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 |
+
|
| 20 |
+
class Gec_Customimport_Helper_Data extends Mage_Core_Helper_Abstract
|
| 21 |
+
{
|
| 22 |
+
|
| 23 |
+
}
|
app/code/community/Gec/Customimport/Model/Attrgroup.php
ADDED
|
@@ -0,0 +1,30 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 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
|
| 8 |
+
# published by the Free Software Foundation, either version 3 of the
|
| 9 |
+
# License, or (at your option) any later version.
|
| 10 |
+
#
|
| 11 |
+
# This program is distributed in the hope that it will be useful,
|
| 12 |
+
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
| 13 |
+
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
| 14 |
+
# GNU Affero General Public License for more details.
|
| 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 |
+
|
| 20 |
+
class Gec_Customimport_Model_Attrgroup extends Mage_Core_Model_Abstract {
|
| 21 |
+
/**
|
| 22 |
+
* Constructor
|
| 23 |
+
*/
|
| 24 |
+
protected function _construct()
|
| 25 |
+
{
|
| 26 |
+
$this->_init('customimport/attrgroup');
|
| 27 |
+
}
|
| 28 |
+
}
|
| 29 |
+
|
| 30 |
+
?>
|
app/code/community/Gec/Customimport/Model/Attrsetmapping.php
ADDED
|
@@ -0,0 +1,30 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 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
|
| 8 |
+
# published by the Free Software Foundation, either version 3 of the
|
| 9 |
+
# License, or (at your option) any later version.
|
| 10 |
+
#
|
| 11 |
+
# This program is distributed in the hope that it will be useful,
|
| 12 |
+
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
| 13 |
+
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
| 14 |
+
# GNU Affero General Public License for more details.
|
| 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 |
+
|
| 20 |
+
class Gec_Customimport_Model_Attrsetmapping extends Mage_Core_Model_Abstract
|
| 21 |
+
{
|
| 22 |
+
/**
|
| 23 |
+
* Constructor
|
| 24 |
+
*/
|
| 25 |
+
protected function _construct()
|
| 26 |
+
{
|
| 27 |
+
$this->_init('customimport/attrsetmapping');
|
| 28 |
+
}
|
| 29 |
+
}
|
| 30 |
+
?>
|
app/code/community/Gec/Customimport/Model/Catalog/Resource/Eav/Mysql4/Attribute.php
ADDED
|
@@ -0,0 +1,105 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 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
|
| 8 |
+
# published by the Free Software Foundation, either version 3 of the
|
| 9 |
+
# License, or (at your option) any later version.
|
| 10 |
+
#
|
| 11 |
+
# This program is distributed in the hope that it will be useful,
|
| 12 |
+
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
| 13 |
+
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
| 14 |
+
# GNU Affero General Public License for more details.
|
| 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 |
+
|
| 20 |
+
class Gec_Customimport_Model_Catalog_Resource_Eav_Mysql4_Attribute extends Mage_Catalog_Model_Resource_Eav_Mysql4_Attribute
|
| 21 |
+
{
|
| 22 |
+
protected function _saveOption(Mage_Core_Model_Abstract $object)
|
| 23 |
+
{
|
| 24 |
+
$option = $object->getOption();
|
| 25 |
+
if (is_array($option)) {
|
| 26 |
+
$write = $this->_getWriteAdapter();
|
| 27 |
+
$optionTable = $this->getTable('attribute_option');
|
| 28 |
+
$optionValueTable = $this->getTable('attribute_option_value');
|
| 29 |
+
$stores = Mage::getModel('core/store')
|
| 30 |
+
->getResourceCollection()
|
| 31 |
+
->setLoadDefault(true)
|
| 32 |
+
->load();
|
| 33 |
+
|
| 34 |
+
if (isset($option['value'])) {
|
| 35 |
+
$attributeDefaultValue = array();
|
| 36 |
+
if (!is_array($object->getDefault())) {
|
| 37 |
+
$object->setDefault(array());
|
| 38 |
+
}
|
| 39 |
+
|
| 40 |
+
foreach ($option['value'] as $optionId => $values) {
|
| 41 |
+
$intOptionId = (int) $optionId;
|
| 42 |
+
if (!empty($option['delete'][$optionId])) {
|
| 43 |
+
if ($intOptionId) {
|
| 44 |
+
$condition = $write->quoteInto('option_id=?', $intOptionId);
|
| 45 |
+
$write->delete($optionTable, $condition);
|
| 46 |
+
}
|
| 47 |
+
|
| 48 |
+
continue;
|
| 49 |
+
}
|
| 50 |
+
|
| 51 |
+
if (!$intOptionId) {
|
| 52 |
+
$data = array(
|
| 53 |
+
'attribute_id' => $object->getId(),
|
| 54 |
+
'sort_order' => isset($option['order'][$optionId]) ? $option['order'][$optionId] : 0,
|
| 55 |
+
'externalid' => isset($option['externalid'][$optionId]) ? $option['externalid'][$optionId] : '',
|
| 56 |
+
);
|
| 57 |
+
$write->insert($optionTable, $data);
|
| 58 |
+
$intOptionId = $write->lastInsertId();
|
| 59 |
+
}
|
| 60 |
+
else {
|
| 61 |
+
$data = array(
|
| 62 |
+
'sort_order' => isset($option['order'][$optionId]) ? $option['order'][$optionId] : 0,
|
| 63 |
+
'externalid' => isset($option['externalid'][$optionId]) ? $option['externalid'][$optionId] : '',
|
| 64 |
+
);
|
| 65 |
+
$write->update($optionTable, $data, $write->quoteInto('option_id=?', $intOptionId));
|
| 66 |
+
}
|
| 67 |
+
|
| 68 |
+
if (in_array($optionId, $object->getDefault())) {
|
| 69 |
+
if ($object->getFrontendInput() == 'multiselect') {
|
| 70 |
+
$attributeDefaultValue[] = $intOptionId;
|
| 71 |
+
} else if ($object->getFrontendInput() == 'select') {
|
| 72 |
+
$attributeDefaultValue = array($intOptionId);
|
| 73 |
+
}
|
| 74 |
+
}
|
| 75 |
+
|
| 76 |
+
|
| 77 |
+
// Default value
|
| 78 |
+
if (!isset($values[0])) {
|
| 79 |
+
Mage::throwException(Mage::helper('eav')->__('Default option value is not defined.'));
|
| 80 |
+
}
|
| 81 |
+
|
| 82 |
+
$write->delete($optionValueTable, $write->quoteInto('option_id=?', $intOptionId));
|
| 83 |
+
foreach ($stores as $store) {
|
| 84 |
+
if (isset($values[$store->getId()]) && (!empty($values[$store->getId()]) || $values[$store->getId()] == "0")) {
|
| 85 |
+
$data = array(
|
| 86 |
+
'option_id' => $intOptionId,
|
| 87 |
+
'store_id' => $store->getId(),
|
| 88 |
+
'value' => $values[$store->getId()],
|
| 89 |
+
);
|
| 90 |
+
$write->insert($optionValueTable, $data);
|
| 91 |
+
}
|
| 92 |
+
}
|
| 93 |
+
}
|
| 94 |
+
|
| 95 |
+
$write->update($this->getMainTable(), array(
|
| 96 |
+
'default_value' => implode(',', $attributeDefaultValue)
|
| 97 |
+
), $write->quoteInto($this->getIdFieldName() . '=?', $object->getId()));
|
| 98 |
+
}
|
| 99 |
+
}
|
| 100 |
+
return $this;
|
| 101 |
+
|
| 102 |
+
|
| 103 |
+
}
|
| 104 |
+
|
| 105 |
+
}
|
app/code/community/Gec/Customimport/Model/Catalogentity.php
ADDED
|
@@ -0,0 +1,30 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 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
|
| 8 |
+
# published by the Free Software Foundation, either version 3 of the
|
| 9 |
+
# License, or (at your option) any later version.
|
| 10 |
+
#
|
| 11 |
+
# This program is distributed in the hope that it will be useful,
|
| 12 |
+
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
| 13 |
+
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
| 14 |
+
# GNU Affero General Public License for more details.
|
| 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 |
+
|
| 20 |
+
class Gec_Customimport_Model_Catalogentity extends Mage_Core_Model_Abstract
|
| 21 |
+
{
|
| 22 |
+
/**
|
| 23 |
+
* Constructor
|
| 24 |
+
*/
|
| 25 |
+
protected function _construct()
|
| 26 |
+
{
|
| 27 |
+
$this->_init('customimport/catalogentity');
|
| 28 |
+
}
|
| 29 |
+
}
|
| 30 |
+
?>
|
app/code/community/Gec/Customimport/Model/Customimport.php
ADDED
|
@@ -0,0 +1,140 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 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
|
| 8 |
+
# published by the Free Software Foundation, either version 3 of the
|
| 9 |
+
# License, or (at your option) any later version.
|
| 10 |
+
#
|
| 11 |
+
# This program is distributed in the hope that it will be useful,
|
| 12 |
+
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
| 13 |
+
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
| 14 |
+
# GNU Affero General Public License for more details.
|
| 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 |
+
|
| 20 |
+
class Gec_Customimport_Model_Customimport extends Mage_Core_Model_Abstract {
|
| 21 |
+
public function _construct() {
|
| 22 |
+
parent::_construct();
|
| 23 |
+
$this->_init('customimport/customimport');
|
| 24 |
+
}
|
| 25 |
+
|
| 26 |
+
/*to fetch the default set id by external set id*/
|
| 27 |
+
public function getAttributeSetIdByExternalId($externalId){ // works
|
| 28 |
+
$attrsetmappingCollection = Mage::getModel('customimport/attrsetmapping')
|
| 29 |
+
->getCollection()
|
| 30 |
+
->addFieldToFilter('external_id', array('eq' => $externalId));
|
| 31 |
+
return $attrsetmappingCollection->getFirstItem()->getMagentoId();
|
| 32 |
+
}
|
| 33 |
+
|
| 34 |
+
/*to insert a row for external id and default id of attribute set*/
|
| 35 |
+
public function mapAttributeSet($externalId, $magentoId){
|
| 36 |
+
$attrsetmapping = Mage::getModel('customimport/attrsetmapping');
|
| 37 |
+
$data = array('external_id' => $externalId, 'magento_id' => $magentoId);
|
| 38 |
+
$attrsetmapping->setData($data);
|
| 39 |
+
$attrsetmapping->save();
|
| 40 |
+
}
|
| 41 |
+
|
| 42 |
+
/*to check if attribute group exists in attribute set*/
|
| 43 |
+
public function getAttributeGroupByExternalId($externalId, $attributeSetId){
|
| 44 |
+
$attrgroupCollection = Mage::getModel('customimport/attrgroup')
|
| 45 |
+
->getCollection()
|
| 46 |
+
->addFieldToFilter('external_id', array('eq' => $externalId))
|
| 47 |
+
->addFieldToFilter('attribute_set_id', array('eq' => $attributeSetId));
|
| 48 |
+
|
| 49 |
+
return $attrgroupCollection->getFirstItem()->getMagentoId();
|
| 50 |
+
}
|
| 51 |
+
/*to insert a row to define relation between external id ,magento id of group along with setid*/
|
| 52 |
+
|
| 53 |
+
public function mapAttributeGroup($externalId, $magentoId, $attributeSetId){
|
| 54 |
+
$attrgroup = Mage::getModel('customimport/attrgroup');
|
| 55 |
+
$attrgroup->setData(
|
| 56 |
+
array('external_id' => $externalId,
|
| 57 |
+
'magento_id' => $magentoId,
|
| 58 |
+
'attribute_set_id' => $attributeSetId
|
| 59 |
+
))->save();
|
| 60 |
+
}
|
| 61 |
+
/*to get default group id from attribute group table using set id*/
|
| 62 |
+
public function getGroupIdUsingSetId($attribute_group_name, $attributeSetId){
|
| 63 |
+
$eavattributegroupCollection = Mage::getModel('customimport/eavattributegroup')
|
| 64 |
+
->getCollection()
|
| 65 |
+
->addFieldToFilter('attribute_group_name', array('eq' => $attribute_group_name))
|
| 66 |
+
->addFieldToFilter('attribute_set_id', array('eq' => $attributeSetId));
|
| 67 |
+
return $eavattributegroupCollection->getFirstItem()->getAttributeGroupId();
|
| 68 |
+
}
|
| 69 |
+
|
| 70 |
+
public function isAttributeExistsInGroup($attribute_id, $attributeGroupId){
|
| 71 |
+
$eaventityattributeCollection = Mage::getModel('customimport/eaventityattribute')
|
| 72 |
+
->getCollection()
|
| 73 |
+
->addFieldToFilter('attribute_group_id', array('eq' => $attributeGroupId))
|
| 74 |
+
->addFieldToFilter('attribute_id', array('eq' => $attribute_id));
|
| 75 |
+
return $eaventityattributeCollection->getFirstItem()->getEntityAttributeId();
|
| 76 |
+
}
|
| 77 |
+
|
| 78 |
+
public function updateSequenceOfAttribute($attributeGroupId, $attribute_id, $attribute_sort_order){
|
| 79 |
+
$eaventityattribute = Mage::getModel('customimport/eaventityattribute');
|
| 80 |
+
$eaventityattributeCollection = $eaventityattribute
|
| 81 |
+
->getCollection()
|
| 82 |
+
->addFieldToFilter('attribute_group_id', array('eq' => $attributeGroupId))
|
| 83 |
+
->addFieldToFilter('attribute_id', array('eq' => $attribute_id));
|
| 84 |
+
$id = $eaventityattributeCollection->getFirstItem()->getEntityAttributeId();
|
| 85 |
+
$data = array('sort_order' => $attribute_sort_order);
|
| 86 |
+
if($id){
|
| 87 |
+
$eaventityattribute->load($id)->addData($data);
|
| 88 |
+
try {
|
| 89 |
+
$eaventityattribute->setEntityAttributeId($id)->save();
|
| 90 |
+
echo "Data updated successfully.";
|
| 91 |
+
|
| 92 |
+
} catch (Exception $e){
|
| 93 |
+
echo $e->getMessage();
|
| 94 |
+
}
|
| 95 |
+
}
|
| 96 |
+
}
|
| 97 |
+
|
| 98 |
+
public function isOptionExistsInAttribute($external_id, $attributeId){
|
| 99 |
+
$eavattributeoptionCollection = Mage::getModel('customimport/eavattributeoption')->getCollection()
|
| 100 |
+
->addFieldToFilter('attribute_id',array('eq' => $attributeId))
|
| 101 |
+
->addFieldToFilter('externalid',array('eq' => $external_id));
|
| 102 |
+
return $eavattributeoptionCollection->getFirstItem()->getOptionId();
|
| 103 |
+
}
|
| 104 |
+
|
| 105 |
+
public function isSubcategoryExists($external_subcat_id, $parent_id){
|
| 106 |
+
$externalcatCollection = Mage::getModel('customimport/externalcategorymappinginfo')
|
| 107 |
+
->getCollection()
|
| 108 |
+
->addFieldToFilter('external_id', array('eq' => $external_subcat_id))
|
| 109 |
+
->addFieldToFilter('magento_pid', array('eq' => $parent_id));
|
| 110 |
+
return $externalcatCollection->getFirstItem()->getMagentoId();
|
| 111 |
+
}
|
| 112 |
+
|
| 113 |
+
public function isCategoryExists($external_subcat_id){
|
| 114 |
+
$externalcatCollection = Mage::getModel('customimport/externalcategorymappinginfo')
|
| 115 |
+
->getCollection()
|
| 116 |
+
->addFieldToFilter('external_id', array('eq' => $external_subcat_id));
|
| 117 |
+
return $externalcatCollection->getFirstItem()->getMagentoId();
|
| 118 |
+
|
| 119 |
+
}
|
| 120 |
+
|
| 121 |
+
public function updateCategoryMappingInfo($externalId, $magentoId, $externalParentId, $parentId){
|
| 122 |
+
$externalcatmappinginfo = Mage::getModel('customimport/externalcategorymappinginfo');
|
| 123 |
+
$externalcatmappinginfo->setData(
|
| 124 |
+
array('external_id' => $externalId,
|
| 125 |
+
'magento_id' => $magentoId,
|
| 126 |
+
'external_pid' => $externalParentId,
|
| 127 |
+
'magento_pid' => $parentId
|
| 128 |
+
))->save();
|
| 129 |
+
}
|
| 130 |
+
|
| 131 |
+
public function updateParent($parentId,$categoryId){
|
| 132 |
+
$data = array('parent_id' => $parentId);
|
| 133 |
+
$catalogentity = Mage::getModel('customimport/catalogentity')->load($categoryId)->addData($data);
|
| 134 |
+
try{
|
| 135 |
+
$catalogentity->setEntityId($categoryId)->save();
|
| 136 |
+
} catch (Exception $e){
|
| 137 |
+
echo $e->getMessage();
|
| 138 |
+
}
|
| 139 |
+
}
|
| 140 |
+
}
|
app/code/community/Gec/Customimport/Model/Eavattributegroup.php
ADDED
|
@@ -0,0 +1,30 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 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
|
| 8 |
+
# published by the Free Software Foundation, either version 3 of the
|
| 9 |
+
# License, or (at your option) any later version.
|
| 10 |
+
#
|
| 11 |
+
# This program is distributed in the hope that it will be useful,
|
| 12 |
+
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
| 13 |
+
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
| 14 |
+
# GNU Affero General Public License for more details.
|
| 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 |
+
|
| 20 |
+
class Gec_Customimport_Model_Eavattributegroup extends Mage_Core_Model_Abstract {
|
| 21 |
+
/**
|
| 22 |
+
* Constructor
|
| 23 |
+
*/
|
| 24 |
+
protected function _construct()
|
| 25 |
+
{
|
| 26 |
+
$this->_init('customimport/eavattributegroup');
|
| 27 |
+
}
|
| 28 |
+
}
|
| 29 |
+
|
| 30 |
+
?>
|
app/code/community/Gec/Customimport/Model/Eavattributeoption.php
ADDED
|
@@ -0,0 +1,30 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 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
|
| 8 |
+
# published by the Free Software Foundation, either version 3 of the
|
| 9 |
+
# License, or (at your option) any later version.
|
| 10 |
+
#
|
| 11 |
+
# This program is distributed in the hope that it will be useful,
|
| 12 |
+
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
| 13 |
+
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
| 14 |
+
# GNU Affero General Public License for more details.
|
| 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 |
+
|
| 20 |
+
class Gec_Customimport_Model_Eavattributeoption extends Mage_Core_Model_Abstract {
|
| 21 |
+
/**
|
| 22 |
+
* Constructor
|
| 23 |
+
*/
|
| 24 |
+
protected function _construct()
|
| 25 |
+
{
|
| 26 |
+
$this->_init('customimport/eavattributeoption');
|
| 27 |
+
}
|
| 28 |
+
}
|
| 29 |
+
|
| 30 |
+
?>
|
app/code/community/Gec/Customimport/Model/Eaventityattribute.php
ADDED
|
@@ -0,0 +1,30 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 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
|
| 8 |
+
# published by the Free Software Foundation, either version 3 of the
|
| 9 |
+
# License, or (at your option) any later version.
|
| 10 |
+
#
|
| 11 |
+
# This program is distributed in the hope that it will be useful,
|
| 12 |
+
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
| 13 |
+
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
| 14 |
+
# GNU Affero General Public License for more details.
|
| 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 |
+
|
| 20 |
+
class Gec_Customimport_Model_Eaventityattribute extends Mage_Core_Model_Abstract {
|
| 21 |
+
/**
|
| 22 |
+
* Constructor
|
| 23 |
+
*/
|
| 24 |
+
protected function _construct()
|
| 25 |
+
{
|
| 26 |
+
$this->_init('customimport/eaventityattribute');
|
| 27 |
+
}
|
| 28 |
+
}
|
| 29 |
+
|
| 30 |
+
?>
|
app/code/community/Gec/Customimport/Model/Externalcategorymappinginfo.php
ADDED
|
@@ -0,0 +1,30 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 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
|
| 8 |
+
# published by the Free Software Foundation, either version 3 of the
|
| 9 |
+
# License, or (at your option) any later version.
|
| 10 |
+
#
|
| 11 |
+
# This program is distributed in the hope that it will be useful,
|
| 12 |
+
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
| 13 |
+
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
| 14 |
+
# GNU Affero General Public License for more details.
|
| 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 |
+
|
| 20 |
+
class Gec_Customimport_Model_Externalcategorymappinginfo extends Mage_Core_Model_Abstract {
|
| 21 |
+
/**
|
| 22 |
+
* Constructor
|
| 23 |
+
*/
|
| 24 |
+
protected function _construct()
|
| 25 |
+
{
|
| 26 |
+
$this->_init('customimport/externalcategorymappinginfo');
|
| 27 |
+
}
|
| 28 |
+
}
|
| 29 |
+
|
| 30 |
+
?>
|
app/code/community/Gec/Customimport/Model/Mysql4/Attrgroup.php
ADDED
|
@@ -0,0 +1,28 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 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
|
| 8 |
+
# published by the Free Software Foundation, either version 3 of the
|
| 9 |
+
# License, or (at your option) any later version.
|
| 10 |
+
#
|
| 11 |
+
# This program is distributed in the hope that it will be useful,
|
| 12 |
+
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
| 13 |
+
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
| 14 |
+
# GNU Affero General Public License for more details.
|
| 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 |
+
|
| 20 |
+
class Gec_Customimport_Model_Mysql4_Attrgroup extends Mage_Core_Model_Mysql4_Abstract {
|
| 21 |
+
|
| 22 |
+
public function _construct() {
|
| 23 |
+
|
| 24 |
+
// Note that the external_attrgroup_id refers to the key field in your database table.
|
| 25 |
+
$this->_init('customimport/attrgroup', 'external_attrgroup_id');
|
| 26 |
+
}
|
| 27 |
+
|
| 28 |
+
}
|
app/code/community/Gec/Customimport/Model/Mysql4/Attrgroup/Collection.php
ADDED
|
@@ -0,0 +1,26 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 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
|
| 8 |
+
# published by the Free Software Foundation, either version 3 of the
|
| 9 |
+
# License, or (at your option) any later version.
|
| 10 |
+
#
|
| 11 |
+
# This program is distributed in the hope that it will be useful,
|
| 12 |
+
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
| 13 |
+
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
| 14 |
+
# GNU Affero General Public License for more details.
|
| 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 |
+
|
| 20 |
+
class Gec_Customimport_Model_Mysql4_Attrgroup_Collection extends Mage_Core_Model_Mysql4_Collection_Abstract {
|
| 21 |
+
|
| 22 |
+
public function _construct() {
|
| 23 |
+
parent::_construct();
|
| 24 |
+
$this->_init('customimport/attrgroup');
|
| 25 |
+
}
|
| 26 |
+
}
|
app/code/community/Gec/Customimport/Model/Mysql4/Attrsetmapping.php
ADDED
|
@@ -0,0 +1,32 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 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
|
| 8 |
+
# published by the Free Software Foundation, either version 3 of the
|
| 9 |
+
# License, or (at your option) any later version.
|
| 10 |
+
#
|
| 11 |
+
# This program is distributed in the hope that it will be useful,
|
| 12 |
+
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
| 13 |
+
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
| 14 |
+
# GNU Affero General Public License for more details.
|
| 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 |
+
|
| 20 |
+
class Gec_Customimport_Model_Mysql4_Attrsetmapping extends Mage_Core_Model_Mysql4_Abstract {
|
| 21 |
+
|
| 22 |
+
public function _construct() {
|
| 23 |
+
|
| 24 |
+
// Note that the external_attrsetmapping_id refers to the key field in your database table.
|
| 25 |
+
|
| 26 |
+
$this->_init('customimport/attrsetmapping', 'external_attrsetmapping_id');
|
| 27 |
+
}
|
| 28 |
+
|
| 29 |
+
}
|
| 30 |
+
|
| 31 |
+
|
| 32 |
+
?>
|
app/code/community/Gec/Customimport/Model/Mysql4/Attrsetmapping/Collection.php
ADDED
|
@@ -0,0 +1,26 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 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
|
| 8 |
+
# published by the Free Software Foundation, either version 3 of the
|
| 9 |
+
# License, or (at your option) any later version.
|
| 10 |
+
#
|
| 11 |
+
# This program is distributed in the hope that it will be useful,
|
| 12 |
+
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
| 13 |
+
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
| 14 |
+
# GNU Affero General Public License for more details.
|
| 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 |
+
|
| 20 |
+
class Gec_Customimport_Model_Mysql4_Attrsetmapping_Collection extends Mage_Core_Model_Mysql4_Collection_Abstract {
|
| 21 |
+
|
| 22 |
+
public function _construct() {
|
| 23 |
+
parent::_construct();
|
| 24 |
+
$this->_init('customimport/attrsetmapping');
|
| 25 |
+
}
|
| 26 |
+
}
|
app/code/community/Gec/Customimport/Model/Mysql4/Catalogentity.php
ADDED
|
@@ -0,0 +1,31 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 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
|
| 8 |
+
# published by the Free Software Foundation, either version 3 of the
|
| 9 |
+
# License, or (at your option) any later version.
|
| 10 |
+
#
|
| 11 |
+
# This program is distributed in the hope that it will be useful,
|
| 12 |
+
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
| 13 |
+
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
| 14 |
+
# GNU Affero General Public License for more details.
|
| 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 |
+
|
| 20 |
+
class Gec_Customimport_Model_Mysql4_Catalogentity extends Mage_Core_Model_Mysql4_Abstract {
|
| 21 |
+
|
| 22 |
+
public function _construct() {
|
| 23 |
+
|
| 24 |
+
// Note that the entity_id refers to the key field in your database table.
|
| 25 |
+
$this->_init('customimport/catalogentity', 'entity_id');
|
| 26 |
+
}
|
| 27 |
+
|
| 28 |
+
}
|
| 29 |
+
|
| 30 |
+
|
| 31 |
+
?>
|
app/code/community/Gec/Customimport/Model/Mysql4/Catalogentity/Collection.php
ADDED
|
@@ -0,0 +1,26 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 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
|
| 8 |
+
# published by the Free Software Foundation, either version 3 of the
|
| 9 |
+
# License, or (at your option) any later version.
|
| 10 |
+
#
|
| 11 |
+
# This program is distributed in the hope that it will be useful,
|
| 12 |
+
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
| 13 |
+
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
| 14 |
+
# GNU Affero General Public License for more details.
|
| 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 |
+
|
| 20 |
+
class Gec_Customimport_Model_Mysql4_Catalogentity_Collection extends Mage_Core_Model_Mysql4_Collection_Abstract {
|
| 21 |
+
|
| 22 |
+
public function _construct() {
|
| 23 |
+
parent::_construct();
|
| 24 |
+
$this->_init('customimport/catalogentity');
|
| 25 |
+
}
|
| 26 |
+
}
|
app/code/community/Gec/Customimport/Model/Mysql4/Customimport.php
ADDED
|
@@ -0,0 +1,27 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 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
|
| 8 |
+
# published by the Free Software Foundation, either version 3 of the
|
| 9 |
+
# License, or (at your option) any later version.
|
| 10 |
+
#
|
| 11 |
+
# This program is distributed in the hope that it will be useful,
|
| 12 |
+
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
| 13 |
+
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
| 14 |
+
# GNU Affero General Public License for more details.
|
| 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 |
+
|
| 20 |
+
class Gec_Customimport_Model_Mysql4_Customimport extends Mage_Core_Model_Mysql4_Abstract {
|
| 21 |
+
|
| 22 |
+
public function _construct() {
|
| 23 |
+
|
| 24 |
+
// Note that the entity_id refers to the key field in your database table.
|
| 25 |
+
$this->_init('customimport/customimport', 'customimport_id');
|
| 26 |
+
}
|
| 27 |
+
}
|
app/code/community/Gec/Customimport/Model/Mysql4/Customimport/Collection.php
ADDED
|
@@ -0,0 +1,26 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 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
|
| 8 |
+
# published by the Free Software Foundation, either version 3 of the
|
| 9 |
+
# License, or (at your option) any later version.
|
| 10 |
+
#
|
| 11 |
+
# This program is distributed in the hope that it will be useful,
|
| 12 |
+
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
| 13 |
+
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
| 14 |
+
# GNU Affero General Public License for more details.
|
| 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 |
+
|
| 20 |
+
class Gec_Customimport_Model_Mysql4_Customimport_Collection extends Mage_Core_Model_Mysql4_Collection_Abstract {
|
| 21 |
+
|
| 22 |
+
public function _construct() {
|
| 23 |
+
parent::_construct();
|
| 24 |
+
$this->_init('customimport/customimport');
|
| 25 |
+
}
|
| 26 |
+
}
|
app/code/community/Gec/Customimport/Model/Mysql4/Eavattributegroup.php
ADDED
|
@@ -0,0 +1,29 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 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
|
| 8 |
+
# published by the Free Software Foundation, either version 3 of the
|
| 9 |
+
# License, or (at your option) any later version.
|
| 10 |
+
#
|
| 11 |
+
# This program is distributed in the hope that it will be useful,
|
| 12 |
+
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
| 13 |
+
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
| 14 |
+
# GNU Affero General Public License for more details.
|
| 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 |
+
|
| 20 |
+
class Gec_Customimport_Model_Mysql4_Eavattributegroup extends Mage_Core_Model_Mysql4_Abstract {
|
| 21 |
+
|
| 22 |
+
public function _construct() {
|
| 23 |
+
|
| 24 |
+
// Note that the attribute_group_id refers to the key field in your database table.
|
| 25 |
+
$this->_init('customimport/eavattributegroup', 'attribute_group_id');
|
| 26 |
+
}
|
| 27 |
+
|
| 28 |
+
}
|
| 29 |
+
?>
|
app/code/community/Gec/Customimport/Model/Mysql4/Eavattributegroup/Collection.php
ADDED
|
@@ -0,0 +1,26 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 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
|
| 8 |
+
# published by the Free Software Foundation, either version 3 of the
|
| 9 |
+
# License, or (at your option) any later version.
|
| 10 |
+
#
|
| 11 |
+
# This program is distributed in the hope that it will be useful,
|
| 12 |
+
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
| 13 |
+
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
| 14 |
+
# GNU Affero General Public License for more details.
|
| 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 |
+
|
| 20 |
+
class Gec_Customimport_Model_Mysql4_Eavattributegroup_Collection extends Mage_Core_Model_Mysql4_Collection_Abstract {
|
| 21 |
+
|
| 22 |
+
public function _construct() {
|
| 23 |
+
parent::_construct();
|
| 24 |
+
$this->_init('customimport/eavattributegroup');
|
| 25 |
+
}
|
| 26 |
+
}
|
app/code/community/Gec/Customimport/Model/Mysql4/Eavattributeoption.php
ADDED
|
@@ -0,0 +1,31 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 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
|
| 8 |
+
# published by the Free Software Foundation, either version 3 of the
|
| 9 |
+
# License, or (at your option) any later version.
|
| 10 |
+
#
|
| 11 |
+
# This program is distributed in the hope that it will be useful,
|
| 12 |
+
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
| 13 |
+
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
| 14 |
+
# GNU Affero General Public License for more details.
|
| 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 |
+
|
| 20 |
+
class Gec_Customimport_Model_Mysql4_Eavattributeoption extends Mage_Core_Model_Mysql4_Abstract {
|
| 21 |
+
|
| 22 |
+
public function _construct() {
|
| 23 |
+
|
| 24 |
+
// Note that the option_id refers to the key field in your database table.
|
| 25 |
+
$this->_init('customimport/eavattributeoption', 'option_id');
|
| 26 |
+
}
|
| 27 |
+
|
| 28 |
+
}
|
| 29 |
+
|
| 30 |
+
|
| 31 |
+
?>
|
app/code/community/Gec/Customimport/Model/Mysql4/Eavattributeoption/Collection.php
ADDED
|
@@ -0,0 +1,26 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 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
|
| 8 |
+
# published by the Free Software Foundation, either version 3 of the
|
| 9 |
+
# License, or (at your option) any later version.
|
| 10 |
+
#
|
| 11 |
+
# This program is distributed in the hope that it will be useful,
|
| 12 |
+
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
| 13 |
+
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
| 14 |
+
# GNU Affero General Public License for more details.
|
| 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 |
+
|
| 20 |
+
class Gec_Customimport_Model_Mysql4_Eavattributeoption_Collection extends Mage_Core_Model_Mysql4_Collection_Abstract {
|
| 21 |
+
|
| 22 |
+
public function _construct() {
|
| 23 |
+
parent::_construct();
|
| 24 |
+
$this->_init('customimport/eavattributeoption');
|
| 25 |
+
}
|
| 26 |
+
}
|
app/code/community/Gec/Customimport/Model/Mysql4/Eaventityattribute.php
ADDED
|
@@ -0,0 +1,31 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 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
|
| 8 |
+
# published by the Free Software Foundation, either version 3 of the
|
| 9 |
+
# License, or (at your option) any later version.
|
| 10 |
+
#
|
| 11 |
+
# This program is distributed in the hope that it will be useful,
|
| 12 |
+
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
| 13 |
+
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
| 14 |
+
# GNU Affero General Public License for more details.
|
| 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 |
+
|
| 20 |
+
class Gec_Customimport_Model_Mysql4_Eaventityattribute extends Mage_Core_Model_Mysql4_Abstract {
|
| 21 |
+
|
| 22 |
+
public function _construct() {
|
| 23 |
+
|
| 24 |
+
// Note that the option_id refers to the key field in your database table.
|
| 25 |
+
$this->_init('customimport/eaventityattribute', 'entity_attribute_id');
|
| 26 |
+
}
|
| 27 |
+
|
| 28 |
+
}
|
| 29 |
+
|
| 30 |
+
|
| 31 |
+
?>
|
app/code/community/Gec/Customimport/Model/Mysql4/Eaventityattribute/Collection.php
ADDED
|
@@ -0,0 +1,26 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 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
|
| 8 |
+
# published by the Free Software Foundation, either version 3 of the
|
| 9 |
+
# License, or (at your option) any later version.
|
| 10 |
+
#
|
| 11 |
+
# This program is distributed in the hope that it will be useful,
|
| 12 |
+
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
| 13 |
+
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
| 14 |
+
# GNU Affero General Public License for more details.
|
| 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 |
+
|
| 20 |
+
class Gec_Customimport_Model_Mysql4_Eaventityattribute_Collection extends Mage_Core_Model_Mysql4_Collection_Abstract {
|
| 21 |
+
|
| 22 |
+
public function _construct() {
|
| 23 |
+
parent::_construct();
|
| 24 |
+
$this->_init('customimport/eaventityattribute');
|
| 25 |
+
}
|
| 26 |
+
}
|
app/code/community/Gec/Customimport/Model/Mysql4/Externalcategorymappinginfo.php
ADDED
|
@@ -0,0 +1,31 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 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
|
| 8 |
+
# published by the Free Software Foundation, either version 3 of the
|
| 9 |
+
# License, or (at your option) any later version.
|
| 10 |
+
#
|
| 11 |
+
# This program is distributed in the hope that it will be useful,
|
| 12 |
+
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
| 13 |
+
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
| 14 |
+
# GNU Affero General Public License for more details.
|
| 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 |
+
|
| 20 |
+
class Gec_Customimport_Model_Mysql4_Externalcategorymappinginfo extends Mage_Core_Model_Mysql4_Abstract {
|
| 21 |
+
|
| 22 |
+
public function _construct() {
|
| 23 |
+
|
| 24 |
+
// Note that the external_category_id refers to the key field in your database table.
|
| 25 |
+
$this->_init('customimport/externalcategorymappinginfo', 'external_category_id');
|
| 26 |
+
}
|
| 27 |
+
|
| 28 |
+
}
|
| 29 |
+
|
| 30 |
+
|
| 31 |
+
?>
|
app/code/community/Gec/Customimport/Model/Mysql4/Externalcategorymappinginfo/Collection.php
ADDED
|
@@ -0,0 +1,26 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 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
|
| 8 |
+
# published by the Free Software Foundation, either version 3 of the
|
| 9 |
+
# License, or (at your option) any later version.
|
| 10 |
+
#
|
| 11 |
+
# This program is distributed in the hope that it will be useful,
|
| 12 |
+
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
| 13 |
+
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
| 14 |
+
# GNU Affero General Public License for more details.
|
| 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 |
+
|
| 20 |
+
class Gec_Customimport_Model_Mysql4_Externalcategorymappinginfo_Collection extends Mage_Core_Model_Mysql4_Collection_Abstract {
|
| 21 |
+
|
| 22 |
+
public function _construct() {
|
| 23 |
+
parent::_construct();
|
| 24 |
+
$this->_init('customimport/externalcategorymappinginfo');
|
| 25 |
+
}
|
| 26 |
+
}
|
app/code/community/Gec/Customimport/Model/Mysql4/Setup.php
ADDED
|
@@ -0,0 +1,22 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 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
|
| 8 |
+
# published by the Free Software Foundation, either version 3 of the
|
| 9 |
+
# License, or (at your option) any later version.
|
| 10 |
+
#
|
| 11 |
+
# This program is distributed in the hope that it will be useful,
|
| 12 |
+
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
| 13 |
+
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
| 14 |
+
# GNU Affero General Public License for more details.
|
| 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 |
+
|
| 20 |
+
class Gec_Customimport_Model_Mysql4_Setup extends Mage_Catalog_Model_Resource_Eav_Mysql4_Setup{
|
| 21 |
+
|
| 22 |
+
}
|
app/code/community/Gec/Customimport/Model/Status.php
ADDED
|
@@ -0,0 +1,39 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 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
|
| 8 |
+
# published by the Free Software Foundation, either version 3 of the
|
| 9 |
+
# License, or (at your option) any later version.
|
| 10 |
+
#
|
| 11 |
+
# This program is distributed in the hope that it will be useful,
|
| 12 |
+
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
| 13 |
+
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
| 14 |
+
# GNU Affero General Public License for more details.
|
| 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 |
+
|
| 20 |
+
|
| 21 |
+
class Gec_Customimport_Model_Status extends Varien_Object {
|
| 22 |
+
/*
|
| 23 |
+
const STATUS_ENABLED = 1;
|
| 24 |
+
const STATUS_DISABLED = 2;
|
| 25 |
+
|
| 26 |
+
static public function getOptionArray() {
|
| 27 |
+
return array(
|
| 28 |
+
self::STATUS_ENABLED => Mage::helper('homeproducts')->__('Enabled'),
|
| 29 |
+
self::STATUS_DISABLED => Mage::helper('homeproducts')->__('Disabled')
|
| 30 |
+
);
|
| 31 |
+
}
|
| 32 |
+
*/
|
| 33 |
+
|
| 34 |
+
|
| 35 |
+
public function exampleMethod()
|
| 36 |
+
{
|
| 37 |
+
return 'status';
|
| 38 |
+
}
|
| 39 |
+
}
|
app/code/community/Gec/Customimport/controllers/IndexController.php
ADDED
|
@@ -0,0 +1,29 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 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
|
| 8 |
+
# published by the Free Software Foundation, either version 3 of the
|
| 9 |
+
# License, or (at your option) any later version.
|
| 10 |
+
#
|
| 11 |
+
# This program is distributed in the hope that it will be useful,
|
| 12 |
+
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
| 13 |
+
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
| 14 |
+
# GNU Affero General Public License for more details.
|
| 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 |
+
|
| 20 |
+
class Gec_Customimport_IndexController extends Mage_Core_Controller_Front_Action
|
| 21 |
+
{
|
| 22 |
+
public function indexAction()
|
| 23 |
+
{
|
| 24 |
+
$this->loadLayout(array('default'));
|
| 25 |
+
$this->renderLayout();
|
| 26 |
+
}
|
| 27 |
+
}
|
| 28 |
+
|
| 29 |
+
?>
|
app/code/community/Gec/Customimport/etc/config.xml
ADDED
|
@@ -0,0 +1,135 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
<?xml version="1.0"?>
|
| 2 |
+
<!--
|
| 3 |
+
/**
|
| 4 |
+
# Copyright (C) 2013 Global Era (http://www.globalera.com). All Rights Reserved
|
| 5 |
+
# @author Serenus Infotech <magento@serenusinfotech.com>
|
| 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
|
| 9 |
+
# published by the Free Software Foundation, either version 3 of the
|
| 10 |
+
# License, or (at your option) any later version.
|
| 11 |
+
#
|
| 12 |
+
# This program is distributed in the hope that it will be useful,
|
| 13 |
+
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
| 14 |
+
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
| 15 |
+
# GNU Affero General Public License for more details.
|
| 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 |
+
<config>
|
| 22 |
+
<modules>
|
| 23 |
+
<Gec_Customimport>
|
| 24 |
+
<version>0.1.0</version>
|
| 25 |
+
</Gec_Customimport>
|
| 26 |
+
</modules>
|
| 27 |
+
<frontend>
|
| 28 |
+
<routers>
|
| 29 |
+
<customimport>
|
| 30 |
+
<use>standard</use>
|
| 31 |
+
<args>
|
| 32 |
+
<module>Gec_Customimport</module>
|
| 33 |
+
<frontName>customimport</frontName>
|
| 34 |
+
</args>
|
| 35 |
+
</customimport>
|
| 36 |
+
</routers>
|
| 37 |
+
<layout>
|
| 38 |
+
<updates>
|
| 39 |
+
<customimport>
|
| 40 |
+
<file>customimport.xml</file>
|
| 41 |
+
</customimport>
|
| 42 |
+
</updates>
|
| 43 |
+
</layout>
|
| 44 |
+
</frontend>
|
| 45 |
+
<admin>
|
| 46 |
+
<routers>
|
| 47 |
+
<customimport>
|
| 48 |
+
<use>admin</use>
|
| 49 |
+
<args>
|
| 50 |
+
<module>Gec_Customimport</module>
|
| 51 |
+
<frontName>customimport</frontName>
|
| 52 |
+
</args>
|
| 53 |
+
</customimport>
|
| 54 |
+
</routers>
|
| 55 |
+
</admin>
|
| 56 |
+
<global>
|
| 57 |
+
<models>
|
| 58 |
+
<customimport>
|
| 59 |
+
<class>Gec_Customimport_Model</class>
|
| 60 |
+
<resourceModel>customimport_mysql4</resourceModel>
|
| 61 |
+
</customimport>
|
| 62 |
+
<customimport_mysql4>
|
| 63 |
+
<class>Gec_Customimport_Model_Mysql4</class>
|
| 64 |
+
<entities>
|
| 65 |
+
<attrsetmapping>
|
| 66 |
+
<table>external_attrsetmapping_info</table>
|
| 67 |
+
</attrsetmapping>
|
| 68 |
+
<attrgroup>
|
| 69 |
+
<table>external_attrgroup_mapping_info</table>
|
| 70 |
+
</attrgroup>
|
| 71 |
+
<eavattributegroup>
|
| 72 |
+
<table>eav_attribute_group</table>
|
| 73 |
+
</eavattributegroup>
|
| 74 |
+
<eaventityattribute>
|
| 75 |
+
<table>eav_entity_attribute</table>
|
| 76 |
+
</eaventityattribute>
|
| 77 |
+
<eavattributeoption>
|
| 78 |
+
<table>eav_attribute_option</table>
|
| 79 |
+
</eavattributeoption>
|
| 80 |
+
<externalcategorymappinginfo>
|
| 81 |
+
<table>external_category_mapping_info</table>
|
| 82 |
+
</externalcategorymappinginfo>
|
| 83 |
+
<catalogentity>
|
| 84 |
+
<table>catalog_category_entity</table>
|
| 85 |
+
</catalogentity>
|
| 86 |
+
</entities>
|
| 87 |
+
</customimport_mysql4>
|
| 88 |
+
<catalog_resource_eav_mysql4>
|
| 89 |
+
<rewrite>
|
| 90 |
+
<attribute>Gec_Customimport_Model_Catalog_Resource_Eav_Mysql4_Attribute</attribute>
|
| 91 |
+
</rewrite>
|
| 92 |
+
</catalog_resource_eav_mysql4>
|
| 93 |
+
</models>
|
| 94 |
+
<resources>
|
| 95 |
+
<customimport_setup>
|
| 96 |
+
<setup>
|
| 97 |
+
<module>Gec_Customimport</module>
|
| 98 |
+
</setup>
|
| 99 |
+
<connection>
|
| 100 |
+
<use>core_setup</use>
|
| 101 |
+
</connection>
|
| 102 |
+
</customimport_setup>
|
| 103 |
+
<customimport_write>
|
| 104 |
+
<connection>
|
| 105 |
+
<use>core_write</use>
|
| 106 |
+
</connection>
|
| 107 |
+
</customimport_write>
|
| 108 |
+
<customimport_read>
|
| 109 |
+
<connection>
|
| 110 |
+
<use>core_read</use>
|
| 111 |
+
</connection>
|
| 112 |
+
</customimport_read>
|
| 113 |
+
</resources>
|
| 114 |
+
<blocks>
|
| 115 |
+
<customimport>
|
| 116 |
+
<class>Gec_Customimport_Block</class>
|
| 117 |
+
</customimport>
|
| 118 |
+
<adminhtml>
|
| 119 |
+
<rewrite>
|
| 120 |
+
<catalog_product_attribute_edit_tab_options>Gec_Customimport_Block_Catalog_Product_Attribute_Edit_Tab_Options</catalog_product_attribute_edit_tab_options>
|
| 121 |
+
</rewrite>
|
| 122 |
+
</adminhtml>
|
| 123 |
+
</blocks>
|
| 124 |
+
<helpers>
|
| 125 |
+
<customimport>
|
| 126 |
+
<class>Gec_Customimport_Helper</class>
|
| 127 |
+
</customimport>
|
| 128 |
+
<catalog>
|
| 129 |
+
<rewrite>
|
| 130 |
+
<image>Gec_Customimport_Helper_Catalog_Image</image>
|
| 131 |
+
</rewrite>
|
| 132 |
+
</catalog>
|
| 133 |
+
</helpers>
|
| 134 |
+
</global>
|
| 135 |
+
</config>
|
app/code/community/Gec/Customimport/sql/customimport_setup/mysql4-install-0.1.0.php
ADDED
|
@@ -0,0 +1,192 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 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
|
| 8 |
+
# published by the Free Software Foundation, either version 3 of the
|
| 9 |
+
# License, or (at your option) any later version.
|
| 10 |
+
#
|
| 11 |
+
# This program is distributed in the hope that it will be useful,
|
| 12 |
+
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
| 13 |
+
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
| 14 |
+
# GNU Affero General Public License for more details.
|
| 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 |
+
|
| 20 |
+
$installer = $this;
|
| 21 |
+
$installer->startSetup();
|
| 22 |
+
|
| 23 |
+
$installer->run("
|
| 24 |
+
DROP TABLE IF EXISTS `{$this->getTable('external_attrgroup_mapping_info')}`;
|
| 25 |
+
CREATE TABLE IF NOT EXISTS `{$this->getTable('external_attrgroup_mapping_info')}` (
|
| 26 |
+
`external_attrgroup_id` int(12) NOT NULL AUTO_INCREMENT COMMENT 'auto increment id',
|
| 27 |
+
`attribute_set_id` smallint(5) unsigned NOT NULL COMMENT 'attribute set id',
|
| 28 |
+
`external_id` varchar(255) NOT NULL,
|
| 29 |
+
`magento_id` smallint(5) unsigned NOT NULL,
|
| 30 |
+
PRIMARY KEY (`external_attrgroup_id`),
|
| 31 |
+
UNIQUE KEY `magento_id` (`magento_id`)
|
| 32 |
+
) ENGINE=InnoDB DEFAULT CHARSET=latin1 AUTO_INCREMENT=1 ;
|
| 33 |
+
|
| 34 |
+
DROP TABLE IF EXISTS `{$this->getTable('external_attrsetmapping_info')}`;
|
| 35 |
+
CREATE TABLE IF NOT EXISTS `{$this->getTable('external_attrsetmapping_info')}` (
|
| 36 |
+
`external_attrsetmapping_id` int(12) NOT NULL AUTO_INCREMENT,
|
| 37 |
+
`external_id` varchar(255) NOT NULL,
|
| 38 |
+
`magento_id` smallint(5) unsigned NOT NULL COMMENT 'same as attribute_set_id',
|
| 39 |
+
PRIMARY KEY (`external_attrsetmapping_id`),
|
| 40 |
+
UNIQUE KEY `external_id` (`external_id`,`magento_id`),
|
| 41 |
+
KEY `magento_id` (`magento_id`)
|
| 42 |
+
) ENGINE=InnoDB DEFAULT CHARSET=latin1 AUTO_INCREMENT=1 ;
|
| 43 |
+
|
| 44 |
+
DROP TABLE IF EXISTS `{$this->getTable('external_category_mapping_info')}`;
|
| 45 |
+
CREATE TABLE IF NOT EXISTS `{$this->getTable('external_category_mapping_info')}` (
|
| 46 |
+
`external_category_id` int(12) NOT NULL AUTO_INCREMENT,
|
| 47 |
+
`external_id` varchar(255) NOT NULL,
|
| 48 |
+
`magento_id` int(10) unsigned NOT NULL,
|
| 49 |
+
`external_pid` varchar(255) NOT NULL,
|
| 50 |
+
`magento_pid` int(10) unsigned NOT NULL,
|
| 51 |
+
PRIMARY KEY (`external_category_id`),
|
| 52 |
+
UNIQUE KEY `external_id` (`external_id`,`magento_id`),
|
| 53 |
+
KEY `magento_id` (`magento_id`)
|
| 54 |
+
) ENGINE=InnoDB DEFAULT CHARSET=latin1 AUTO_INCREMENT=1 ;
|
| 55 |
+
|
| 56 |
+
ALTER TABLE `{$this->getTable('external_attrgroup_mapping_info')}` ADD FOREIGN KEY (`magento_id`) REFERENCES `{$this->getTable('eav_attribute_group')}` (`attribute_group_id`)
|
| 57 |
+
ON DELETE CASCADE ON UPDATE CASCADE;
|
| 58 |
+
|
| 59 |
+
ALTER TABLE `{$this->getTable('external_attrsetmapping_info')}` ADD FOREIGN KEY (`magento_id`) REFERENCES `{$this->getTable('eav_attribute_set')}` (`attribute_set_id`)
|
| 60 |
+
ON DELETE CASCADE ON UPDATE CASCADE;
|
| 61 |
+
|
| 62 |
+
ALTER TABLE `{$this->getTable('external_category_mapping_info')}` ADD FOREIGN KEY (`magento_id`) REFERENCES `{$this->getTable('catalog_category_entity')}` (`entity_id`)
|
| 63 |
+
ON DELETE CASCADE ON UPDATE CASCADE;
|
| 64 |
+
|
| 65 |
+
");
|
| 66 |
+
|
| 67 |
+
|
| 68 |
+
$resource = Mage::getSingleton('core/resource');
|
| 69 |
+
$read = $resource->getConnection('core_read');
|
| 70 |
+
$write = $resource->getConnection('core_write');
|
| 71 |
+
|
| 72 |
+
$database = Mage::getConfig()->getResourceConnectionConfig('default_setup')->dbname;
|
| 73 |
+
$option_table = Mage::getSingleton('core/resource')->getTableName('eav_attribute_option');
|
| 74 |
+
$attribute_table = Mage::getSingleton('core/resource')->getTableName('eav_attribute');
|
| 75 |
+
|
| 76 |
+
$query = "SELECT COUNT(*) as abc FROM information_schema.COLUMNS
|
| 77 |
+
WHERE TABLE_SCHEMA = '".$database."' AND
|
| 78 |
+
TABLE_NAME = '".$option_table."' AND COLUMN_NAME = 'externalid'";
|
| 79 |
+
|
| 80 |
+
$results = $read->fetchRow($query);
|
| 81 |
+
|
| 82 |
+
if($results['abc'] == '0'):
|
| 83 |
+
$result = $write->query("ALTER TABLE $option_table
|
| 84 |
+
ADD `externalid` VARCHAR( 255 ) NOT NULL AFTER `sort_order` ");
|
| 85 |
+
|
| 86 |
+
endif;
|
| 87 |
+
|
| 88 |
+
$setup = new Mage_Eav_Model_Entity_Setup('core_setup');
|
| 89 |
+
|
| 90 |
+
$query_2 = "Select attribute_code from $attribute_table
|
| 91 |
+
where entity_type_id = '3'
|
| 92 |
+
and attribute_code = 'external_id'";
|
| 93 |
+
|
| 94 |
+
$result_2 = $read->fetchRow($query_2);
|
| 95 |
+
|
| 96 |
+
if($result_2['attribute_code'] != 'external_id'):
|
| 97 |
+
$setup->addAttribute('catalog_category', 'external_id', array(
|
| 98 |
+
'group' => 'General Information',
|
| 99 |
+
'input' => 'text',
|
| 100 |
+
'type' => 'varchar',
|
| 101 |
+
'label' => 'External id',
|
| 102 |
+
'backend' => '',
|
| 103 |
+
'visible' => 1,
|
| 104 |
+
'required' => 0,
|
| 105 |
+
'user_defined' => 1,
|
| 106 |
+
'default' => '',
|
| 107 |
+
'global' => Mage_Catalog_Model_Resource_Eav_Attribute::SCOPE_GLOBAL,
|
| 108 |
+
));
|
| 109 |
+
|
| 110 |
+
endif;
|
| 111 |
+
$query_3 = "Select attribute_code from $attribute_table
|
| 112 |
+
where entity_type_id = '3'
|
| 113 |
+
and attribute_code = 'external_cat_image'";
|
| 114 |
+
$result_3 = $read->fetchRow($query_3);
|
| 115 |
+
|
| 116 |
+
|
| 117 |
+
if($result_3['attribute_code'] != 'external_cat_image'):
|
| 118 |
+
$setup->addAttribute('catalog_category', 'external_cat_image', array(
|
| 119 |
+
'group' => 'General Information',
|
| 120 |
+
'input' => 'text',
|
| 121 |
+
'type' => 'varchar',
|
| 122 |
+
'label' => 'External Image',
|
| 123 |
+
'backend' => '',
|
| 124 |
+
'visible' => 1,
|
| 125 |
+
'required' => 0,
|
| 126 |
+
'user_defined' => 1,
|
| 127 |
+
'default' => '',
|
| 128 |
+
'global' => Mage_Catalog_Model_Resource_Eav_Attribute::SCOPE_GLOBAL,
|
| 129 |
+
));
|
| 130 |
+
|
| 131 |
+
endif;
|
| 132 |
+
|
| 133 |
+
|
| 134 |
+
|
| 135 |
+
|
| 136 |
+
$setup->addAttribute('catalog_product', 'external_image', array(
|
| 137 |
+
'group' => 'Images',
|
| 138 |
+
'input' => 'text',
|
| 139 |
+
'type' => 'text',
|
| 140 |
+
'label' => 'External image',
|
| 141 |
+
'backend' => '',
|
| 142 |
+
'visible' => 1,
|
| 143 |
+
'required' => 0,
|
| 144 |
+
'user_defined' => 1,
|
| 145 |
+
'searchable' => 1,
|
| 146 |
+
'filterable' => 0,
|
| 147 |
+
'comparable' => 1,
|
| 148 |
+
'visible_on_front' => 1,
|
| 149 |
+
'visible_in_advanced_search' => 0,
|
| 150 |
+
'is_html_allowed_on_front' => 0,
|
| 151 |
+
'global' => Mage_Catalog_Model_Resource_Eav_Attribute::SCOPE_GLOBAL,
|
| 152 |
+
));
|
| 153 |
+
|
| 154 |
+
$setup->addAttribute('catalog_product', 'external_small_image', array(
|
| 155 |
+
'group' => 'Images',
|
| 156 |
+
'input' => 'text',
|
| 157 |
+
'type' => 'text',
|
| 158 |
+
'label' => 'External small image',
|
| 159 |
+
'backend' => '',
|
| 160 |
+
'visible' => 1,
|
| 161 |
+
'required' => 0,
|
| 162 |
+
'user_defined' => 1,
|
| 163 |
+
'searchable' => 1,
|
| 164 |
+
'filterable' => 0,
|
| 165 |
+
'comparable' => 1,
|
| 166 |
+
'visible_on_front' => 1,
|
| 167 |
+
'visible_in_advanced_search' => 0,
|
| 168 |
+
'is_html_allowed_on_front' => 0,
|
| 169 |
+
'global' => Mage_Catalog_Model_Resource_Eav_Attribute::SCOPE_GLOBAL,
|
| 170 |
+
));
|
| 171 |
+
|
| 172 |
+
|
| 173 |
+
$setup->addAttribute('catalog_product', 'external_thumbnail', array(
|
| 174 |
+
'group' => 'Images',
|
| 175 |
+
'input' => 'text',
|
| 176 |
+
'type' => 'text',
|
| 177 |
+
'label' => 'External thumbnail',
|
| 178 |
+
'backend' => '',
|
| 179 |
+
'visible' => 1,
|
| 180 |
+
'required' => 0,
|
| 181 |
+
'user_defined' => 1,
|
| 182 |
+
'searchable' => 1,
|
| 183 |
+
'filterable' => 0,
|
| 184 |
+
'comparable' => 1,
|
| 185 |
+
'visible_on_front' => 1,
|
| 186 |
+
'visible_in_advanced_search' => 0,
|
| 187 |
+
'is_html_allowed_on_front' => 0,
|
| 188 |
+
'global' => Mage_Catalog_Model_Resource_Eav_Attribute::SCOPE_GLOBAL,
|
| 189 |
+
));
|
| 190 |
+
|
| 191 |
+
|
| 192 |
+
$installer->endSetup();
|
app/design/adminhtml/default/default/template/gec/catalog/product/attribute/options.phtml
ADDED
|
@@ -0,0 +1,203 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 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
|
| 8 |
+
# published by the Free Software Foundation, either version 3 of the
|
| 9 |
+
# License, or (at your option) any later version.
|
| 10 |
+
#
|
| 11 |
+
# This program is distributed in the hope that it will be useful,
|
| 12 |
+
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
| 13 |
+
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
| 14 |
+
# GNU Affero General Public License for more details.
|
| 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 |
+
|
| 20 |
+
?>
|
| 21 |
+
<div>
|
| 22 |
+
<ul class="messages">
|
| 23 |
+
<li class="notice-msg">
|
| 24 |
+
<ul>
|
| 25 |
+
<li><?php echo Mage::helper('catalog')->__('If you do not specify an option value for a specific store view then the default (Admin) value will be used.') ?></li>
|
| 26 |
+
</ul>
|
| 27 |
+
</li>
|
| 28 |
+
</ul>
|
| 29 |
+
</div>
|
| 30 |
+
|
| 31 |
+
<div class="entity-edit">
|
| 32 |
+
<div class="entry-edit-head">
|
| 33 |
+
<h4 class="icon-head head-edit-form fieldset-legend"><?php echo Mage::helper('catalog')->__('Manage Titles (Size, Color, etc.)') ?></h4>
|
| 34 |
+
</div>
|
| 35 |
+
<div class="box">
|
| 36 |
+
<div class="hor-scroll">
|
| 37 |
+
<table class="dynamic-grid" cellspacing="0" id="attribute-labels-table">
|
| 38 |
+
<tr>
|
| 39 |
+
<?php foreach ($this->getStores() as $_store): ?>
|
| 40 |
+
<th><?php echo $_store->getName() ?></th>
|
| 41 |
+
<?php endforeach; ?>
|
| 42 |
+
</tr>
|
| 43 |
+
<tr>
|
| 44 |
+
<?php $_labels = $this->getLabelValues() ?>
|
| 45 |
+
<?php foreach ($this->getStores() as $_store): ?>
|
| 46 |
+
<td>
|
| 47 |
+
<input class="input-text<?php if($_store->getId()==0): ?> required-option<?php endif; ?>" type="text" name="frontend_label[<?php echo $_store->getId() ?>]" value="<?php echo $this->htmlEscape($_labels[$_store->getId()]) ?>"<?php if ($this->getReadOnly()):?> disabled="disabled"<?php endif;?>/>
|
| 48 |
+
</td>
|
| 49 |
+
<?php endforeach; ?>
|
| 50 |
+
</tr>
|
| 51 |
+
</table>
|
| 52 |
+
</div>
|
| 53 |
+
</div>
|
| 54 |
+
</div>
|
| 55 |
+
<br/>
|
| 56 |
+
<div class="entity-edit" id="matage-options-panel">
|
| 57 |
+
<div class="entry-edit-head">
|
| 58 |
+
<h4 class="icon-head head-edit-form fieldset-legend"><?php echo Mage::helper('catalog')->__('Manage Options (values of your attribute)') ?></h4>
|
| 59 |
+
</div>
|
| 60 |
+
<div class="box">
|
| 61 |
+
<div class="hor-scroll">
|
| 62 |
+
<table class="dynamic-grid" cellspacing="0" cellpadding="0">
|
| 63 |
+
<tr id="attribute-options-table">
|
| 64 |
+
<?php foreach ($this->getStores() as $_store): ?>
|
| 65 |
+
<th><?php echo $_store->getName() ?></th>
|
| 66 |
+
<?php endforeach; ?>
|
| 67 |
+
<th><?php echo Mage::helper('catalog')->__('Position') ?></th>
|
| 68 |
+
<th class="nobr a-center"><?php echo Mage::helper('catalog')->__('Is Default') ?></th>
|
| 69 |
+
<th class="nobr"><?php echo Mage::helper('catalog')->__('Externalid') ?></th>
|
| 70 |
+
<!-- <th class="nobr"><?php echo Mage::helper('catalog')->__('Thumbnail') ?></th>
|
| 71 |
+
<th class="nobr"><?php echo Mage::helper('catalog')->__('Image Preview') ?></th> -->
|
| 72 |
+
<th>
|
| 73 |
+
<?php if (!$this->getReadOnly()):?>
|
| 74 |
+
<?php echo $this->getAddNewButtonHtml() ?>
|
| 75 |
+
<?php endif;?>
|
| 76 |
+
</th>
|
| 77 |
+
</tr>
|
| 78 |
+
<tr class="no-display template" id="row-template">
|
| 79 |
+
<?php foreach ($this->getStores() as $_store): ?>
|
| 80 |
+
<td><input name="option[value][{{id}}][<?php echo $_store->getId() ?>]" value="{{store<?php echo $_store->getId() ?>}}" class="input-text<?php if($_store->getId()==0): ?> required-option<?php endif; ?>" type="text" <?php if ($this->getReadOnly()):?> disabled="disabled"<?php endif;?>/></td>
|
| 81 |
+
<?php endforeach; ?>
|
| 82 |
+
<td class="a-center"><input class="input-text" type="text" name="option[order][{{id}}]" value="{{sort_order}}" <?php if ($this->getReadOnly()):?> disabled="disabled"<?php endif;?>/></td>
|
| 83 |
+
<td><input class="input-radio" type="radio" name="default[]" value="{{id}}" <?php if ($this->getReadOnly()):?> disabled="disabled"<?php endif;?>/></td>
|
| 84 |
+
<td class="a-left">
|
| 85 |
+
<input type="hidden" class="delete-flag" name="option[delete][{{id}}]" value="" />
|
| 86 |
+
<?php if (!$this->getReadOnly()):?>
|
| 87 |
+
<?php echo $this->getDeleteButtonHtml() ?>
|
| 88 |
+
<?php endif;?>
|
| 89 |
+
</td>
|
| 90 |
+
</tr>
|
| 91 |
+
</table>
|
| 92 |
+
</div>
|
| 93 |
+
<input type="hidden" id="option-count-check" value="" />
|
| 94 |
+
</div>
|
| 95 |
+
</div>
|
| 96 |
+
<script type="text/javascript">
|
| 97 |
+
//<![CDATA[
|
| 98 |
+
var optionDefaultInputType = 'radio';
|
| 99 |
+
|
| 100 |
+
// IE removes quotes from element.innerHTML whenever it thinks they're not needed, which breaks html.
|
| 101 |
+
var templateText =
|
| 102 |
+
'<tr class="option-row">'+
|
| 103 |
+
<?php foreach ($this->getStores() as $_store): ?>
|
| 104 |
+
'<td><input name="option[value][{{id}}][<?php echo $_store->getId() ?>]" value="{{store<?php echo $_store->getId() ?>}}" class="input-text<?php if($_store->getId()==0): ?> required-option<?php endif; ?>" type="text" <?php if ($this->getReadOnly()):?> disabled="disabled"<?php endif;?>/><\/td>'+
|
| 105 |
+
<?php endforeach; ?>
|
| 106 |
+
'<td><input class="input-text" type="text" name="option[order][{{id}}]" value="{{sort_order}}" <?php if ($this->getReadOnly()):?> disabled="disabled"<?php endif;?>/><\/td>'+
|
| 107 |
+
'<td class="a-center"><input class="input-radio" type="{{intype}}" name="default[]" value="{{id}}" {{checked}} <?php if ($this->getReadOnly()):?> disabled="disabled"<?php endif;?>/><\/td>'+
|
| 108 |
+
'<td><input class="input-text" type="text" name="option[externalid][{{id}}]" value="{{externalid}}" <?php if ($this->getReadOnly()):?> disabled="disabled"<?php endif;?> /><\/td>'+
|
| 109 |
+
'<td class="a-left">'+
|
| 110 |
+
'<input type="hidden" class="delete-flag" name="option[delete][{{id}}]" value="" />'+
|
| 111 |
+
<?php if (!$this->getReadOnly()):?>
|
| 112 |
+
'<?php echo $this->getDeleteButtonHtml() ?>'+
|
| 113 |
+
<?php endif;?>
|
| 114 |
+
'<\/td>'+
|
| 115 |
+
'<\/tr>';
|
| 116 |
+
|
| 117 |
+
var attributeOption = {
|
| 118 |
+
table : $('attribute-options-table'),
|
| 119 |
+
templateSyntax : /(^|.|\r|\n)({{(\w+)}})/,
|
| 120 |
+
templateText : templateText,
|
| 121 |
+
itemCount : 0,
|
| 122 |
+
totalItems : 0,
|
| 123 |
+
add : function(data) {
|
| 124 |
+
this.template = new Template(this.templateText, this.templateSyntax);
|
| 125 |
+
if(!data.id){
|
| 126 |
+
data = {};
|
| 127 |
+
data.id = 'option_'+this.itemCount;
|
| 128 |
+
}
|
| 129 |
+
if (!data.intype)
|
| 130 |
+
data.intype = optionDefaultInputType;
|
| 131 |
+
|
| 132 |
+
Element.insert(this.table, {after: this.template.evaluate(data)});
|
| 133 |
+
this.bindRemoveButtons();
|
| 134 |
+
this.itemCount++;
|
| 135 |
+
this.totalItems++;
|
| 136 |
+
this.updateItemsCountField();
|
| 137 |
+
},
|
| 138 |
+
remove : function(event){
|
| 139 |
+
var element = $(Event.findElement(event, 'tr')); // !!! Button already
|
| 140 |
+
// have table parent in safari
|
| 141 |
+
// Safari workaround
|
| 142 |
+
element.ancestors().each(function(parentItem){
|
| 143 |
+
if (parentItem.hasClassName('option-row')) {
|
| 144 |
+
element = parentItem;
|
| 145 |
+
throw $break;
|
| 146 |
+
} else if (parentItem.hasClassName('box')) {
|
| 147 |
+
throw $break;
|
| 148 |
+
}
|
| 149 |
+
});
|
| 150 |
+
|
| 151 |
+
|
| 152 |
+
if(element){
|
| 153 |
+
var elementFlags = element.getElementsByClassName('delete-flag');
|
| 154 |
+
if(elementFlags[0]){
|
| 155 |
+
elementFlags[0].value=1;
|
| 156 |
+
}
|
| 157 |
+
|
| 158 |
+
element.addClassName('no-display');
|
| 159 |
+
element.addClassName('template');
|
| 160 |
+
element.hide();
|
| 161 |
+
this.totalItems--;
|
| 162 |
+
this.updateItemsCountField();
|
| 163 |
+
}
|
| 164 |
+
},
|
| 165 |
+
updateItemsCountField: function() {
|
| 166 |
+
if (this.totalItems > 0) {
|
| 167 |
+
$('option-count-check').value = '1';
|
| 168 |
+
} else {
|
| 169 |
+
$('option-count-check').value = '';
|
| 170 |
+
}
|
| 171 |
+
},
|
| 172 |
+
bindRemoveButtons : function(){
|
| 173 |
+
var buttons = $$('.delete-option');
|
| 174 |
+
for(var i=0;i<buttons.length;i++){
|
| 175 |
+
if(!$(buttons[i]).binded){
|
| 176 |
+
$(buttons[i]).binded = true;
|
| 177 |
+
Event.observe(buttons[i], 'click', this.remove.bind(this));
|
| 178 |
+
}
|
| 179 |
+
}
|
| 180 |
+
}
|
| 181 |
+
|
| 182 |
+
}
|
| 183 |
+
if($('row-template')){
|
| 184 |
+
$('row-template').remove();
|
| 185 |
+
}
|
| 186 |
+
attributeOption.bindRemoveButtons();
|
| 187 |
+
|
| 188 |
+
if($('add_new_option_button')){
|
| 189 |
+
Event.observe('add_new_option_button', 'click', attributeOption.add.bind(attributeOption));
|
| 190 |
+
}
|
| 191 |
+
Validation.addAllThese([
|
| 192 |
+
['required-option', '<?php echo Mage::helper('catalog')->__('Failed') ?>', function(v) {
|
| 193 |
+
return !Validation.get('IsEmpty').test(v);
|
| 194 |
+
}]]);
|
| 195 |
+
Validation.addAllThese([
|
| 196 |
+
['required-options-count', '<?php echo Mage::helper('catalog')->__('Options is required') ?>', function(v) {
|
| 197 |
+
return !Validation.get('IsEmpty').test(v);
|
| 198 |
+
}]]);
|
| 199 |
+
<?php foreach ($this->getOptionValues() as $_value): ?>
|
| 200 |
+
attributeOption.add(<?php echo $_value->toJson() ?>);
|
| 201 |
+
<?php endforeach; ?>
|
| 202 |
+
//]]>
|
| 203 |
+
</script>
|
app/design/frontend/default/default/layout/customimport.xml
ADDED
|
@@ -0,0 +1,64 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
<?xml version="1.0"?>
|
| 2 |
+
<!--
|
| 3 |
+
/**
|
| 4 |
+
# Copyright (C) 2013 Global Era (http://www.globalera.com). All Rights Reserved
|
| 5 |
+
# @author Serenus Infotech <magento@serenusinfotech.com>
|
| 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
|
| 9 |
+
# published by the Free Software Foundation, either version 3 of the
|
| 10 |
+
# License, or (at your option) any later version.
|
| 11 |
+
#
|
| 12 |
+
# This program is distributed in the hope that it will be useful,
|
| 13 |
+
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
| 14 |
+
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
| 15 |
+
# GNU Affero General Public License for more details.
|
| 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 |
+
<layout version="0.1.0">
|
| 22 |
+
<customimport_index_index>
|
| 23 |
+
<reference name="root">
|
| 24 |
+
<action method="setTemplate"><template>page/1column.phtml</template></action>
|
| 25 |
+
</reference>
|
| 26 |
+
<reference name="content">
|
| 27 |
+
<block type="customimport/customimport" name="hello" template="customimport/customimport.phtml"/>
|
| 28 |
+
</reference>
|
| 29 |
+
</customimport_index_index>
|
| 30 |
+
<catalog_product_view>
|
| 31 |
+
<reference name="product.info">
|
| 32 |
+
<block type="catalog/product_view_media" name="product.info.media" as="media" template="customimport/catalog/product/view/media.phtml" />
|
| 33 |
+
</reference>
|
| 34 |
+
</catalog_product_view>
|
| 35 |
+
|
| 36 |
+
<catalog_category_default>
|
| 37 |
+
<reference name="category.products">
|
| 38 |
+
<block type="catalog/category_view" name="category.products" template="catalog/category/view.phtml">
|
| 39 |
+
<action method="setTemplate"><template>customimport/catalog/category/view.phtml</template></action>
|
| 40 |
+
<block type="catalog/product_list" name="product_list" template="catalog/product/list.phtml">
|
| 41 |
+
<block type="catalog/product_list_toolbar" name="product_list_toolbar" template="catalog/product/list/toolbar.phtml">
|
| 42 |
+
<block type="page/html_pager" name="product_list_toolbar_pager"/>
|
| 43 |
+
<!-- The following code shows how to set your own pager increments -->
|
| 44 |
+
<!--
|
| 45 |
+
<action method="setDefaultListPerPage"><limit>4</limit></action>
|
| 46 |
+
<action method="setDefaultGridPerPage"><limit>9</limit></action>
|
| 47 |
+
<action method="addPagerLimit"><mode>list</mode><limit>2</limit></action>
|
| 48 |
+
<action method="addPagerLimit"><mode>list</mode><limit>4</limit></action>
|
| 49 |
+
<action method="addPagerLimit"><mode>list</mode><limit>6</limit></action>
|
| 50 |
+
<action method="addPagerLimit"><mode>list</mode><limit>8</limit></action>
|
| 51 |
+
<action method="addPagerLimit" translate="label"><mode>list</mode><limit>all</limit><label>All</label></action>
|
| 52 |
+
-->
|
| 53 |
+
</block>
|
| 54 |
+
<action method="addColumnCountLayoutDepend"><layout>empty</layout><count>6</count></action>
|
| 55 |
+
<action method="addColumnCountLayoutDepend"><layout>one_column</layout><count>5</count></action>
|
| 56 |
+
<action method="addColumnCountLayoutDepend"><layout>two_columns_left</layout><count>4</count></action>
|
| 57 |
+
<action method="addColumnCountLayoutDepend"><layout>two_columns_right</layout><count>4</count></action>
|
| 58 |
+
<action method="addColumnCountLayoutDepend"><layout>three_columns</layout><count>3</count></action>
|
| 59 |
+
<action method="setToolbarBlockName"><name>product_list_toolbar</name></action>
|
| 60 |
+
</block>
|
| 61 |
+
</block>
|
| 62 |
+
</reference>
|
| 63 |
+
</catalog_category_default>
|
| 64 |
+
</layout>
|
app/design/frontend/default/default/template/customimport/catalog/category/view.phtml
ADDED
|
@@ -0,0 +1,66 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 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
|
| 8 |
+
# published by the Free Software Foundation, either version 3 of the
|
| 9 |
+
# License, or (at your option) any later version.
|
| 10 |
+
#
|
| 11 |
+
# This program is distributed in the hope that it will be useful,
|
| 12 |
+
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
| 13 |
+
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
| 14 |
+
# GNU Affero General Public License for more details.
|
| 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 |
+
|
| 20 |
+
$_helper = $this->helper('catalog/output');
|
| 21 |
+
$_category = $this->getCurrentCategory();
|
| 22 |
+
$_imgHtml = '';
|
| 23 |
+
|
| 24 |
+
if ($_externalimgUrl = $_category->getExternalCatImage()) {
|
| 25 |
+
$_externalimgHtml = '<p class="category-image"><img src="'.$_externalimgUrl.'" alt="'.$this->htmlEscape($_category->getName()).'" title="'.$this->htmlEscape($_category->getName()).'" width="300px"/></p>';
|
| 26 |
+
// $_imgHtml = $_helper->categoryAttribute($_category, $_imgHtml, 'image');
|
| 27 |
+
}
|
| 28 |
+
else if ($_imgUrl = $_category->getImageUrl()) {
|
| 29 |
+
$_imgHtml = '<p class="category-image"><img src="'.$_imgUrl.'" alt="'.$this->htmlEscape($_category->getName()).'" title="'.$this->htmlEscape($_category->getName()).'" /></p>';
|
| 30 |
+
$_imgHtml = $_helper->categoryAttribute($_category, $_imgHtml, 'image');
|
| 31 |
+
}
|
| 32 |
+
?>
|
| 33 |
+
<div class="page-title category-title">
|
| 34 |
+
<?php if($this->IsRssCatalogEnable() && $this->IsTopCategory()): ?>
|
| 35 |
+
<a href="<?php echo $this->getRssLink() ?>" class="link-rss"><?php echo $this->__('Subscribe to RSS Feed') ?></a>
|
| 36 |
+
<?php endif; ?>
|
| 37 |
+
<h1><?php echo $_helper->categoryAttribute($_category, $_category->getName(), 'name') ?></h1>
|
| 38 |
+
</div>
|
| 39 |
+
|
| 40 |
+
<?php echo $this->getMessagesBlock()->getGroupedHtml() ?>
|
| 41 |
+
|
| 42 |
+
|
| 43 |
+
|
| 44 |
+
|
| 45 |
+
<?php if($_externalimgUrl): ?>
|
| 46 |
+
<?php echo $_externalimgHtml ;
|
| 47 |
+
elseif($_imgUrl): ?>
|
| 48 |
+
<?php echo $_imgHtml ?>
|
| 49 |
+
<?php endif; ?>
|
| 50 |
+
|
| 51 |
+
<?php if($_description=$this->getCurrentCategory()->getDescription()): ?>
|
| 52 |
+
<div class="category-description std">
|
| 53 |
+
<?php echo $_helper->categoryAttribute($_category, $_description, 'description') ?>
|
| 54 |
+
</div>
|
| 55 |
+
<?php endif; ?>
|
| 56 |
+
|
| 57 |
+
<?php if($this->isContentMode()): ?>
|
| 58 |
+
<?php echo $this->getCmsBlockHtml() ?>
|
| 59 |
+
|
| 60 |
+
<?php elseif($this->isMixedMode()): ?>
|
| 61 |
+
<?php echo $this->getCmsBlockHtml() ?>
|
| 62 |
+
<?php echo $this->getProductListHtml() ?>
|
| 63 |
+
|
| 64 |
+
<?php else: ?>
|
| 65 |
+
<?php echo $this->getProductListHtml() ?>
|
| 66 |
+
<?php endif; ?>
|
app/design/frontend/default/default/template/customimport/catalog/product/view/media.phtml
ADDED
|
@@ -0,0 +1,102 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 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
|
| 8 |
+
# published by the Free Software Foundation, either version 3 of the
|
| 9 |
+
# License, or (at your option) any later version.
|
| 10 |
+
#
|
| 11 |
+
# This program is distributed in the hope that it will be useful,
|
| 12 |
+
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
| 13 |
+
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
| 14 |
+
# GNU Affero General Public License for more details.
|
| 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 |
+
|
| 20 |
+
$_product = $this->getProduct();
|
| 21 |
+
$_helper = $this->helper('catalog/output');
|
| 22 |
+
?>
|
| 23 |
+
|
| 24 |
+
|
| 25 |
+
<?php if ($_product->getImage() != 'no_selection' && $_product->getImage()): ?>
|
| 26 |
+
<p class="product-image product-image-zoom">
|
| 27 |
+
<?php
|
| 28 |
+
$_img = '<img id="image" src="'.$this->helper('catalog/image')->init($_product, 'image').'" alt="'.$this->htmlEscape($this->getImageLabel()).'" title="'.$this->htmlEscape($this->getImageLabel()).'" />';
|
| 29 |
+
echo $_helper->productAttribute($_product, $_img, 'image');
|
| 30 |
+
?>
|
| 31 |
+
</p>
|
| 32 |
+
<p class="zoom-notice" id="track_hint"><?php echo $this->__('Double click on above image to view full picture') ?></p>
|
| 33 |
+
<div class="zoom">
|
| 34 |
+
<img id="zoom_out" src="<?php echo $this->getSkinUrl('images/slider_btn_zoom_out.gif') ?>" alt="<?php echo $this->__('Zoom Out') ?>" title="<?php echo $this->__('Zoom Out') ?>" class="btn-zoom-out" />
|
| 35 |
+
<div id="track">
|
| 36 |
+
<div id="handle"></div>
|
| 37 |
+
</div>
|
| 38 |
+
<img id="zoom_in" src="<?php echo $this->getSkinUrl('images/slider_btn_zoom_in.gif') ?>" alt="<?php echo $this->__('Zoom In') ?>" title="<?php echo $this->__('Zoom In') ?>" class="btn-zoom-in" />
|
| 39 |
+
</div>
|
| 40 |
+
<script type="text/javascript">
|
| 41 |
+
//<![CDATA[
|
| 42 |
+
Event.observe(window, 'load', function() {
|
| 43 |
+
product_zoom = new Product.Zoom('image', 'track', 'handle', 'zoom_in', 'zoom_out', 'track_hint');
|
| 44 |
+
});
|
| 45 |
+
//]]>
|
| 46 |
+
</script>
|
| 47 |
+
<?php else: ?>
|
| 48 |
+
<p class="product-image product-image-zoom">
|
| 49 |
+
<?php
|
| 50 |
+
$_img = '<img id="image" src="'.$this->helper('catalog/image')->init($_product, 'image')->resize(265).'" alt="'.$this->htmlEscape($this->getImageLabel()).'" title="'.$this->htmlEscape($this->getImageLabel()).'" />';
|
| 51 |
+
echo $_helper->productAttribute($_product, $_img, 'image');
|
| 52 |
+
?>
|
| 53 |
+
</p>
|
| 54 |
+
<p class="zoom-notice" id="track_hint"><?php echo $this->__('Double click on above image to view full picture') ?></p>
|
| 55 |
+
<div class="zoom">
|
| 56 |
+
<img id="zoom_out" src="<?php echo $this->getSkinUrl('images/slider_btn_zoom_out.gif') ?>" alt="<?php echo $this->__('Zoom Out') ?>" title="<?php echo $this->__('Zoom Out') ?>" class="btn-zoom-out" />
|
| 57 |
+
<div id="track">
|
| 58 |
+
<div id="handle"></div>
|
| 59 |
+
</div>
|
| 60 |
+
<img id="zoom_in" src="<?php echo $this->getSkinUrl('images/slider_btn_zoom_in.gif') ?>" alt="<?php echo $this->__('Zoom In') ?>" title="<?php echo $this->__('Zoom In') ?>" class="btn-zoom-in" />
|
| 61 |
+
</div>
|
| 62 |
+
<script type="text/javascript">
|
| 63 |
+
//<![CDATA[
|
| 64 |
+
Event.observe(window, 'load', function() {
|
| 65 |
+
product_zoom = new Product.Zoom('image', 'track', 'handle', 'zoom_in', 'zoom_out', 'track_hint');
|
| 66 |
+
});
|
| 67 |
+
//]]>
|
| 68 |
+
</script>
|
| 69 |
+
<?php endif; ?>
|
| 70 |
+
<?php
|
| 71 |
+
if($_product->getExternalImage()){
|
| 72 |
+
?>
|
| 73 |
+
<div class="more-views11">
|
| 74 |
+
<h2><?php echo $this->__('More Views') ?></h2>
|
| 75 |
+
<ul>
|
| 76 |
+
<li>
|
| 77 |
+
<a href="#" onclick="popWin('<?php echo $this->helper('catalog/image')->init($_product, 'image'); ?>', 'gallery', 'width=300,height=300,left=0,top=0,location=no,status=yes,scrollbars=yes,resizable=yes'); return false;">
|
| 78 |
+
<img src="<?php echo $this->helper('catalog/image')->init($_product, 'image'); ?>" width="56px;"/>
|
| 79 |
+
</a>
|
| 80 |
+
</li>
|
| 81 |
+
</ul>
|
| 82 |
+
</div>
|
| 83 |
+
<?php
|
| 84 |
+
}else{
|
| 85 |
+
if (count($this->getGalleryImages()) > 0): ?>
|
| 86 |
+
<div class="more-views">
|
| 87 |
+
<h2><?php echo $this->__('More Views') ?></h2>
|
| 88 |
+
<ul>
|
| 89 |
+
<?php foreach ($this->getGalleryImages() as $_image): ?>
|
| 90 |
+
<li>
|
| 91 |
+
<a href="#" onclick="popWin('<?php echo $_image->getUrl() ?>', 'gallery', 'width=300,height=300,left=0,top=0,location=no,status=yes,scrollbars=yes,resizable=yes'); return false;" title="<?php echo $this->htmlEscape($_image->getLabel()) ?>">
|
| 92 |
+
<img src="<?php echo $_image->getUrl(); ?>" width="56" height="56" alt="<?php echo $this->htmlEscape($_image->getLabel()) ?>" /></a>
|
| 93 |
+
</li>
|
| 94 |
+
<?php endforeach; ?>
|
| 95 |
+
</ul>
|
| 96 |
+
</div>
|
| 97 |
+
<?php
|
| 98 |
+
endif;
|
| 99 |
+
}
|
| 100 |
+
?>
|
| 101 |
+
|
| 102 |
+
|
app/design/frontend/default/default/template/customimport/customimport.phtml
ADDED
|
@@ -0,0 +1,102 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 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
|
| 8 |
+
# published by the Free Software Foundation, either version 3 of the
|
| 9 |
+
# License, or (at your option) any later version.
|
| 10 |
+
#
|
| 11 |
+
# This program is distributed in the hope that it will be useful,
|
| 12 |
+
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
| 13 |
+
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
| 14 |
+
# GNU Affero General Public License for more details.
|
| 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 |
+
ob_start();
|
| 20 |
+
?>
|
| 21 |
+
|
| 22 |
+
<?php
|
| 23 |
+
//$xmlPath = Mage::getBaseDir().DS.'gec-catalog-export-draft.xml';
|
| 24 |
+
|
| 25 |
+
$xmlPath = Mage::getBaseDir().DS.'gec-catalog-export-draft.xml'; //catalog-large.xml
|
| 26 |
+
|
| 27 |
+
$t0=microtime(true);
|
| 28 |
+
$this->parseXml($xmlPath);
|
| 29 |
+
|
| 30 |
+
//// CATAGORY AND CATEGORYRELATION IMPORT
|
| 31 |
+
|
| 32 |
+
$categories = $this->showCategory();
|
| 33 |
+
if($categories){
|
| 34 |
+
$this->importAllCategory($categories);
|
| 35 |
+
}
|
| 36 |
+
|
| 37 |
+
$this->parseAllCategoryRelation();
|
| 38 |
+
|
| 39 |
+
// ATTRIBUTE , ATTRIBUTE SET , ATTRIBUTE GROUP IMPORT
|
| 40 |
+
|
| 41 |
+
|
| 42 |
+
// ATTRIBUTE IMPORT
|
| 43 |
+
$parsedAttribute = $this->parseAttribute();
|
| 44 |
+
if($parsedAttribute){
|
| 45 |
+
$this->importAttribute($parsedAttribute);
|
| 46 |
+
}
|
| 47 |
+
// ATTRIBUTE SET IMPORT
|
| 48 |
+
$parsedAttributeSet = $this->parseAttributeSet();
|
| 49 |
+
if($parsedAttributeSet){
|
| 50 |
+
$this->importAttributeSet($parsedAttributeSet);
|
| 51 |
+
}
|
| 52 |
+
// ATTRIBUTE GROUP IMPORT
|
| 53 |
+
$parseAttributegrp = $this->parseAttributegrp();
|
| 54 |
+
if($parseAttributegrp){
|
| 55 |
+
$this->importAttributeGrp($parseAttributegrp);
|
| 56 |
+
}
|
| 57 |
+
|
| 58 |
+
//PRODUCT IMPORT
|
| 59 |
+
|
| 60 |
+
$products = $this->showProducts();
|
| 61 |
+
if($products){
|
| 62 |
+
$this->importAllProducts($products);
|
| 63 |
+
}
|
| 64 |
+
else{
|
| 65 |
+
echo 'no product available';
|
| 66 |
+
}
|
| 67 |
+
|
| 68 |
+
|
| 69 |
+
// ASSOCIATIONS <categoryProducts>
|
| 70 |
+
$associatedProductsCategory = $this->associatedProductsCategory();
|
| 71 |
+
if($associatedProductsCategory){
|
| 72 |
+
$this->associateProducts($associatedProductsCategory);
|
| 73 |
+
}else{
|
| 74 |
+
echo 'Category-Product association not found';
|
| 75 |
+
}
|
| 76 |
+
|
| 77 |
+
// ASSOCIATION <productAssociations>
|
| 78 |
+
$associatedProductsProducts = $this->associatedProductsProducts();
|
| 79 |
+
if($associatedProductsProducts){
|
| 80 |
+
$this->associatePdtPdt($associatedProductsProducts);
|
| 81 |
+
}else{
|
| 82 |
+
echo 'Product-Product association not found';
|
| 83 |
+
}
|
| 84 |
+
|
| 85 |
+
|
| 86 |
+
foreach($this->_log_array as $msg){
|
| 87 |
+
echo $msg.'<br>';
|
| 88 |
+
}
|
| 89 |
+
|
| 90 |
+
|
| 91 |
+
$t1 = microtime(true);
|
| 92 |
+
$time = $t1-$t0;
|
| 93 |
+
echo "It took $time sec" ;
|
| 94 |
+
|
| 95 |
+
// CODE FOR INDEXING
|
| 96 |
+
$indexingProcesses = Mage::getSingleton('index/indexer')->getProcessesCollection();
|
| 97 |
+
foreach ($indexingProcesses as $process) {
|
| 98 |
+
$process->reindexEverything();
|
| 99 |
+
}
|
| 100 |
+
|
| 101 |
+
ob_end_flush();
|
| 102 |
+
?>
|
app/etc/modules/Gec_Customimport.xml
ADDED
|
@@ -0,0 +1,29 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
<?xml version="1.0"?>
|
| 2 |
+
<!--
|
| 3 |
+
/**
|
| 4 |
+
# Copyright (C) 2013 Global Era (http://www.globalera.com). All Rights Reserved
|
| 5 |
+
# @author Serenus Infotech magento@serenusinfotech.com
|
| 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
|
| 9 |
+
# published by the Free Software Foundation, either version 3 of the
|
| 10 |
+
# License, or (at your option) any later version.
|
| 11 |
+
#
|
| 12 |
+
# This program is distributed in the hope that it will be useful,
|
| 13 |
+
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
| 14 |
+
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
| 15 |
+
# GNU Affero General Public License for more details.
|
| 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 |
+
|
| 22 |
+
<config>
|
| 23 |
+
<modules>
|
| 24 |
+
<Gec_Customimport>
|
| 25 |
+
<active>true</active>
|
| 26 |
+
<codePool>community</codePool>
|
| 27 |
+
</Gec_Customimport>
|
| 28 |
+
</modules>
|
| 29 |
+
</config>
|
package.xml
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
<?xml version="1.0"?>
|
| 2 |
+
<package>
|
| 3 |
+
<name>Gec_Customimport</name>
|
| 4 |
+
<version>1.0.0.1</version>
|
| 5 |
+
<stability>stable</stability>
|
| 6 |
+
<license uri="http://opensource.org/licenses/OSL-3.0">OSL v3.0</license>
|
| 7 |
+
<channel>community</channel>
|
| 8 |
+
<extends/>
|
| 9 |
+
<summary>Magento Catalog Import</summary>
|
| 10 |
+
<description>Import categories, attributes, and products
|
| 11 |
+
remote image hosting such as a CDN 
|
| 12 |
+
categories can exist in multiple hierarchies (multiple parents) uses standardized xml format 
|
| 13 |
+
supports simple and configurable products </description>
|
| 14 |
+
<notes>First Preview Release</notes>
|
| 15 |
+
<authors><author><name>Soham Chakraborty</name><user>sohamc</user><email>soham.c@serenusinfotech.com</email></author></authors>
|
| 16 |
+
<date>2013-08-28</date>
|
| 17 |
+
<time>09:17:56</time>
|
| 18 |
+
<contents><target name="magecommunity"><dir name="Gec"><dir name="Customimport"><dir name="Block"><dir name="Catalog"><dir name="Product"><dir name="Attribute"><dir name="Edit"><dir name="Tab"><file name="Options.php" hash="1e047f00d1b5f68c9c2f384f424fbcff"/></dir></dir></dir></dir></dir><file name="Catalogimport.php" hash="862ed0156f84a6d23f27340a5b89f7d2"/><file name="Customimport.php" hash="2d0164e58dca682f4329fda896d8d3e5"/></dir><dir name="Helper"><dir name="Catalog"><file name="Image.php" hash="220b080ed2c44b48845c809492f8a9ce"/></dir><file name="Data.php" hash="cfc9ed1492d7596f55af699338ae2b48"/></dir><dir name="Model"><file name="Attrgroup.php" hash="a6b88f887c01fa38ba9cb1785f9a9ef2"/><file name="Attrsetmapping.php" hash="4866f5daf86541eda627b0402b0a4a73"/><dir name="Catalog"><dir name="Resource"><dir name="Eav"><dir name="Mysql4"><file name="Attribute.php" hash="f566c298dcf6fcbcf205eaf30f42c3e9"/></dir></dir></dir></dir><file name="Catalogentity.php" hash="10a4802e8e5000bcf7a5f790c9d9272d"/><file name="Customimport.php" hash="bba2c82bbe293dea8c409d783f7733d3"/><file name="Eavattributegroup.php" hash="ff2f0ddc066a2435aab02efaa1e4b37a"/><file name="Eavattributeoption.php" hash="83250698b1799725e400df78064b304a"/><file name="Eaventityattribute.php" hash="a95ae774a45862670546d91b59758245"/><file name="Externalcategorymappinginfo.php" hash="be46d86f2d23512d99272a3ef579423b"/><dir name="Mysql4"><dir name="Attrgroup"><file name="Collection.php" hash="f0fe8e1ec28e9a9bae5cc6e342164b5b"/></dir><file name="Attrgroup.php" hash="617b51239bba81fadc552a008f84588e"/><dir name="Attrsetmapping"><file name="Collection.php" hash="2cef863ae94e3c7e2b402238aa972bf7"/></dir><file name="Attrsetmapping.php" hash="5468c266b66f0016ca95f95920266a37"/><dir name="Catalogentity"><file name="Collection.php" hash="796cbd65602a631eb1489282e870592b"/></dir><file name="Catalogentity.php" hash="f571664b764e2f0ee98e10117719a1e5"/><dir name="Customimport"><file name="Collection.php" hash="7272479b8266329ab7222fe715d97a00"/></dir><file name="Customimport.php" hash="a2b283e095834f3a6c029d82e80f9c51"/><dir name="Eavattributegroup"><file name="Collection.php" hash="50604f8f8141d61833bbb9310e41b9e0"/></dir><file name="Eavattributegroup.php" hash="ffdfc2633fa8ac20fbf0a4d778f5f2ee"/><dir name="Eavattributeoption"><file name="Collection.php" hash="e1747c078f11fa3defcd3eb1b32e4b9c"/></dir><file name="Eavattributeoption.php" hash="a415d4e885595147e4accb95fbbfcac2"/><dir name="Eaventityattribute"><file name="Collection.php" hash="3f3fd9745bc948795ec1a816f01117fd"/></dir><file name="Eaventityattribute.php" hash="53f6b150f0bb4b2404b9b01fd58d932b"/><dir name="Externalcategorymappinginfo"><file name="Collection.php" hash="25092c68f61af6366d92ff6ace3ed705"/></dir><file name="Externalcategorymappinginfo.php" hash="a7f2c5bad4a6a862cac7fa9c329c1c9c"/><file name="Setup.php" hash="0c576f054a917cea4c4f17634906b07e"/></dir><file name="Status.php" hash="ecc832de7f14cf1b090a4ea85d121a3d"/></dir><dir name="controllers"><file name="IndexController.php" hash="1cfee51e0767cdb0a57be6571af96ae9"/></dir><dir name="etc"><file name="config.xml" hash="5463b09b793e7d103bdbd1fbc1efbd71"/></dir><dir name="sql"><dir name="customimport_setup"><file name="mysql4-install-0.1.0.php" hash="4548015244372ed3b3d4c7cbf1bfdc9e"/></dir></dir></dir></dir></target><target name="mageetc"><dir name="modules"><file name="Gec_Customimport.xml" hash="05964d96d6c49a3cc026cb588ece6ec1"/></dir></target><target name="magedesign"><dir name="adminhtml"><dir name="default"><dir name="default"><dir name="template"><dir name="gec"><dir><dir name="catalog"><dir name="product"><dir name="attribute"><file name="options.phtml" hash="8aba77dcb4da3baebc5ac452010d6be2"/></dir></dir></dir></dir></dir></dir></dir></dir></dir><dir name="frontend"><dir name="default"><dir name="default"><dir name="layout"><file name="customimport.xml" hash="a60da75dd40c40f504c4c9b5550a3f75"/></dir><dir name="template"><dir name="customimport"><dir name="catalog"><dir name="category"><file name="view.phtml" hash="6c2b5b06641175e21501b41785874236"/></dir><dir name="product"><dir name="view"><file name="media.phtml" hash="97bdb89d181f73b5a373ad3c51763d2c"/></dir></dir></dir><file name="customimport.phtml" hash="11832de99dde955954d7d82fa43fd087"/></dir></dir></dir></dir></dir></target></contents>
|
| 19 |
+
<compatible/>
|
| 20 |
+
<dependencies><required><php><min>5.2.0</min><max>6.0.0</max></php></required></dependencies>
|
| 21 |
+
</package>
|
