Version Notes
Added multiple store views, synchronization with IceCat etc.
Download this release
Release Info
| Developer | IceShop |
| Extension | ice_import |
| Version | 1.0.0 |
| Comparing to | |
| See all releases | |
Version 1.0.0
- app/code/community/Capacitywebsolutions/Importproduct/Model/Convert/Adapter/Product.php +531 -0
- app/code/community/Capacitywebsolutions/Importproduct/Model/Observer.php +98 -0
- app/code/community/Capacitywebsolutions/Importproduct/Model/System/Config/Categoryactivity.php +14 -0
- app/code/community/Capacitywebsolutions/Importproduct/Model/System/Config/Imageimport.php +14 -0
- app/code/community/Capacitywebsolutions/Importproduct/Model/System/Config/Lockproddetails.php +15 -0
- app/code/community/Capacitywebsolutions/Importproduct/etc/config.xml +71 -0
- app/code/community/Capacitywebsolutions/Importproduct/etc/system.xml +64 -0
- app/code/community/Capacitywebsolutions/Importproduct/sql/importproduct_setup/mysql4-install-0.1.0.php +54 -0
- app/etc/modules/Capacitywebsolutions_Importproduct.xml +9 -0
- package.xml +18 -0
app/code/community/Capacitywebsolutions/Importproduct/Model/Convert/Adapter/Product.php
ADDED
|
@@ -0,0 +1,531 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
<?php
|
| 2 |
+
/**
|
| 3 |
+
* Import Multiple Images during Product Import
|
| 4 |
+
* Copyright � 2010 Web Design by Capacity Web Solutions Pvt. Ltd. All Rights Reserved.
|
| 5 |
+
* http://www.capacitywebsolutions.com
|
| 6 |
+
*/
|
| 7 |
+
|
| 8 |
+
class Capacitywebsolutions_Importproduct_Model_Convert_Adapter_Product extends Mage_Catalog_Model_Convert_Adapter_Product
|
| 9 |
+
{
|
| 10 |
+
/**
|
| 11 |
+
* Save product (import)
|
| 12 |
+
*
|
| 13 |
+
* @param array $importData
|
| 14 |
+
* @throws Mage_Core_Exception
|
| 15 |
+
* @return bool
|
| 16 |
+
*/
|
| 17 |
+
protected $custom_options = array();
|
| 18 |
+
|
| 19 |
+
|
| 20 |
+
public function saveRow(array $importData)
|
| 21 |
+
{
|
| 22 |
+
$product = $this->getProductModel()
|
| 23 |
+
->reset();
|
| 24 |
+
|
| 25 |
+
if (empty($importData['store'])) {
|
| 26 |
+
if (!is_null($this->getBatchParams('store'))) {
|
| 27 |
+
$store = $this->getStoreById($this->getBatchParams('store'));
|
| 28 |
+
} else {
|
| 29 |
+
$message = Mage::helper('catalog')->__('Skip import row, required field "%s" not defined', 'store');
|
| 30 |
+
Mage::throwException($message);
|
| 31 |
+
}
|
| 32 |
+
}
|
| 33 |
+
else {
|
| 34 |
+
$store = $this->getStoreByCode($importData['store']);
|
| 35 |
+
}
|
| 36 |
+
|
| 37 |
+
if ($store === false) {
|
| 38 |
+
$message = Mage::helper('catalog')->__('Skip import row, store "%s" field not exists', $importData['store']);
|
| 39 |
+
Mage::throwException($message);
|
| 40 |
+
}
|
| 41 |
+
|
| 42 |
+
if (empty($importData['sku'])) {
|
| 43 |
+
$message = Mage::helper('catalog')->__('Skip import row, required field "%s" not defined', 'sku');
|
| 44 |
+
Mage::throwException($message);
|
| 45 |
+
}
|
| 46 |
+
$product->setStoreId($store->getId());
|
| 47 |
+
$productId = $product->getIdBySku($importData['sku']);
|
| 48 |
+
|
| 49 |
+
if ($productId) {
|
| 50 |
+
$product->load($productId);
|
| 51 |
+
|
| 52 |
+
// check import type (Import only price & qty or all product info)
|
| 53 |
+
if('import_price_stock' == Mage::getStoreConfig('importprod_root/importprod/import_only_prices_stock',
|
| 54 |
+
$storeId)) {
|
| 55 |
+
$product->setPrice($importData['price']);
|
| 56 |
+
$product->setStockData(array('qty' => $importData['qty']));
|
| 57 |
+
$product->save();
|
| 58 |
+
return true;
|
| 59 |
+
}
|
| 60 |
+
|
| 61 |
+
}
|
| 62 |
+
else {
|
| 63 |
+
$productTypes = $this->getProductTypes();
|
| 64 |
+
$productAttributeSets = $this->getProductAttributeSets();
|
| 65 |
+
|
| 66 |
+
/**
|
| 67 |
+
* Check product define type
|
| 68 |
+
*/
|
| 69 |
+
if (empty($importData['type']) || !isset($productTypes[strtolower($importData['type'])])) {
|
| 70 |
+
$value = isset($importData['type']) ? $importData['type'] : '';
|
| 71 |
+
$message = Mage::helper('catalog')->__('Skip import row, is not valid value "%s" for field "%s"', $value, 'type');
|
| 72 |
+
Mage::throwException($message);
|
| 73 |
+
}
|
| 74 |
+
$product->setTypeId($productTypes[strtolower($importData['type'])]);
|
| 75 |
+
/**
|
| 76 |
+
* Check product define attribute set
|
| 77 |
+
*/
|
| 78 |
+
if (empty($importData['attribute_set']) || !isset($productAttributeSets[$importData['attribute_set']])) {
|
| 79 |
+
/*$value = isset($importData['attribute_set']) ? $importData['attribute_set'] : '';
|
| 80 |
+
$message = Mage::helper('catalog')->__('Skip import row, is not valid value "%s" for field "%s"', $value, 'attribute_set');
|
| 81 |
+
Mage::throwException($message);*/
|
| 82 |
+
}
|
| 83 |
+
$product->setAttributeSetId($productAttributeSets[$importData['attribute_set']]);
|
| 84 |
+
|
| 85 |
+
foreach ($this->_requiredFields as $field) {
|
| 86 |
+
$attribute = $this->getAttribute($field);
|
| 87 |
+
if (!isset($importData[$field]) && $attribute && $attribute->getIsRequired()) {
|
| 88 |
+
$message = Mage::helper('catalog')->__('Skip import row, required field "%s" for new products not defined', $field);
|
| 89 |
+
Mage::throwException($message);
|
| 90 |
+
}
|
| 91 |
+
}
|
| 92 |
+
}
|
| 93 |
+
|
| 94 |
+
$this->setProductTypeInstance($product);
|
| 95 |
+
|
| 96 |
+
if (isset($importData['category_ids'])) {
|
| 97 |
+
$product->setCategoryIds($importData['category_ids']);
|
| 98 |
+
}
|
| 99 |
+
/* if category name is in csv file */
|
| 100 |
+
if (isset($importData['categories'])) {
|
| 101 |
+
|
| 102 |
+
|
| 103 |
+
//get IceImport configs
|
| 104 |
+
$storeId = $store->getId();
|
| 105 |
+
$categoriesToActiveConf = Mage::getStoreConfig('importprod_root/importprod/category_active',
|
| 106 |
+
$storeId);
|
| 107 |
+
$cronScheduleConf = Mage::getStoreConfig('importprod_root/importprod/import_schedule',
|
| 108 |
+
$storeId);
|
| 109 |
+
$importImagesConf = Mage::getStoreConfig('importprod_root/importprod/import_images',
|
| 110 |
+
$storeId);
|
| 111 |
+
|
| 112 |
+
|
| 113 |
+
|
| 114 |
+
|
| 115 |
+
if (!empty($importData['leader_categories'])) {
|
| 116 |
+
$leader_categories = $importData['leader_categories'];
|
| 117 |
+
$leader_store = $this->getStoreByCode($importData['leader_store']);
|
| 118 |
+
} else {
|
| 119 |
+
$leader_categories = '';
|
| 120 |
+
$leader_store = '';
|
| 121 |
+
}
|
| 122 |
+
|
| 123 |
+
$unspsc = '';
|
| 124 |
+
if (!empty($importData['unspsc'])) {
|
| 125 |
+
$unspsc = $importData['unspsc'];
|
| 126 |
+
}
|
| 127 |
+
|
| 128 |
+
$categoryIds = $this->_addCategories($importData['categories'], $leader_categories, $store, $leader_store, $unspsc, $categoriesToActiveConf);
|
| 129 |
+
if ($categoryIds) {
|
| 130 |
+
|
| 131 |
+
// check, that's product exist
|
| 132 |
+
$oldProductId = $product->getIdBySku($importData['sku']);
|
| 133 |
+
|
| 134 |
+
if ($oldProductId) {
|
| 135 |
+
$oldCategoryIds = Mage::getModel('catalog/product')
|
| 136 |
+
->load($oldProductId)
|
| 137 |
+
->getCategoryIds();
|
| 138 |
+
$categoryIds .= ','.implode(',', $oldCategoryIds);
|
| 139 |
+
}
|
| 140 |
+
|
| 141 |
+
$product->setCategoryIds($categoryIds);
|
| 142 |
+
}
|
| 143 |
+
}
|
| 144 |
+
foreach ($this->_ignoreFields as $field) {
|
| 145 |
+
if (isset($importData[$field])) {
|
| 146 |
+
unset($importData[$field]);
|
| 147 |
+
}
|
| 148 |
+
}
|
| 149 |
+
|
| 150 |
+
if ($store->getId() != 0) {
|
| 151 |
+
$websiteIds = $product->getWebsiteIds();
|
| 152 |
+
if (!is_array($websiteIds)) {
|
| 153 |
+
$websiteIds = array();
|
| 154 |
+
}
|
| 155 |
+
if (!in_array($store->getWebsiteId(), $websiteIds)) {
|
| 156 |
+
$websiteIds[] = $store->getWebsiteId();
|
| 157 |
+
}
|
| 158 |
+
$product->setWebsiteIds($websiteIds);
|
| 159 |
+
}
|
| 160 |
+
|
| 161 |
+
if (isset($importData['websites'])) {
|
| 162 |
+
$websiteIds = $product->getWebsiteIds();
|
| 163 |
+
if (!is_array($websiteIds)) {
|
| 164 |
+
$websiteIds = array();
|
| 165 |
+
}
|
| 166 |
+
$websiteCodes = explode(',', $importData['websites']);
|
| 167 |
+
foreach ($websiteCodes as $websiteCode) {
|
| 168 |
+
try {
|
| 169 |
+
$website = Mage::app()->getWebsite(trim($websiteCode));
|
| 170 |
+
if (!in_array($website->getId(), $websiteIds)) {
|
| 171 |
+
$websiteIds[] = $website->getId();
|
| 172 |
+
}
|
| 173 |
+
}
|
| 174 |
+
catch (Exception $e) {}
|
| 175 |
+
}
|
| 176 |
+
$product->setWebsiteIds($websiteIds);
|
| 177 |
+
unset($websiteIds);
|
| 178 |
+
}
|
| 179 |
+
|
| 180 |
+
foreach ($importData as $field => $value) {
|
| 181 |
+
if (in_array($field, $this->_inventoryFields)) {
|
| 182 |
+
continue;
|
| 183 |
+
}
|
| 184 |
+
if (in_array($field, $this->_imageFields)) {
|
| 185 |
+
continue;
|
| 186 |
+
}
|
| 187 |
+
$attribute = $this->getAttribute($field);
|
| 188 |
+
if (!$attribute) {
|
| 189 |
+
|
| 190 |
+
if(strpos($field,':')!==FALSE && strlen($value)) {
|
| 191 |
+
$values=explode('|',$value);
|
| 192 |
+
if(count($values)>0) {
|
| 193 |
+
@list($title,$type,$is_required,$sort_order) = explode(':',$field);
|
| 194 |
+
$title = ucfirst(str_replace('_',' ',$title));
|
| 195 |
+
$custom_options[] = array(
|
| 196 |
+
'is_delete'=>0,
|
| 197 |
+
'title'=>$title,
|
| 198 |
+
'previous_group'=>'',
|
| 199 |
+
'previous_type'=>'',
|
| 200 |
+
'type'=>$type,
|
| 201 |
+
'is_require'=>$is_required,
|
| 202 |
+
'sort_order'=>$sort_order,
|
| 203 |
+
'values'=>array()
|
| 204 |
+
);
|
| 205 |
+
foreach($values as $v) {
|
| 206 |
+
$parts = explode(':',$v);
|
| 207 |
+
$title = $parts[0];
|
| 208 |
+
if(count($parts)>1) {
|
| 209 |
+
$price_type = $parts[1];
|
| 210 |
+
} else {
|
| 211 |
+
$price_type = 'fixed';
|
| 212 |
+
}
|
| 213 |
+
if(count($parts)>2) {
|
| 214 |
+
$price = $parts[2];
|
| 215 |
+
} else {
|
| 216 |
+
$price =0;
|
| 217 |
+
}
|
| 218 |
+
if(count($parts)>3) {
|
| 219 |
+
$sku = $parts[3];
|
| 220 |
+
} else {
|
| 221 |
+
$sku='';
|
| 222 |
+
}
|
| 223 |
+
if(count($parts)>4) {
|
| 224 |
+
$sort_order = $parts[4];
|
| 225 |
+
} else {
|
| 226 |
+
$sort_order = 0;
|
| 227 |
+
}
|
| 228 |
+
switch($type) {
|
| 229 |
+
case 'file':
|
| 230 |
+
/* TODO */
|
| 231 |
+
break;
|
| 232 |
+
|
| 233 |
+
case 'field':
|
| 234 |
+
case 'area':
|
| 235 |
+
$custom_options[count($custom_options) - 1]['max_characters'] = $sort_order;
|
| 236 |
+
/* NO BREAK */
|
| 237 |
+
|
| 238 |
+
case 'date':
|
| 239 |
+
case 'date_time':
|
| 240 |
+
case 'time':
|
| 241 |
+
$custom_options[count($custom_options) - 1]['price_type'] = $price_type;
|
| 242 |
+
$custom_options[count($custom_options) - 1]['price'] = $price;
|
| 243 |
+
$custom_options[count($custom_options) - 1]['sku'] = $sku;
|
| 244 |
+
break;
|
| 245 |
+
|
| 246 |
+
case 'drop_down':
|
| 247 |
+
case 'radio':
|
| 248 |
+
case 'checkbox':
|
| 249 |
+
case 'multiple':
|
| 250 |
+
default:
|
| 251 |
+
$custom_options[count($custom_options) - 1]['values'][]=array(
|
| 252 |
+
'is_delete'=>0,
|
| 253 |
+
'title'=>$title,
|
| 254 |
+
'option_type_id'=>-1,
|
| 255 |
+
'price_type'=>$price_type,
|
| 256 |
+
'price'=>$price,
|
| 257 |
+
'sku'=>$sku,
|
| 258 |
+
'sort_order'=>$sort_order,
|
| 259 |
+
);
|
| 260 |
+
break;
|
| 261 |
+
}
|
| 262 |
+
}
|
| 263 |
+
}
|
| 264 |
+
}
|
| 265 |
+
|
| 266 |
+
continue;
|
| 267 |
+
}
|
| 268 |
+
|
| 269 |
+
$isArray = false;
|
| 270 |
+
$setValue = $value;
|
| 271 |
+
|
| 272 |
+
if ($attribute->getFrontendInput() == 'multiselect') {
|
| 273 |
+
$value = explode(self::MULTI_DELIMITER, $value);
|
| 274 |
+
$isArray = true;
|
| 275 |
+
$setValue = array();
|
| 276 |
+
}
|
| 277 |
+
|
| 278 |
+
if ($value && $attribute->getBackendType() == 'decimal') {
|
| 279 |
+
$setValue = $this->getNumber($value);
|
| 280 |
+
}
|
| 281 |
+
|
| 282 |
+
|
| 283 |
+
if ($attribute->usesSource()) {
|
| 284 |
+
$options = $attribute->getSource()->getAllOptions(false);
|
| 285 |
+
|
| 286 |
+
if ($isArray) {
|
| 287 |
+
foreach ($options as $item) {
|
| 288 |
+
if (in_array($item['label'], $value)) {
|
| 289 |
+
$setValue[] = $item['value'];
|
| 290 |
+
}
|
| 291 |
+
}
|
| 292 |
+
}
|
| 293 |
+
else {
|
| 294 |
+
$setValue = null;
|
| 295 |
+
foreach ($options as $item) {
|
| 296 |
+
if ($item['label'] == $value) {
|
| 297 |
+
$setValue = $item['value'];
|
| 298 |
+
}
|
| 299 |
+
}
|
| 300 |
+
}
|
| 301 |
+
}
|
| 302 |
+
|
| 303 |
+
$product->setData($field, $setValue);
|
| 304 |
+
}
|
| 305 |
+
|
| 306 |
+
if (!$product->getVisibility()) {
|
| 307 |
+
$product->setVisibility(Mage_Catalog_Model_Product_Visibility::VISIBILITY_NOT_VISIBLE);
|
| 308 |
+
}
|
| 309 |
+
|
| 310 |
+
$stockData = array();
|
| 311 |
+
$inventoryFields = isset($this->_inventoryFieldsProductTypes[$product->getTypeId()])
|
| 312 |
+
? $this->_inventoryFieldsProductTypes[$product->getTypeId()]
|
| 313 |
+
: array();
|
| 314 |
+
foreach ($inventoryFields as $field) {
|
| 315 |
+
if (isset($importData[$field])) {
|
| 316 |
+
if (in_array($field, $this->_toNumber)) {
|
| 317 |
+
$stockData[$field] = $this->getNumber($importData[$field]);
|
| 318 |
+
}
|
| 319 |
+
else {
|
| 320 |
+
$stockData[$field] = $importData[$field];
|
| 321 |
+
}
|
| 322 |
+
}
|
| 323 |
+
}
|
| 324 |
+
$product->setStockData($stockData);
|
| 325 |
+
|
| 326 |
+
$imageData = array();
|
| 327 |
+
foreach ($this->_imageFields as $field) {
|
| 328 |
+
if (!empty($importData[$field]) && $importData[$field] != 'no_selection') {
|
| 329 |
+
if (!isset($imageData[$importData[$field]])) {
|
| 330 |
+
$imageData[$importData[$field]] = array();
|
| 331 |
+
}
|
| 332 |
+
$imageData[$importData[$field]][] = $field;
|
| 333 |
+
}
|
| 334 |
+
}
|
| 335 |
+
|
| 336 |
+
foreach ($imageData as $file => $fields) {
|
| 337 |
+
try {
|
| 338 |
+
$product->addImageToMediaGallery(Mage::getBaseDir('media') . DS . 'import' . $file, $fields);
|
| 339 |
+
}
|
| 340 |
+
catch (Exception $e) {}
|
| 341 |
+
}
|
| 342 |
+
|
| 343 |
+
/**
|
| 344 |
+
* Allows you to import multiple images for each product.
|
| 345 |
+
* Simply add a 'gallery' column to the import file, and separate
|
| 346 |
+
* each image with a semi-colon.
|
| 347 |
+
*/
|
| 348 |
+
try {
|
| 349 |
+
$galleryData = explode(';',$importData["gallery"]);
|
| 350 |
+
foreach($galleryData as $gallery_img)
|
| 351 |
+
/**
|
| 352 |
+
* @param directory where import image resides
|
| 353 |
+
* @param leave 'null' so that it isn't imported as thumbnail, base, or small
|
| 354 |
+
* @param false = the image is copied, not moved from the import directory to it's new location
|
| 355 |
+
* @param false = not excluded from the front end gallery
|
| 356 |
+
*/
|
| 357 |
+
{
|
| 358 |
+
$product->addImageToMediaGallery(Mage::getBaseDir('media') . DS . 'import' . $gallery_img, null, false, false);
|
| 359 |
+
}
|
| 360 |
+
}
|
| 361 |
+
catch (Exception $e) {}
|
| 362 |
+
/* End Modification */
|
| 363 |
+
|
| 364 |
+
$product->setIsMassupdate(true);
|
| 365 |
+
$product->setExcludeUrlRewrite(true);
|
| 366 |
+
|
| 367 |
+
$product->save();
|
| 368 |
+
/* Add the custom options specified in the CSV import file */
|
| 369 |
+
|
| 370 |
+
if(isset($custom_options)){
|
| 371 |
+
if(count($custom_options)) {
|
| 372 |
+
foreach($custom_options as $option) {
|
| 373 |
+
try {
|
| 374 |
+
$opt = Mage::getModel('catalog/product_option');
|
| 375 |
+
$opt->setProduct($product);
|
| 376 |
+
$opt->addOption($option);
|
| 377 |
+
$opt->saveOptions();
|
| 378 |
+
}
|
| 379 |
+
catch (Exception $e) {}
|
| 380 |
+
}
|
| 381 |
+
}
|
| 382 |
+
}
|
| 383 |
+
return true;
|
| 384 |
+
}
|
| 385 |
+
|
| 386 |
+
protected $_categoryCache = array();
|
| 387 |
+
/* Add category and sub category. */
|
| 388 |
+
protected function _addCategories($categories, $leader_categories, $store, $leader_store, $unspsc, $categoryActive = 1)
|
| 389 |
+
{
|
| 390 |
+
|
| 391 |
+
if (empty($leader_categories)) {
|
| 392 |
+
$multyLang = false;
|
| 393 |
+
$shadowStore = $store;
|
| 394 |
+
} else {
|
| 395 |
+
$multyLang = true;
|
| 396 |
+
$shadowStore = $leader_store;
|
| 397 |
+
}
|
| 398 |
+
|
| 399 |
+
$rootId = $shadowStore->getRootCategoryId();
|
| 400 |
+
|
| 401 |
+
if (!$rootId) {
|
| 402 |
+
/* If stoder not create that mense admin then assign 1 to storeId */
|
| 403 |
+
$storeId = 1;
|
| 404 |
+
$rootId = Mage::app()->getStore($storeId)->getRootCategoryId();
|
| 405 |
+
}
|
| 406 |
+
|
| 407 |
+
if($categories=="")
|
| 408 |
+
return array();
|
| 409 |
+
$rootPath = '1/'.$rootId;
|
| 410 |
+
|
| 411 |
+
if (empty($this->_categoryCache[$shadowStore->getId()])) {
|
| 412 |
+
$collection = Mage::getModel('catalog/category')->getCollection()
|
| 413 |
+
->setStore($shadowStore)
|
| 414 |
+
->addAttributeToSelect('name');
|
| 415 |
+
$collection->getSelect()->where("path like '".$rootPath."/%'");
|
| 416 |
+
|
| 417 |
+
foreach ($collection as $cat) {
|
| 418 |
+
if (!empty($unspsc) && !$multylang) {
|
| 419 |
+
$category = Mage::getModel('catalog/category')->load($cat->getId());
|
| 420 |
+
$unspsc_orig = $category->getData('unspsc');
|
| 421 |
+
|
| 422 |
+
if ($unspsc_orig == $unspsc) {
|
| 423 |
+
$cat->setIsActive($categoryActive)->save();
|
| 424 |
+
return $cat->getId();
|
| 425 |
+
}
|
| 426 |
+
}
|
| 427 |
+
|
| 428 |
+
$pathArr = explode('/', $cat->getPath());
|
| 429 |
+
$namePath = '';
|
| 430 |
+
for ($i=2, $l=sizeof($pathArr); $i<$l; $i++) {
|
| 431 |
+
$name = $collection->getItemById($pathArr[$i])->getName();
|
| 432 |
+
$namePath .= (empty($namePath) ? '' : '/').trim($name);
|
| 433 |
+
}
|
| 434 |
+
$cat->setNamePath($namePath);
|
| 435 |
+
}
|
| 436 |
+
|
| 437 |
+
$cache = array();
|
| 438 |
+
foreach ($collection as $cat) {
|
| 439 |
+
$cache[strtolower($cat->getNamePath())] = $cat;
|
| 440 |
+
$cat->unsNamePath();
|
| 441 |
+
}
|
| 442 |
+
$this->_categoryCache[$shadowStore->getId()] = $cache;
|
| 443 |
+
}
|
| 444 |
+
$cache =& $this->_categoryCache[$shadowStore->getId()];
|
| 445 |
+
|
| 446 |
+
$catIds = array();
|
| 447 |
+
foreach (explode(',', $categories) as $categoryPathStr) {
|
| 448 |
+
$categoryPathStr = preg_replace('#\s*/\s*#', '/', trim($categoryPathStr));
|
| 449 |
+
if (!empty($cache[$categoryPathStr])) {
|
| 450 |
+
$catIds[] = $cache[$categoryPathStr]->getId();
|
| 451 |
+
if (!$multylang) {
|
| 452 |
+
continue;
|
| 453 |
+
}
|
| 454 |
+
}
|
| 455 |
+
$path = $rootPath;
|
| 456 |
+
$namePath = '';
|
| 457 |
+
|
| 458 |
+
if ($multyLang) {
|
| 459 |
+
$shadowPath = '';
|
| 460 |
+
}
|
| 461 |
+
|
| 462 |
+
$shadowCategory = explode('/', $leader_categories);
|
| 463 |
+
$shadowIterator = 0;
|
| 464 |
+
|
| 465 |
+
$catNamesArr = explode('/', $categoryPathStr);
|
| 466 |
+
|
| 467 |
+
$categoriesCounter = count($catNamesArr);
|
| 468 |
+
|
| 469 |
+
foreach ($catNamesArr as $catName) {
|
| 470 |
+
$namePath .= (empty($namePath) ? '' : '/').strtolower($catName);
|
| 471 |
+
|
| 472 |
+
if ($multyLang) {
|
| 473 |
+
// update existing category, set new name to NL store.
|
| 474 |
+
$shadowPath .= (empty($shadowPath) ? '' : '/').strtolower($shadowCategory[$shadowIterator]);
|
| 475 |
+
$catId = $cache[$shadowPath]->getId();
|
| 476 |
+
$cat = Mage::getModel('catalog/category');
|
| 477 |
+
$cat->setStoreId($store->getId());
|
| 478 |
+
$cat->load($catId);
|
| 479 |
+
$cat->setData('name', $catName);
|
| 480 |
+
$cat->save();
|
| 481 |
+
$cache[$shadowPath] = $cat;
|
| 482 |
+
|
| 483 |
+
} else {
|
| 484 |
+
if (empty($cache[$namePath])) {
|
| 485 |
+
$cat = Mage::getModel('catalog/category');
|
| 486 |
+
$cat = Mage::getModel('catalog/category')
|
| 487 |
+
->setStoreId($shadowStore->getId())
|
| 488 |
+
->setPath($path)
|
| 489 |
+
->setName($catName)
|
| 490 |
+
->setIsActive($categoryActive);
|
| 491 |
+
|
| 492 |
+
if ($categoriesCounter -1 == $shadowIterator) {
|
| 493 |
+
if (!empty($unspsc)) {
|
| 494 |
+
$catAttrib = $cat->getAttributes();
|
| 495 |
+
if ($catAttrib['unspsc']) {
|
| 496 |
+
$cat->setData('unspsc', $unspsc);
|
| 497 |
+
}
|
| 498 |
+
}
|
| 499 |
+
}
|
| 500 |
+
|
| 501 |
+
$cat->save();
|
| 502 |
+
$cache[$namePath] = $cat;
|
| 503 |
+
} else {
|
| 504 |
+
if ($categoriesCounter -1 == $shadowIterator) {
|
| 505 |
+
if (!empty($unspsc)) {
|
| 506 |
+
$catAttrib = $cache[$namePath]->getAttributes();
|
| 507 |
+
if ($catAttrib['unspsc']) {
|
| 508 |
+
$cache[$namePath]->setIsActive($categoryActive)
|
| 509 |
+
->setData('unspsc', $unspsc)
|
| 510 |
+
->save();
|
| 511 |
+
}
|
| 512 |
+
}
|
| 513 |
+
}
|
| 514 |
+
}
|
| 515 |
+
|
| 516 |
+
$catId = $cache[$namePath]->getId();
|
| 517 |
+
}
|
| 518 |
+
|
| 519 |
+
$path .= '/'.$catId;
|
| 520 |
+
$shadowIterator++;
|
| 521 |
+
}
|
| 522 |
+
$shadowIterator = 0;
|
| 523 |
+
|
| 524 |
+
if ($catId) {
|
| 525 |
+
$catIds[] = $catId;
|
| 526 |
+
}
|
| 527 |
+
}
|
| 528 |
+
return join(',', $catIds);
|
| 529 |
+
}
|
| 530 |
+
|
| 531 |
+
}
|
app/code/community/Capacitywebsolutions/Importproduct/Model/Observer.php
ADDED
|
@@ -0,0 +1,98 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
<?php
|
| 2 |
+
/*m@rk*/
|
| 3 |
+
class Capacitywebsolutions_Importproduct_Model_Observer
|
| 4 |
+
{
|
| 5 |
+
|
| 6 |
+
protected function _construct() {
|
| 7 |
+
$this->_init('importproduct/observer');
|
| 8 |
+
}
|
| 9 |
+
|
| 10 |
+
|
| 11 |
+
/**
|
| 12 |
+
* load
|
| 13 |
+
* @access publc
|
| 14 |
+
*/
|
| 15 |
+
public function load() {
|
| 16 |
+
|
| 17 |
+
/*
|
| 18 |
+
// test load
|
| 19 |
+
$con = mysql_connect('localhost', 'test', 'test');
|
| 20 |
+
$db = mysql_select_db('catch');
|
| 21 |
+
$query = mysql_query("INSERT INTO detect (event, time) VALUES ('load called', NOW())");
|
| 22 |
+
*/
|
| 23 |
+
|
| 24 |
+
|
| 25 |
+
$profileId = 3;
|
| 26 |
+
$logFileName= 'test.log';
|
| 27 |
+
$recordCount = 0;
|
| 28 |
+
|
| 29 |
+
Mage::log("Import Started",null,$logFileName);
|
| 30 |
+
|
| 31 |
+
$profile = Mage::getModel('dataflow/profile');
|
| 32 |
+
|
| 33 |
+
$userModel = Mage::getModel('admin/user');
|
| 34 |
+
$userModel->setUserId(0);
|
| 35 |
+
Mage::getSingleton('admin/session')->setUser($userModel);
|
| 36 |
+
|
| 37 |
+
if ($profileId) {
|
| 38 |
+
$profile->load($profileId);
|
| 39 |
+
if (!$profile->getId()) {
|
| 40 |
+
Mage::getSingleton('adminhtml/session')->addError('The profile that you are trying to save no longer exists');
|
| 41 |
+
}
|
| 42 |
+
}
|
| 43 |
+
|
| 44 |
+
$profile->run();
|
| 45 |
+
|
| 46 |
+
$batchModel = Mage::getSingleton('dataflow/batch');
|
| 47 |
+
if ($batchModel->getId()) {
|
| 48 |
+
if ($batchModel->getAdapter()) {
|
| 49 |
+
$batchId = $batchModel->getId();
|
| 50 |
+
$batchImportModel = $batchModel->getBatchImportModel();
|
| 51 |
+
$importIds = $batchImportModel->getIdCollection();
|
| 52 |
+
|
| 53 |
+
$batchModel = Mage::getModel('dataflow/batch')->load($batchId);
|
| 54 |
+
$adapter = Mage::getModel($batchModel->getAdapter());
|
| 55 |
+
foreach ($importIds as $importId) {
|
| 56 |
+
$recordCount++;
|
| 57 |
+
try{
|
| 58 |
+
$batchImportModel->load($importId);
|
| 59 |
+
if (!$batchImportModel->getId()) {
|
| 60 |
+
$errors[] = Mage::helper('dataflow')->__('Skip undefined row');
|
| 61 |
+
continue;
|
| 62 |
+
}
|
| 63 |
+
|
| 64 |
+
$importData = $batchImportModel->getBatchData();
|
| 65 |
+
|
| 66 |
+
try {
|
| 67 |
+
$adapter->saveRow($importData);
|
| 68 |
+
} catch (Exception $e) {
|
| 69 |
+
Mage::log($e->getMessage(),null,$logFileName);
|
| 70 |
+
continue;
|
| 71 |
+
}
|
| 72 |
+
|
| 73 |
+
}catch (Exeption $ex) {
|
| 74 |
+
Mage::log('Record# ' . $recordCount . ' - SKU = ' . $importData['sku']. ' - Error - ' . $ex->getMessage(),null,$logFileName);
|
| 75 |
+
}
|
| 76 |
+
|
| 77 |
+
}
|
| 78 |
+
|
| 79 |
+
foreach ($profile->getExceptions() as $e) {
|
| 80 |
+
Mage::log($e->getMessage(),null,$logFileName);
|
| 81 |
+
}
|
| 82 |
+
|
| 83 |
+
}
|
| 84 |
+
}
|
| 85 |
+
|
| 86 |
+
echo 'Import Completed';
|
| 87 |
+
Mage::log("Import Completed",null,$logFileName);
|
| 88 |
+
|
| 89 |
+
try {
|
| 90 |
+
$import = Mage::getModel('importexport/import');
|
| 91 |
+
} catch (Exeptint $e) {
|
| 92 |
+
Mage::log($e->getMessage(), null, $logFileName);
|
| 93 |
+
}
|
| 94 |
+
|
| 95 |
+
}
|
| 96 |
+
|
| 97 |
+
}
|
| 98 |
+
?>
|
app/code/community/Capacitywebsolutions/Importproduct/Model/System/Config/Categoryactivity.php
ADDED
|
@@ -0,0 +1,14 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
<?php
|
| 2 |
+
|
| 3 |
+
class Capacitywebsolutions_Importproduct_Model_System_Config_Categoryactivity
|
| 4 |
+
{
|
| 5 |
+
public function toOptionArray()
|
| 6 |
+
{
|
| 7 |
+
$paramsArray = array(
|
| 8 |
+
1 => 'Yes',
|
| 9 |
+
0 => 'No'
|
| 10 |
+
);
|
| 11 |
+
return $paramsArray;
|
| 12 |
+
}
|
| 13 |
+
}
|
| 14 |
+
?>
|
app/code/community/Capacitywebsolutions/Importproduct/Model/System/Config/Imageimport.php
ADDED
|
@@ -0,0 +1,14 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
<?php
|
| 2 |
+
|
| 3 |
+
class Capacitywebsolutions_Importproduct_Model_System_Config_Imageimport
|
| 4 |
+
{
|
| 5 |
+
public function toOptionArray()
|
| 6 |
+
{
|
| 7 |
+
$paramsArray = array(
|
| 8 |
+
'import_images_true' => 'Yes',
|
| 9 |
+
'import_images_false' => 'No'
|
| 10 |
+
);
|
| 11 |
+
return $paramsArray;
|
| 12 |
+
}
|
| 13 |
+
}
|
| 14 |
+
?>
|
app/code/community/Capacitywebsolutions/Importproduct/Model/System/Config/Lockproddetails.php
ADDED
|
@@ -0,0 +1,15 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
<?php
|
| 2 |
+
|
| 3 |
+
class Capacitywebsolutions_Importproduct_Model_System_Config_Lockproddetails
|
| 4 |
+
{
|
| 5 |
+
public function toOptionArray()
|
| 6 |
+
{
|
| 7 |
+
$paramsArray = array(
|
| 8 |
+
'import_price_stock' => 'Yes',
|
| 9 |
+
'import_info' => 'No'
|
| 10 |
+
);
|
| 11 |
+
return $paramsArray;
|
| 12 |
+
}
|
| 13 |
+
}
|
| 14 |
+
|
| 15 |
+
?>
|
app/code/community/Capacitywebsolutions/Importproduct/etc/config.xml
ADDED
|
@@ -0,0 +1,71 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
<?xml version="1.0"?>
|
| 2 |
+
<config>
|
| 3 |
+
<modules>
|
| 4 |
+
<Capacitywebsolutions_Importproduct>
|
| 5 |
+
<version>1.0</version>
|
| 6 |
+
</Capacitywebsolutions_Importproduct>
|
| 7 |
+
</modules>
|
| 8 |
+
<global>
|
| 9 |
+
<models>
|
| 10 |
+
<catalog>
|
| 11 |
+
<rewrite>
|
| 12 |
+
<!-- Override Mage_Catalog_Model_Convert_Adapter_Product -->
|
| 13 |
+
<convert_adapter_product>Capacitywebsolutions_Importproduct_Model_Convert_Adapter_Product</convert_adapter_product>
|
| 14 |
+
</rewrite>
|
| 15 |
+
</catalog>
|
| 16 |
+
<importproduct>
|
| 17 |
+
<class>Capacitywebsolutions_Importproduct_Model</class>
|
| 18 |
+
</importproduct>
|
| 19 |
+
</models>
|
| 20 |
+
<resources>
|
| 21 |
+
<importproduct_setup>
|
| 22 |
+
<setup>
|
| 23 |
+
<module>Capacitywebsolutions_Importproduct</module>
|
| 24 |
+
<class>Mage_Catalog_Model_Resource_Eav_Mysql4_Setup</class>
|
| 25 |
+
</setup>
|
| 26 |
+
<connection>
|
| 27 |
+
<use>core_setup</use>
|
| 28 |
+
</connection>
|
| 29 |
+
</importproduct_setup>
|
| 30 |
+
<importproduct_setup_write>
|
| 31 |
+
<connection>
|
| 32 |
+
<use>core_write</use>
|
| 33 |
+
</connection>
|
| 34 |
+
</importproduct_setup_write>
|
| 35 |
+
<importproduct_setup_read>
|
| 36 |
+
<connection>
|
| 37 |
+
<use>core_read</use>
|
| 38 |
+
</connection>
|
| 39 |
+
</importproduct_setup_read>
|
| 40 |
+
</resources>
|
| 41 |
+
</global>
|
| 42 |
+
<adminhtml>
|
| 43 |
+
<acl>
|
| 44 |
+
<resources>
|
| 45 |
+
<admin>
|
| 46 |
+
<children>
|
| 47 |
+
<system>
|
| 48 |
+
<children>
|
| 49 |
+
<config>
|
| 50 |
+
<children>
|
| 51 |
+
<importprod_root>
|
| 52 |
+
<title>IceImport module</title>
|
| 53 |
+
</importprod_root>
|
| 54 |
+
</children>
|
| 55 |
+
</config>
|
| 56 |
+
</children>
|
| 57 |
+
</system>
|
| 58 |
+
</children>
|
| 59 |
+
</admin>
|
| 60 |
+
</resources>
|
| 61 |
+
</acl>
|
| 62 |
+
</adminhtml>
|
| 63 |
+
<crontab>
|
| 64 |
+
<jobs>
|
| 65 |
+
<importproduct>
|
| 66 |
+
<schedule><cron_expr>* * * * *</cron_expr></schedule>
|
| 67 |
+
<run><model>importproduct/observer::load</model></run>
|
| 68 |
+
</importproduct>
|
| 69 |
+
</jobs>
|
| 70 |
+
</crontab>
|
| 71 |
+
</config>
|
app/code/community/Capacitywebsolutions/Importproduct/etc/system.xml
ADDED
|
@@ -0,0 +1,64 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
<?xml version="1.0" encoding="UTF-8"?>
|
| 2 |
+
<config>
|
| 3 |
+
<sections>
|
| 4 |
+
<importprod_root translate="label" module="catalog">
|
| 5 |
+
<class>separator-top</class>
|
| 6 |
+
<label>IceImport</label>
|
| 7 |
+
<tab>catalog</tab>
|
| 8 |
+
<frontend_type>text</frontend_type>
|
| 9 |
+
<sort_order>300</sort_order>
|
| 10 |
+
<show_in_default>1</show_in_default>
|
| 11 |
+
<show_in_website>1</show_in_website>
|
| 12 |
+
<show_in_store>1</show_in_store>
|
| 13 |
+
<groups>
|
| 14 |
+
<importprod translate="label">
|
| 15 |
+
<label>IceImport Settings</label>
|
| 16 |
+
<frontend_type>text</frontend_type>
|
| 17 |
+
<sort_order>50</sort_order>
|
| 18 |
+
<show_in_default>1</show_in_default>
|
| 19 |
+
<show_in_website>1</show_in_website>
|
| 20 |
+
<show_in_store>1</show_in_store>
|
| 21 |
+
<fields>
|
| 22 |
+
<category_active translate="label">
|
| 23 |
+
<label>Set to active imported categories</label>
|
| 24 |
+
<frontend_type>select</frontend_type>
|
| 25 |
+
<source_model>importproduct/system_config_categoryactivity</source_model>
|
| 26 |
+
<sort_order>10</sort_order>
|
| 27 |
+
<show_in_default>1</show_in_default>
|
| 28 |
+
<show_in_website>1</show_in_website>
|
| 29 |
+
<show_in_store>1</show_in_store>
|
| 30 |
+
</category_active>
|
| 31 |
+
<import_only_prices_stock translate="label">
|
| 32 |
+
<label>Import only prices and stock</label>
|
| 33 |
+
<frontend_type>select</frontend_type>
|
| 34 |
+
<source_model>importproduct/system_config_lockproddetails</source_model>
|
| 35 |
+
<sort_order>20</sort_order>
|
| 36 |
+
<show_in_default>1</show_in_default>
|
| 37 |
+
<show_in_website>1</show_in_website>
|
| 38 |
+
<show_in_store>1</show_in_store>
|
| 39 |
+
</import_only_prices_stock>
|
| 40 |
+
<!--
|
| 41 |
+
<import_images>
|
| 42 |
+
<label>Import product images</label>
|
| 43 |
+
<frontend_type>select</frontend_type>
|
| 44 |
+
<source_model>importproduct/system_config_imageimport</source_model>
|
| 45 |
+
<sort_order>30</sort_order>
|
| 46 |
+
<show_in_default>1</show_in_default>
|
| 47 |
+
<show_in_website>1</show_in_website>
|
| 48 |
+
<show_in_store>1</show_in_store>
|
| 49 |
+
</import_images>
|
| 50 |
+
<import_schedule>
|
| 51 |
+
<label>Import schedule</label>
|
| 52 |
+
<frontend_type>text</frontend_type>
|
| 53 |
+
<sort_order>40</sort_order>
|
| 54 |
+
<show_in_default>1</show_in_default>
|
| 55 |
+
<show_in_website>1</show_in_website>
|
| 56 |
+
<show_in_store>1</show_in_store>
|
| 57 |
+
</import_schedule>
|
| 58 |
+
-->
|
| 59 |
+
</fields>
|
| 60 |
+
</importprod>
|
| 61 |
+
</groups>
|
| 62 |
+
</importprod_root>
|
| 63 |
+
</sections>
|
| 64 |
+
</config>
|
app/code/community/Capacitywebsolutions/Importproduct/sql/importproduct_setup/mysql4-install-0.1.0.php
ADDED
|
@@ -0,0 +1,54 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
<?php
|
| 2 |
+
|
| 3 |
+
$installer = $this;
|
| 4 |
+
$installer->startSetup();
|
| 5 |
+
|
| 6 |
+
$entityTypeId = $installer->getEntityTypeId('catalog_category');
|
| 7 |
+
$attributeSetId = $installer->getDefaultAttributeSetId($entityTypeId);
|
| 8 |
+
$attributeGroupId = $installer->getDefaultAttributeGroupId($entityTypeId, $attributeSetId);
|
| 9 |
+
|
| 10 |
+
$installer->addAttribute('catalog_category', 'unspsc', array(
|
| 11 |
+
'type' => 'varchar',
|
| 12 |
+
'label' => 'unspsc',
|
| 13 |
+
'input' => 'text',
|
| 14 |
+
'global' => Mage_Catalog_Model_Resource_Eav_Attribute::SCOPE_STORE,
|
| 15 |
+
'visible' => true,
|
| 16 |
+
'required' => false,
|
| 17 |
+
'user_defined' => false,
|
| 18 |
+
'default' => 0
|
| 19 |
+
));
|
| 20 |
+
|
| 21 |
+
$installer->addAttributeToGroup(
|
| 22 |
+
$entityTypeId,
|
| 23 |
+
$attributeSetId,
|
| 24 |
+
$attributeGroupId,
|
| 25 |
+
'unspsc',
|
| 26 |
+
'11'
|
| 27 |
+
);
|
| 28 |
+
|
| 29 |
+
$attributeId = $installer->getAttributeId($entityTypeId, 'unspsc');
|
| 30 |
+
|
| 31 |
+
$installer->run("
|
| 32 |
+
INSERT INTO `{$installer->getTable('catalog_category_entity_varchar')}`
|
| 33 |
+
(`entity_type_id`, `attribute_id`, `entity_id`, `value`)
|
| 34 |
+
SELECT '{$entityTypeId}', '{$attributeId}', `entity_id`, '1'
|
| 35 |
+
FROM `{$installer->getTable('catalog_category_entity')}`;
|
| 36 |
+
");
|
| 37 |
+
|
| 38 |
+
/*
|
| 39 |
+
// set attribute to root category
|
| 40 |
+
Mage::getModel('catalog/category')
|
| 41 |
+
->load(1)
|
| 42 |
+
->setImportedCatId(0)
|
| 43 |
+
->setInitialSetupFlag(true)
|
| 44 |
+
->save();
|
| 45 |
+
|
| 46 |
+
Mage::getModel('catalog/category')
|
| 47 |
+
->load(2)
|
| 48 |
+
->setImportedCatId(0)
|
| 49 |
+
->setInitialSetupFlag(true)
|
| 50 |
+
->save();
|
| 51 |
+
*/
|
| 52 |
+
$installer->endSetup();
|
| 53 |
+
|
| 54 |
+
?>
|
app/etc/modules/Capacitywebsolutions_Importproduct.xml
ADDED
|
@@ -0,0 +1,9 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
<?xml version="1.0"?>
|
| 2 |
+
<config>
|
| 3 |
+
<modules>
|
| 4 |
+
<Capacitywebsolutions_Importproduct>
|
| 5 |
+
<active>true</active>
|
| 6 |
+
<codePool>community</codePool>
|
| 7 |
+
</Capacitywebsolutions_Importproduct>
|
| 8 |
+
</modules>
|
| 9 |
+
</config>
|
package.xml
ADDED
|
@@ -0,0 +1,18 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
<?xml version="1.0"?>
|
| 2 |
+
<package>
|
| 3 |
+
<name>ice_import</name>
|
| 4 |
+
<version>1.0.0</version>
|
| 5 |
+
<stability>stable</stability>
|
| 6 |
+
<license uri="http://opensource.org/licenses/osl-3.0.php">OSL v.3</license>
|
| 7 |
+
<channel>community</channel>
|
| 8 |
+
<extends/>
|
| 9 |
+
<summary>Import categories & products</summary>
|
| 10 |
+
<description>This extension can use to import products with categories, multiple images and custom options from CSV file.</description>
|
| 11 |
+
<notes>Added multiple store views, synchronization with IceCat etc.</notes>
|
| 12 |
+
<authors><author><name>Iceshop</name><user>Iceshop</user><email>support@iceshop.nl</email></author></authors>
|
| 13 |
+
<date>2012-06-18</date>
|
| 14 |
+
<time>11:07:18</time>
|
| 15 |
+
<contents><target name="magecommunity"><dir name="Capacitywebsolutions"><dir name="Importproduct"><dir name="etc"><file name="config.xml" hash="287d723649aea3da75aa67f5b70fa632"/><file name="system.xml" hash="7a810bc95f4565c6bb09b8634e27109a"/></dir><dir name="Model"><dir name="Convert"><dir name="Adapter"><file name="Product.php" hash="95b154e0f00d639fdca6f5ec682dde3d"/></dir></dir><dir name="System"><dir name="Config"><file name="Categoryactivity.php" hash="b6765ac67a3dfda7c7fdafb09b0a9374"/><file name="Imageimport.php" hash="6d46e8ff52f3006a4461c0f0d479a190"/><file name="Lockproddetails.php" hash="32a823c0c914348585702536732fed3e"/></dir></dir><file name="Observer.php" hash="8ea437e36f8755a8578f31a8d0141f5a"/></dir><dir name="sql"><dir name="importproduct_setup"><file name="mysql4-install-0.1.0.php" hash="d20ba6989d47a7e3bb896f4e82172303"/></dir></dir></dir></dir></target><target name="mageetc"><dir name="modules"><file name="Capacitywebsolutions_Importproduct.xml" hash="02cb79dd6ed129ce3aa5305e1bfb4bbf"/></dir></target></contents>
|
| 16 |
+
<compatible/>
|
| 17 |
+
<dependencies><required><php><min>5.2.0</min><max>6.0.0</max></php></required></dependencies>
|
| 18 |
+
</package>
|
