Version Notes
- Added mapping by EAN/UPC codes
- Added support of Multilanguage stores
- Added new setting Description Priority
- Added new setting Short Description Priority
- Added new setting Product Name Priority
- Added new setting Product Images Priority
- Added loading products description from DB when icecat info is missing and config setting product descr source is set to icecat
- Added saving icecat images to server and display from there
- Added saving product title to db from file and display it on list page
- Added cron process lock - only one icecat cron process can be running at a time
- LOAD DATA replaced with insert queries
- Fixed problems with Icecat names
- Fixed problems with images on product listing/shopping cart.
- Fixed problems with correct displaying attributes on product detail page
- Fixed problems with description on product detail page
- Fixed product info in breadcrumbs
- Fixed problems with loading icecat data for each product on product listing page
- Fixed problems with product images and gallery
Release Info
| Developer | IceShop |
| Extension | IcecatLive |
| Version | 1.4.0 |
| Comparing to | |
| See all releases | |
Code changes from version 1.3.0 to 1.4.0
- app/code/local/Bintime/Icecatimport/Block/Media.php +14 -15
- app/code/local/Bintime/Icecatimport/Helper/Catalog/Image.php +11 -2
- app/code/local/Bintime/Icecatimport/Helper/Output.php +42 -19
- app/code/local/Bintime/Icecatimport/Model/Catalog/Product.php +21 -8
- app/code/local/Bintime/Icecatimport/Model/Import.php +69 -14
- app/code/local/Bintime/Icecatimport/Model/Observer.php +119 -77
- app/code/local/Bintime/Icecatimport/Model/Output.php +160 -0
- app/code/local/Bintime/Icecatimport/Model/System/Config/Imagepriority.php +13 -0
- app/code/local/Bintime/Icecatimport/Model/System/Config/Namepriority.php +13 -0
- app/code/local/Bintime/Icecatimport/Model/System/Config/Productpriority.php +13 -0
- app/code/local/Bintime/Icecatimport/Model/System/Config/Shortdescrpriority.php +13 -0
- app/code/local/Bintime/Icecatimport/etc/config.xml +3 -4
- app/code/local/Bintime/Icecatimport/etc/system.xml +27 -0
- package.xml +22 -17
|
@@ -5,27 +5,24 @@ class Bintime_Icecatimport_Block_Media extends Mage_Catalog_Block_Product_View_M
|
|
| 5 |
protected $_isGalleryDisabled;
|
| 6 |
|
| 7 |
public function getGalleryImages()
|
| 8 |
-
{
|
| 9 |
if ($this->_isGalleryDisabled) {
|
| 10 |
return array();
|
| 11 |
}
|
| 12 |
-
|
| 13 |
-
|
| 14 |
-
|
| 15 |
$collection = $this->getProduct()->getMediaGalleryImages();
|
| 16 |
$items = $collection->getItems();
|
| 17 |
-
|
| 18 |
-
|
| 19 |
-
|
| 20 |
-
|
|
|
|
| 21 |
} else if (count($items) == 1) {
|
| 22 |
-
|
| 23 |
-
|
| 24 |
-
|
| 25 |
-
} else{
|
| 26 |
-
|
| 27 |
return $collection;
|
| 28 |
-
|
| 29 |
}
|
| 30 |
}
|
| 31 |
|
|
@@ -37,7 +34,9 @@ class Bintime_Icecatimport_Block_Media extends Mage_Catalog_Block_Product_View_M
|
|
| 37 |
$icePhotos = $iceCatModel->getGalleryPhotos();
|
| 38 |
$collection = $this->getProduct()->getMediaGalleryImages();
|
| 39 |
$items = $collection->getItems();
|
| 40 |
-
|
|
|
|
|
|
|
| 41 |
$product_id = $this->getProduct()->getEntityId();
|
| 42 |
$image_saved = $iceCatModel->saveImg($product_id,$image['file'],'thumb');
|
| 43 |
return Mage::getBaseUrl(Mage_Core_Model_Store::URL_TYPE_MEDIA).'catalog/product/'.$image_saved;
|
| 5 |
protected $_isGalleryDisabled;
|
| 6 |
|
| 7 |
public function getGalleryImages()
|
| 8 |
+
{
|
| 9 |
if ($this->_isGalleryDisabled) {
|
| 10 |
return array();
|
| 11 |
}
|
| 12 |
+
$iceCatModel = Mage::getSingleton('icecatimport/import');
|
| 13 |
+
$icePhotos = $iceCatModel->getGalleryPhotos();
|
| 14 |
+
|
| 15 |
$collection = $this->getProduct()->getMediaGalleryImages();
|
| 16 |
$items = $collection->getItems();
|
| 17 |
+
$Imagepriority = Mage::getStoreConfig('icecat_root/icecat/image_priority');
|
| 18 |
+
if (!empty($icePhotos) && $Imagepriority != 'Db'){
|
| 19 |
+
return Mage::getSingleton('Bintime_Icecatimport_Model_Imagescollection',array(
|
| 20 |
+
'product' => $this->getProduct()
|
| 21 |
+
));
|
| 22 |
} else if (count($items) == 1) {
|
| 23 |
+
return array();
|
| 24 |
+
} else{
|
|
|
|
|
|
|
|
|
|
| 25 |
return $collection;
|
|
|
|
| 26 |
}
|
| 27 |
}
|
| 28 |
|
| 34 |
$icePhotos = $iceCatModel->getGalleryPhotos();
|
| 35 |
$collection = $this->getProduct()->getMediaGalleryImages();
|
| 36 |
$items = $collection->getItems();
|
| 37 |
+
$Imagepriority = Mage::getStoreConfig('icecat_root/icecat/image_priority');
|
| 38 |
+
|
| 39 |
+
if (!empty($icePhotos) && $Imagepriority != 'Db') {
|
| 40 |
$product_id = $this->getProduct()->getEntityId();
|
| 41 |
$image_saved = $iceCatModel->saveImg($product_id,$image['file'],'thumb');
|
| 42 |
return Mage::getBaseUrl(Mage_Core_Model_Store::URL_TYPE_MEDIA).'catalog/product/'.$image_saved;
|
|
@@ -14,7 +14,16 @@ class Bintime_Icecatimport_Helper_Catalog_Image extends Mage_Catalog_Helper_Imag
|
|
| 14 |
* @param $imageFile string
|
| 15 |
*/
|
| 16 |
public function init(Mage_Catalog_Model_Product $product, $attributeName, $imageFile=null)
|
| 17 |
-
{
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 18 |
if ($attributeName == 'image' && $imageFile == null ) {
|
| 19 |
$imageFile = mage::getsingleton('icecatimport/import')->getLowPicUrl();
|
| 20 |
} else if ($attributeName == 'thumbnail' && $imageFile == null ) {
|
|
@@ -26,7 +35,7 @@ class Bintime_Icecatimport_Helper_Catalog_Image extends Mage_Catalog_Helper_Imag
|
|
| 26 |
$imageFile = $iceImport->getImg($product->getId());
|
| 27 |
}
|
| 28 |
} else if (!empty($imageFile)) {
|
| 29 |
-
$iceCatModel = Mage::getSingleton('icecatimport/import');
|
| 30 |
if (!strpos($imageFile,'ttp')) {
|
| 31 |
$imageFile = $iceCatModel->saveImg($product->getEntityId(),Mage::getBaseUrl(Mage_Core_Model_Store::URL_TYPE_MEDIA).'catalog/product/'.$imageFile,$attributeName);
|
| 32 |
} else {
|
| 14 |
* @param $imageFile string
|
| 15 |
*/
|
| 16 |
public function init(Mage_Catalog_Model_Product $product, $attributeName, $imageFile=null)
|
| 17 |
+
{
|
| 18 |
+
$current_page = Mage::app()->getFrontController()->getRequest()->getControllerName();
|
| 19 |
+
$url = Mage::helper('core/url')->getCurrentUrl();
|
| 20 |
+
$is_gallery = (int) strpos($url,'catalog/product/gallery');
|
| 21 |
+
$Imagepriority = Mage::getStoreConfig('icecat_root/icecat/image_priority');
|
| 22 |
+
if ($Imagepriority == 'Db' || (($attributeName == 'thumbnail' && !empty($imageFile)
|
| 23 |
+
&& $current_page == 'product' ) || ($is_gallery > 0)) ) {
|
| 24 |
+
return parent::init($product, $attributeName, $imageFile);
|
| 25 |
+
}
|
| 26 |
+
|
| 27 |
if ($attributeName == 'image' && $imageFile == null ) {
|
| 28 |
$imageFile = mage::getsingleton('icecatimport/import')->getLowPicUrl();
|
| 29 |
} else if ($attributeName == 'thumbnail' && $imageFile == null ) {
|
| 35 |
$imageFile = $iceImport->getImg($product->getId());
|
| 36 |
}
|
| 37 |
} else if (!empty($imageFile)) {
|
| 38 |
+
$iceCatModel = Mage::getSingleton('icecatimport/import');
|
| 39 |
if (!strpos($imageFile,'ttp')) {
|
| 40 |
$imageFile = $iceCatModel->saveImg($product->getEntityId(),Mage::getBaseUrl(Mage_Core_Model_Store::URL_TYPE_MEDIA).'catalog/product/'.$imageFile,$attributeName);
|
| 41 |
} else {
|
|
@@ -29,47 +29,65 @@ class Bintime_Icecatimport_Helper_Output extends Mage_Catalog_Helper_Output
|
|
| 29 |
// return parent::productAttribute($product, $attributeHtml, $attributeName);
|
| 30 |
}
|
| 31 |
|
| 32 |
-
|
| 33 |
-
|
| 34 |
-
|
| 35 |
|
| 36 |
$productDescriptionPriority = Mage::getStoreConfig('icecat_root/icecat/descript_priority');
|
| 37 |
-
$
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 38 |
$current_page = Mage::app()->getFrontController()->getRequest()->getControllerName();
|
| 39 |
-
if ($productDescriptionPriority == 'Db' &&
|
| 40 |
-
( $attributeName == 'description' || $attributeName == 'short_description')) {
|
| 41 |
$dbDescriptionPriority = true;
|
| 42 |
-
}
|
| 43 |
-
|
|
|
|
|
|
|
|
|
|
| 44 |
if ($current_page == 'product') {
|
| 45 |
$bin_prod = new Bintime_Icecatimport_Model_Catalog_Product();
|
| 46 |
if ($attributeName == 'description' || $attributeName == 'short_description') {
|
| 47 |
-
|
| 48 |
}
|
| 49 |
}
|
| 50 |
$prod_source = Bintime_Icecatimport_Model_Catalog_Product::$_product_source;
|
| 51 |
-
|
| 52 |
if( $prod_source == 'DB' && empty($descr) ) {
|
| 53 |
$dbDescriptionPriority = true;
|
|
|
|
| 54 |
}
|
| 55 |
|
| 56 |
-
if ($
|
| 57 |
-
&& $prod_source != 'DB' && $attributeName != 'name')
|
| 58 |
-
$
|
| 59 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 60 |
}
|
|
|
|
| 61 |
$this->iceCatModel = Mage::getSingleton('icecatimport/import');
|
|
|
|
| 62 |
if ($this->isFirstTime){
|
| 63 |
$helper = Mage::helper('icecatimport/getdata');
|
| 64 |
$helper->getProductDescription($product);
|
| 65 |
|
| 66 |
-
if ($helper->hasError() &&
|
| 67 |
$this->error = true;
|
| 68 |
}
|
| 69 |
$this->isFirstTime = false;
|
| 70 |
}
|
| 71 |
-
|
| 72 |
if ($this->error){
|
|
|
|
| 73 |
if ($attributeName != 'description' && $attributeName != 'short_description') {
|
| 74 |
return parent::productAttribute($product, $attributeHtml, $attributeName);
|
| 75 |
} else {
|
|
@@ -77,8 +95,10 @@ class Bintime_Icecatimport_Helper_Output extends Mage_Catalog_Helper_Output
|
|
| 77 |
}
|
| 78 |
|
| 79 |
}
|
|
|
|
| 80 |
$id = $product->getData('entity_id');
|
| 81 |
-
|
|
|
|
| 82 |
//if we on product page then mage::registry('product') exist
|
| 83 |
if ($product->getId() == $this->iceCatModel->entityId && $name = $this->iceCatModel->getProductName()) {
|
| 84 |
return $name;
|
|
@@ -95,7 +115,8 @@ class Bintime_Icecatimport_Helper_Output extends Mage_Catalog_Helper_Output
|
|
| 95 |
return $product->getName();
|
| 96 |
}
|
| 97 |
|
| 98 |
-
if ($attributeName == 'short_description') {
|
|
|
|
| 99 |
$icecat_descr = $this->iceCatModel->getShortProductDescription();
|
| 100 |
if (!empty($descr)) {
|
| 101 |
return $descr;
|
|
@@ -106,7 +127,9 @@ class Bintime_Icecatimport_Helper_Output extends Mage_Catalog_Helper_Output
|
|
| 106 |
return parent::productAttribute($product, $attributeHtml, $attributeName);
|
| 107 |
}
|
| 108 |
}
|
| 109 |
-
|
|
|
|
|
|
|
| 110 |
$icecat_full_descr = $this->iceCatModel->getFullProductDescription();
|
| 111 |
if (!empty($icecat_full_descr)) {
|
| 112 |
return str_replace("\\n", "<br>",$icecat_full_descr);
|
| 29 |
// return parent::productAttribute($product, $attributeHtml, $attributeName);
|
| 30 |
}
|
| 31 |
|
| 32 |
+
if ($attributeName == 'image') {
|
| 33 |
+
return parent::productAttribute($product, $attributeHtml, $attributeName);
|
| 34 |
+
}
|
| 35 |
|
| 36 |
$productDescriptionPriority = Mage::getStoreConfig('icecat_root/icecat/descript_priority');
|
| 37 |
+
$productShortDescrPriority = Mage::getStoreConfig('icecat_root/icecat/shortdescr_priority');
|
| 38 |
+
$productNamePriority = Mage::getStoreConfig('icecat_root/icecat/name_priority');
|
| 39 |
+
|
| 40 |
+
|
| 41 |
+
|
| 42 |
+
$dbDescriptionPriority = false;
|
| 43 |
+
$dbShortDescriptionPriority = false;
|
| 44 |
$current_page = Mage::app()->getFrontController()->getRequest()->getControllerName();
|
| 45 |
+
if ($productDescriptionPriority == 'Db' && $attributeName == 'description') {
|
|
|
|
| 46 |
$dbDescriptionPriority = true;
|
| 47 |
+
}
|
| 48 |
+
if ($productShortDescrPriority == 'Db' && $attributeName == 'short_description') {
|
| 49 |
+
$dbShortDescriptionPriority = true;
|
| 50 |
+
}
|
| 51 |
+
|
| 52 |
if ($current_page == 'product') {
|
| 53 |
$bin_prod = new Bintime_Icecatimport_Model_Catalog_Product();
|
| 54 |
if ($attributeName == 'description' || $attributeName == 'short_description') {
|
| 55 |
+
$descr = $bin_prod->checkIcecatProdDescription($productId,$attributeName);
|
| 56 |
}
|
| 57 |
}
|
| 58 |
$prod_source = Bintime_Icecatimport_Model_Catalog_Product::$_product_source;
|
| 59 |
+
|
| 60 |
if( $prod_source == 'DB' && empty($descr) ) {
|
| 61 |
$dbDescriptionPriority = true;
|
| 62 |
+
$dbShortDescriptionPriority = true;
|
| 63 |
}
|
| 64 |
|
| 65 |
+
if ($dbShortDescriptionPriority || ($current_page != 'product'
|
| 66 |
+
&& $prod_source != 'DB' ) && $attributeName != 'name') {
|
| 67 |
+
if ($attributeName == 'short_description') {
|
| 68 |
+
$attributeHtml = $product->getData('short_description');
|
| 69 |
+
}
|
| 70 |
+
|
| 71 |
+
if ($attributeName == 'description' && $attributeHtml == 1) {
|
| 72 |
+
$attributeHtml = $product->getData('description');
|
| 73 |
+
}
|
| 74 |
+
return parent::productAttribute($product, $attributeHtml, $attributeName);
|
| 75 |
}
|
| 76 |
+
|
| 77 |
$this->iceCatModel = Mage::getSingleton('icecatimport/import');
|
| 78 |
+
|
| 79 |
if ($this->isFirstTime){
|
| 80 |
$helper = Mage::helper('icecatimport/getdata');
|
| 81 |
$helper->getProductDescription($product);
|
| 82 |
|
| 83 |
+
if ($helper->hasError() && $attributeName != 'name') {
|
| 84 |
$this->error = true;
|
| 85 |
}
|
| 86 |
$this->isFirstTime = false;
|
| 87 |
}
|
| 88 |
+
|
| 89 |
if ($this->error){
|
| 90 |
+
|
| 91 |
if ($attributeName != 'description' && $attributeName != 'short_description') {
|
| 92 |
return parent::productAttribute($product, $attributeHtml, $attributeName);
|
| 93 |
} else {
|
| 95 |
}
|
| 96 |
|
| 97 |
}
|
| 98 |
+
|
| 99 |
$id = $product->getData('entity_id');
|
| 100 |
+
|
| 101 |
+
if ($attributeName == 'name' && $productNamePriority != 'Db'){
|
| 102 |
//if we on product page then mage::registry('product') exist
|
| 103 |
if ($product->getId() == $this->iceCatModel->entityId && $name = $this->iceCatModel->getProductName()) {
|
| 104 |
return $name;
|
| 115 |
return $product->getName();
|
| 116 |
}
|
| 117 |
|
| 118 |
+
if ($attributeName == 'short_description' && !$dbShortDescriptionPriority ) {
|
| 119 |
+
|
| 120 |
$icecat_descr = $this->iceCatModel->getShortProductDescription();
|
| 121 |
if (!empty($descr)) {
|
| 122 |
return $descr;
|
| 127 |
return parent::productAttribute($product, $attributeHtml, $attributeName);
|
| 128 |
}
|
| 129 |
}
|
| 130 |
+
|
| 131 |
+
if ($attributeName == 'description' && !$dbDescriptionPriority) {
|
| 132 |
+
|
| 133 |
$icecat_full_descr = $this->iceCatModel->getFullProductDescription();
|
| 134 |
if (!empty($icecat_full_descr)) {
|
| 135 |
return str_replace("\\n", "<br>",$icecat_full_descr);
|
|
@@ -7,11 +7,19 @@
|
|
| 7 |
class Bintime_Icecatimport_Model_Catalog_Product extends Mage_Catalog_Model_Product
|
| 8 |
{
|
| 9 |
|
| 10 |
-
public function getName(){
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 11 |
try {
|
|
|
|
| 12 |
$connection = Mage::getSingleton('core/resource')->getConnection('core_read');
|
| 13 |
$manufacturerId = $this->getData(Mage::getStoreConfig('icecat_root/icecat/manufacturer'));
|
| 14 |
$mpn = $this->getData(Mage::getStoreConfig('icecat_root/icecat/sku_field'));
|
|
|
|
| 15 |
$attributeInfo = Mage::getResourceModel('eav/entity_attribute_collection')
|
| 16 |
->setCodeFilter(Mage::getStoreConfig('icecat_root/icecat/manufacturer'))
|
| 17 |
->setEntityTypeFilter($this->getResource()->getTypeId())
|
|
@@ -31,11 +39,12 @@ class Bintime_Icecatimport_Model_Catalog_Product extends Mage_Catalog_Model_Prod
|
|
| 31 |
->from(array('connector' => $tableName), new Zend_Db_Expr('connector.prod_title'))
|
| 32 |
->where('connector.prod_id = ? ', $mpn);
|
| 33 |
$icecatName = $connection->fetchOne($selectCondition);
|
|
|
|
| 34 |
} catch (Exception $e) {
|
| 35 |
Mage::log('Icecat getName error'.$e);
|
| 36 |
}
|
| 37 |
|
| 38 |
-
$product_name = $icecatName ? str_replace("|"," ",$icecatName) : $this->getData('name');
|
| 39 |
return $product_name;
|
| 40 |
}
|
| 41 |
|
|
@@ -64,7 +73,7 @@ class Bintime_Icecatimport_Model_Catalog_Product extends Mage_Catalog_Model_Prod
|
|
| 64 |
}
|
| 65 |
|
| 66 |
public function getDescription() {
|
| 67 |
-
|
| 68 |
if( !isset(self::$_product_source) ) {
|
| 69 |
$this->checkIcecatProdDescription();
|
| 70 |
}
|
|
@@ -106,8 +115,9 @@ class Bintime_Icecatimport_Model_Catalog_Product extends Mage_Catalog_Model_Prod
|
|
| 106 |
$descr[1] = false;
|
| 107 |
|
| 108 |
$descr[0] = $iceImport->getProductDescription($mpn, $manufacturer, $locale, $userLogin, $userPass, $entityId, $ean_code);
|
| 109 |
-
|
| 110 |
if (!empty($iceImport->simpleDoc)){
|
|
|
|
| 111 |
$productTag = $iceImport->simpleDoc->Product;
|
| 112 |
$descr[1] = (string) $productTag->ProductDescription['ShortDesc'];
|
| 113 |
} else if(!empty($descr[0]) && $attributeName == 'short_description') {
|
|
@@ -118,11 +128,14 @@ class Bintime_Icecatimport_Model_Catalog_Product extends Mage_Catalog_Model_Prod
|
|
| 118 |
if($descr[0] == false and $descr[1] == false) {
|
| 119 |
self::$_product_source = 'DB';
|
| 120 |
} else if ($attributeName == 'short_description') {
|
| 121 |
-
|
| 122 |
-
|
| 123 |
} else if ($attributeName == 'name') {
|
| 124 |
-
|
| 125 |
-
|
|
|
|
|
|
|
|
|
|
| 126 |
}
|
| 127 |
|
| 128 |
|
| 7 |
class Bintime_Icecatimport_Model_Catalog_Product extends Mage_Catalog_Model_Product
|
| 8 |
{
|
| 9 |
|
| 10 |
+
public function getName(){
|
| 11 |
+
|
| 12 |
+
$productNamePriority = Mage::getStoreConfig('icecat_root/icecat/name_priority');
|
| 13 |
+
if ($productNamePriority=='Db') {
|
| 14 |
+
return parent::getName();
|
| 15 |
+
}
|
| 16 |
+
|
| 17 |
try {
|
| 18 |
+
self::$_product_source = '';
|
| 19 |
$connection = Mage::getSingleton('core/resource')->getConnection('core_read');
|
| 20 |
$manufacturerId = $this->getData(Mage::getStoreConfig('icecat_root/icecat/manufacturer'));
|
| 21 |
$mpn = $this->getData(Mage::getStoreConfig('icecat_root/icecat/sku_field'));
|
| 22 |
+
|
| 23 |
$attributeInfo = Mage::getResourceModel('eav/entity_attribute_collection')
|
| 24 |
->setCodeFilter(Mage::getStoreConfig('icecat_root/icecat/manufacturer'))
|
| 25 |
->setEntityTypeFilter($this->getResource()->getTypeId())
|
| 39 |
->from(array('connector' => $tableName), new Zend_Db_Expr('connector.prod_title'))
|
| 40 |
->where('connector.prod_id = ? ', $mpn);
|
| 41 |
$icecatName = $connection->fetchOne($selectCondition);
|
| 42 |
+
|
| 43 |
} catch (Exception $e) {
|
| 44 |
Mage::log('Icecat getName error'.$e);
|
| 45 |
}
|
| 46 |
|
| 47 |
+
$product_name = !empty($icecatName) ? str_replace("|"," ",$icecatName) : $this->getData('name');
|
| 48 |
return $product_name;
|
| 49 |
}
|
| 50 |
|
| 73 |
}
|
| 74 |
|
| 75 |
public function getDescription() {
|
| 76 |
+
|
| 77 |
if( !isset(self::$_product_source) ) {
|
| 78 |
$this->checkIcecatProdDescription();
|
| 79 |
}
|
| 115 |
$descr[1] = false;
|
| 116 |
|
| 117 |
$descr[0] = $iceImport->getProductDescription($mpn, $manufacturer, $locale, $userLogin, $userPass, $entityId, $ean_code);
|
| 118 |
+
|
| 119 |
if (!empty($iceImport->simpleDoc)){
|
| 120 |
+
|
| 121 |
$productTag = $iceImport->simpleDoc->Product;
|
| 122 |
$descr[1] = (string) $productTag->ProductDescription['ShortDesc'];
|
| 123 |
} else if(!empty($descr[0]) && $attributeName == 'short_description') {
|
| 128 |
if($descr[0] == false and $descr[1] == false) {
|
| 129 |
self::$_product_source = 'DB';
|
| 130 |
} else if ($attributeName == 'short_description') {
|
| 131 |
+
self::$_product_source = '';
|
| 132 |
+
return $descr[1];
|
| 133 |
} else if ($attributeName == 'name') {
|
| 134 |
+
self::$_product_source = '';
|
| 135 |
+
return $iceImport->getProductName();
|
| 136 |
+
} else {
|
| 137 |
+
self::$_product_source = '';
|
| 138 |
+
}
|
| 139 |
}
|
| 140 |
|
| 141 |
|
|
@@ -76,7 +76,7 @@ class Bintime_Icecatimport_Model_Import extends Mage_Core_Model_Abstract {
|
|
| 76 |
"vendor" => $vendorName,
|
| 77 |
"output" => 'productxml'
|
| 78 |
));
|
| 79 |
-
|
| 80 |
if ($this->parseXml($resultString)) {
|
| 81 |
if (!$this->checkIcecatResponse()) {
|
| 82 |
$successRespondByMPNVendorFlag = true;
|
|
@@ -92,7 +92,8 @@ class Bintime_Icecatimport_Model_Import extends Mage_Core_Model_Abstract {
|
|
| 92 |
'lang' => $locale,
|
| 93 |
'output' => 'productxml'
|
| 94 |
));
|
| 95 |
-
|
|
|
|
| 96 |
if (!$this->parseXml($resultString)) {
|
| 97 |
$error = true;
|
| 98 |
$this->simpleDoc = null;
|
|
@@ -134,6 +135,7 @@ class Bintime_Icecatimport_Model_Import extends Mage_Core_Model_Abstract {
|
|
| 134 |
|
| 135 |
private function _getIceCatData($userName, $userPass, $dataUrl, $productAttributes){
|
| 136 |
try{
|
|
|
|
| 137 |
$webClient = new Zend_Http_Client();
|
| 138 |
$webClient->setUri($dataUrl);
|
| 139 |
$webClient->setMethod(Zend_Http_Client::GET);
|
|
@@ -356,7 +358,9 @@ class Bintime_Icecatimport_Model_Import extends Mage_Core_Model_Abstract {
|
|
| 356 |
$this->_manualPdfUrl = (string)$productTag->ProductDescription['ManualPDFURL'];
|
| 357 |
$this->_pdfUrl = (string)$productTag->ProductDescription['PDFURL'];
|
| 358 |
$this->_multimedia = $productTag->ProductMultimediaObject->MultimediaObject;
|
| 359 |
-
|
|
|
|
|
|
|
| 360 |
if (!empty($productTag["HighPic"])) {
|
| 361 |
$this->highPicUrl = $this->saveImg($this->entityId,(string)$productTag["HighPic"]);
|
| 362 |
} else if (!empty($productTag["LowPic"])) {
|
|
@@ -364,7 +368,7 @@ class Bintime_Icecatimport_Model_Import extends Mage_Core_Model_Abstract {
|
|
| 364 |
} else {
|
| 365 |
$this->thumb = $this->saveImg($this->entityId,(string)$productTag["ThumbPic"],'thumb');
|
| 366 |
}
|
| 367 |
-
|
| 368 |
$this->productName = (string)$productTag["Title"];
|
| 369 |
$this->productId = (string)$productTag['Prod_id'];
|
| 370 |
$this->vendor = (string)$productTag->Supplier['Name'];
|
|
@@ -412,38 +416,78 @@ class Bintime_Icecatimport_Model_Import extends Mage_Core_Model_Abstract {
|
|
| 412 |
* @param string $img_type
|
| 413 |
*/
|
| 414 |
public function saveImg($productId,$img_url,$imgtype = '') {
|
| 415 |
-
|
| 416 |
-
|
| 417 |
$pathinfo = pathinfo($img_url);
|
| 418 |
$img_type= $pathinfo["extension"];
|
| 419 |
-
|
| 420 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 421 |
$img = $img_name.".".$img_type;
|
| 422 |
$baseDir = Mage::getSingleton('catalog/product_media_config')->getBaseMediaPath().'/';
|
| 423 |
$local_img = strstr($img_url,Mage::getStoreConfig('web/unsecure/base_url'));
|
| 424 |
|
| 425 |
if (!file_exists($baseDir.$img) && !$local_img) {
|
| 426 |
-
file_put_contents($test_loader,' here 424 prod - '.$productId.' img '.$baseDir.$img.' ',FILE_APPEND);
|
| 427 |
$client = new Zend_Http_Client($img_url);
|
| 428 |
$content=$client->request();
|
| 429 |
if ($content->isError()) {
|
| 430 |
-
file_put_contents($test_loader,' here 428 '.$productId.' ',FILE_APPEND);
|
| 431 |
return $img_url;
|
| 432 |
}
|
| 433 |
$file = file_put_contents($baseDir.$img,$content->getBody());
|
| 434 |
if ($file) {
|
| 435 |
$this->addProductImageQuery($productId,$img,$imgtype);
|
| 436 |
-
file_put_contents($test_loader,' here 434 '.$productId.' ',FILE_APPEND);
|
| 437 |
return $img;
|
| 438 |
} else {
|
| 439 |
-
file_put_contents($test_loader,' here 437 '.$productId.' ',FILE_APPEND);
|
| 440 |
return $img_url;
|
| 441 |
}
|
| 442 |
} else if($local_img) {
|
| 443 |
-
file_put_contents($test_loader,' here 441 '.$productId.' ',FILE_APPEND);
|
| 444 |
return $img_url;
|
| 445 |
} else {
|
| 446 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 447 |
return $img;
|
| 448 |
}
|
| 449 |
}
|
|
@@ -499,6 +543,9 @@ file_put_contents($test_loader,' here 424 prod - '.$productId.' img '.$baseDir.$
|
|
| 499 |
':entity_id' => $productId,
|
| 500 |
':img' => $img));
|
| 501 |
}
|
|
|
|
|
|
|
|
|
|
| 502 |
$db->query(" INSERT INTO `" .$tablePrefix . "catalog_product_entity_media_gallery` (attribute_id,entity_id,value)
|
| 503 |
VALUES(@gallery,:entity_id,:img )",array(
|
| 504 |
':entity_id' => $productId,
|
|
@@ -508,6 +555,14 @@ file_put_contents($test_loader,' here 424 prod - '.$productId.' img '.$baseDir.$
|
|
| 508 |
(value_id,store_id,label,position,disabled)
|
| 509 |
VALUES(LAST_INSERT_ID(),:store_id,'',1,0 )",array(
|
| 510 |
':store_id' => $DefaultStoreId));
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 511 |
}
|
| 512 |
|
| 513 |
}
|
| 76 |
"vendor" => $vendorName,
|
| 77 |
"output" => 'productxml'
|
| 78 |
));
|
| 79 |
+
|
| 80 |
if ($this->parseXml($resultString)) {
|
| 81 |
if (!$this->checkIcecatResponse()) {
|
| 82 |
$successRespondByMPNVendorFlag = true;
|
| 92 |
'lang' => $locale,
|
| 93 |
'output' => 'productxml'
|
| 94 |
));
|
| 95 |
+
|
| 96 |
+
|
| 97 |
if (!$this->parseXml($resultString)) {
|
| 98 |
$error = true;
|
| 99 |
$this->simpleDoc = null;
|
| 135 |
|
| 136 |
private function _getIceCatData($userName, $userPass, $dataUrl, $productAttributes){
|
| 137 |
try{
|
| 138 |
+
|
| 139 |
$webClient = new Zend_Http_Client();
|
| 140 |
$webClient->setUri($dataUrl);
|
| 141 |
$webClient->setMethod(Zend_Http_Client::GET);
|
| 358 |
$this->_manualPdfUrl = (string)$productTag->ProductDescription['ManualPDFURL'];
|
| 359 |
$this->_pdfUrl = (string)$productTag->ProductDescription['PDFURL'];
|
| 360 |
$this->_multimedia = $productTag->ProductMultimediaObject->MultimediaObject;
|
| 361 |
+
|
| 362 |
+
$Imagepriority = Mage::getStoreConfig('icecat_root/icecat/image_priority');
|
| 363 |
+
if ($Imagepriority != 'Db') {
|
| 364 |
if (!empty($productTag["HighPic"])) {
|
| 365 |
$this->highPicUrl = $this->saveImg($this->entityId,(string)$productTag["HighPic"]);
|
| 366 |
} else if (!empty($productTag["LowPic"])) {
|
| 368 |
} else {
|
| 369 |
$this->thumb = $this->saveImg($this->entityId,(string)$productTag["ThumbPic"],'thumb');
|
| 370 |
}
|
| 371 |
+
}
|
| 372 |
$this->productName = (string)$productTag["Title"];
|
| 373 |
$this->productId = (string)$productTag['Prod_id'];
|
| 374 |
$this->vendor = (string)$productTag->Supplier['Name'];
|
| 416 |
* @param string $img_type
|
| 417 |
*/
|
| 418 |
public function saveImg($productId,$img_url,$imgtype = '') {
|
| 419 |
+
|
|
|
|
| 420 |
$pathinfo = pathinfo($img_url);
|
| 421 |
$img_type= $pathinfo["extension"];
|
| 422 |
+
|
| 423 |
+
if (strpos($img_url,'high') > 0) {
|
| 424 |
+
$img_name = str_replace("http://images.icecat.biz/img/norm/high/","",$img_url);
|
| 425 |
+
$img_name = md5($img_name);
|
| 426 |
+
} else if (strpos($img_url,'low') > 0) {
|
| 427 |
+
$img_name = str_replace("http://images.icecat.biz/img/norm/low/","",$img_url);
|
| 428 |
+
$img_name = md5($img_name);
|
| 429 |
+
} else {
|
| 430 |
+
$img_name = md5($img_url);
|
| 431 |
+
}
|
| 432 |
+
|
| 433 |
$img = $img_name.".".$img_type;
|
| 434 |
$baseDir = Mage::getSingleton('catalog/product_media_config')->getBaseMediaPath().'/';
|
| 435 |
$local_img = strstr($img_url,Mage::getStoreConfig('web/unsecure/base_url'));
|
| 436 |
|
| 437 |
if (!file_exists($baseDir.$img) && !$local_img) {
|
|
|
|
| 438 |
$client = new Zend_Http_Client($img_url);
|
| 439 |
$content=$client->request();
|
| 440 |
if ($content->isError()) {
|
|
|
|
| 441 |
return $img_url;
|
| 442 |
}
|
| 443 |
$file = file_put_contents($baseDir.$img,$content->getBody());
|
| 444 |
if ($file) {
|
| 445 |
$this->addProductImageQuery($productId,$img,$imgtype);
|
|
|
|
| 446 |
return $img;
|
| 447 |
} else {
|
|
|
|
| 448 |
return $img_url;
|
| 449 |
}
|
| 450 |
} else if($local_img) {
|
|
|
|
| 451 |
return $img_url;
|
| 452 |
} else {
|
| 453 |
+
|
| 454 |
+
$db = Mage::getSingleton('core/resource')->getConnection('core_write');
|
| 455 |
+
$tablePrefix = (array)Mage::getConfig()->getTablePrefix();
|
| 456 |
+
if (!empty($tablePrefix[0])) {
|
| 457 |
+
$tablePrefix = $tablePrefix[0];
|
| 458 |
+
} else {
|
| 459 |
+
$tablePrefix = '';
|
| 460 |
+
}
|
| 461 |
+
$attr_query = "SELECT @product_entity_type_id := `entity_type_id` FROM `" .$tablePrefix . "eav_entity_type` WHERE
|
| 462 |
+
entity_type_code = 'catalog_product';
|
| 463 |
+
SELECT @attribute_set_id := `entity_type_id` FROM `" . $tablePrefix . "eav_entity_type` WHERE
|
| 464 |
+
entity_type_code = 'catalog_product';
|
| 465 |
+
SELECT @gallery := `attribute_id` FROM `" . $tablePrefix . "eav_attribute` WHERE
|
| 466 |
+
`attribute_code` = 'media_gallery' AND entity_type_id = @product_entity_type_id;
|
| 467 |
+
SELECT @base := `attribute_id` FROM `" . $tablePrefix . "eav_attribute` WHERE `attribute_code` = 'image' AND entity_type_id = @product_entity_type_id;
|
| 468 |
+
SELECT @small := `attribute_id` FROM `" . $tablePrefix . "eav_attribute` WHERE
|
| 469 |
+
`attribute_code` = 'small_image' AND entity_type_id = @product_entity_type_id;
|
| 470 |
+
SELECT @thumb := `attribute_id` FROM `" . $tablePrefix . "eav_attribute` WHERE
|
| 471 |
+
`attribute_code` = 'thumbnail' AND entity_type_id = @product_entity_type_id;";
|
| 472 |
+
|
| 473 |
+
$attr_set = Mage::getModel('catalog/product')->getResource()->getEntityType()->getDefaultAttributeSetId();
|
| 474 |
+
|
| 475 |
+
$db->query($attr_query, array(':attribute_set' => $attr_set));
|
| 476 |
+
|
| 477 |
+
$img_check = $db->fetchAll("SELECT COUNT(*) FROM `" .$tablePrefix . "catalog_product_entity_varchar`
|
| 478 |
+
WHERE attribute_id IN (@base ,@small,@thumb)
|
| 479 |
+
AND entity_id =:entity_id AND value =:img ",array(
|
| 480 |
+
':entity_id' => $productId,
|
| 481 |
+
':img' => $img));
|
| 482 |
+
|
| 483 |
+
$gal_check = $db->fetchAll("SELECT COUNT(*) FROM `" .$tablePrefix . "catalog_product_entity_media_gallery`
|
| 484 |
+
WHERE attribute_id = @gallery AND entity_id =:entity_id AND value =:img ",array(
|
| 485 |
+
':entity_id' => $productId,
|
| 486 |
+
':img' => $img));
|
| 487 |
+
if ((isset($img_check[0]["COUNT(*)"]) && isset($gal_check[0]["COUNT(*)"]))
|
| 488 |
+
&& ($img_check[0]["COUNT(*)"] == 0 && $gal_check[0]["COUNT(*)"] == 0)) {
|
| 489 |
+
$this->addProductImageQuery($productId,$img,$imgtype);
|
| 490 |
+
}
|
| 491 |
return $img;
|
| 492 |
}
|
| 493 |
}
|
| 543 |
':entity_id' => $productId,
|
| 544 |
':img' => $img));
|
| 545 |
}
|
| 546 |
+
|
| 547 |
+
|
| 548 |
+
|
| 549 |
$db->query(" INSERT INTO `" .$tablePrefix . "catalog_product_entity_media_gallery` (attribute_id,entity_id,value)
|
| 550 |
VALUES(@gallery,:entity_id,:img )",array(
|
| 551 |
':entity_id' => $productId,
|
| 555 |
(value_id,store_id,label,position,disabled)
|
| 556 |
VALUES(LAST_INSERT_ID(),:store_id,'',1,0 )",array(
|
| 557 |
':store_id' => $DefaultStoreId));
|
| 558 |
+
|
| 559 |
+
/*$rows = $db->fetchAll("SELECT value_id FROM `" .$tablePrefix . "catalog_product_entity_media_gallery`
|
| 560 |
+
WHERE attribute_id = @gallery AND entity_id =:entity_id ",array(
|
| 561 |
+
':entity_id' => $productId));
|
| 562 |
+
if (count($rows > 0)) {
|
| 563 |
+
echo '<pre>'; var_dump($rows); echo " ============ ";
|
| 564 |
+
}*/
|
| 565 |
+
|
| 566 |
}
|
| 567 |
|
| 568 |
}
|
|
@@ -6,10 +6,17 @@
|
|
| 6 |
*
|
| 7 |
*/
|
| 8 |
class Bintime_Icecatimport_Model_Observer
|
| 9 |
-
{
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 10 |
private $errorMessage;
|
| 11 |
private $connection;
|
| 12 |
-
|
| 13 |
private $freeExportURLs = 'http://data.icecat.biz/export/freeurls/export_urls_rich.txt.gz';
|
| 14 |
private $fullExportURLs = 'http://data.icecat.biz/export/export_urls_rich.txt.gz';
|
| 15 |
private $productinfoUrL = 'http://data.icecat.biz/prodid/prodid_d.txt.gz';
|
|
@@ -26,11 +33,20 @@ class Bintime_Icecatimport_Model_Observer
|
|
| 26 |
* root method for uploading images to DB
|
| 27 |
*/
|
| 28 |
public function load(){
|
| 29 |
-
|
| 30 |
-
|
| 31 |
$loadUrl = $this->getLoadURL();
|
| 32 |
ini_set('max_execution_time', 0);
|
| 33 |
try {
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 34 |
$this->_productFile = $this->_prepareFile(basename($loadUrl));
|
| 35 |
$this->_supplierFile = $this->_prepareFile(basename($this->_supplierMappingUrl));
|
| 36 |
echo "Data file downloading started <br>";
|
|
@@ -59,6 +75,7 @@ file_put_contents($testfile, 'here obs',FILE_APPEND);
|
|
| 59 |
$this->loadFileToDb();
|
| 60 |
|
| 61 |
echo " Product Data File Processed Succesfully<br>";
|
|
|
|
| 62 |
} catch( Exception $e) {
|
| 63 |
echo $e->getMessage();
|
| 64 |
Mage::log($e->getMessage());
|
|
@@ -152,8 +169,8 @@ file_put_contents($testfile, 'here obs',FILE_APPEND);
|
|
| 152 |
* @param string $productManufacturer
|
| 153 |
*/
|
| 154 |
public function getImageURL($productSku, $productManufacturer, $productId = ''){
|
|
|
|
| 155 |
$connection = $this->getDbConnection();
|
| 156 |
-
$testfile = Mage::getBaseDir('var') . $this->_connectorDir . 'test_img2.txt';
|
| 157 |
try {
|
| 158 |
|
| 159 |
$tableName = Mage::getSingleton('core/resource')->getTableName('icecatimport/data');
|
|
@@ -187,7 +204,7 @@ file_put_contents($testfile, 'here obs',FILE_APPEND);
|
|
| 187 |
}
|
| 188 |
|
| 189 |
if (empty($imageURL)){
|
| 190 |
-
$
|
| 191 |
return $imageURL;
|
| 192 |
}
|
| 193 |
return $imageURL;
|
|
@@ -197,6 +214,26 @@ file_put_contents($testfile, 'here obs',FILE_APPEND);
|
|
| 197 |
}
|
| 198 |
}
|
| 199 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 200 |
/**
|
| 201 |
* Singletong for DB connection
|
| 202 |
*/
|
|
@@ -205,68 +242,82 @@ file_put_contents($testfile, 'here obs',FILE_APPEND);
|
|
| 205 |
return $this->connection;
|
| 206 |
}
|
| 207 |
$this->connection = Mage::getSingleton('core/resource')->getConnection('core_read');
|
|
|
|
| 208 |
return $this->connection;
|
| 209 |
}
|
| 210 |
|
| 211 |
-
|
| 212 |
* Upload Data file to DP
|
| 213 |
*/
|
| 214 |
private function loadFileToDb(){
|
| 215 |
-
$connection = $this->
|
| 216 |
$testfile = Mage::getBaseDir('var') . $this->_connectorDir . 'newt.txt';
|
| 217 |
$tableName = Mage::getSingleton('core/resource')->getTableName('icecatimport/data');
|
| 218 |
$is_info_file = strpos($this->_productFile,'prodid_d.txt');
|
|
|
|
| 219 |
try {
|
| 220 |
-
|
| 221 |
$fileHandler = fopen($this->XMLfile, "r");
|
| 222 |
if ($fileHandler) {
|
| 223 |
if (!$is_info_file) {
|
| 224 |
-
|
| 225 |
-
|
| 226 |
-
|
| 227 |
-
|
| 228 |
-
|
| 229 |
-
|
| 230 |
-
|
| 231 |
-
|
| 232 |
-
|
| 233 |
-
|
| 234 |
-
|
| 235 |
} else {
|
| 236 |
-
|
| 237 |
-
|
| 238 |
-
|
| 239 |
-
|
| 240 |
-
|
| 241 |
-
|
| 242 |
-
|
| 243 |
-
|
| 244 |
-
|
| 245 |
-
|
| 246 |
}
|
| 247 |
if (!$is_info_file) {
|
| 248 |
-
$csvFile = Mage::getBaseDir('var') . $this->_connectorDir . 'ice_cat_temp.csv';
|
| 249 |
} else {
|
| 250 |
-
|
| 251 |
}
|
| 252 |
|
| 253 |
-
|
| 254 |
$csvFileRes = fopen($csvFile, "w+");
|
| 255 |
-
|
|
|
|
|
|
|
|
|
|
| 256 |
while (!feof($fileHandler)) {
|
| 257 |
$row = fgets($fileHandler);
|
| 258 |
$oneLine = explode("\t", $row);
|
| 259 |
|
| 260 |
if ($oneLine[0]!= 'product_id' && $oneLine[0]!= '' && !$is_info_file) {
|
|
|
|
| 261 |
try{
|
| 262 |
|
| 263 |
-
$prod_id = (!empty($oneLine[1])) ? $oneLine[1] : '';
|
| 264 |
-
$prod_img = (!empty($oneLine[6])) ? $oneLine[6] :
|
| 265 |
-
$prod_name = (!empty($oneLine[12])) ? $oneLine[12] : '';
|
| 266 |
-
$supplier_id = (!empty($oneLine[4]))
|
| 267 |
-
$line = "$prod_id\t$supplier_id\t$prod_name\t$prod_img\n";
|
| 268 |
|
| 269 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 270 |
}catch(Exception $e){
|
| 271 |
Mage::log("connector issue: {$e->getMessage()}");
|
| 272 |
}
|
|
@@ -283,51 +334,42 @@ file_put_contents($testfile, 'here obs',FILE_APPEND);
|
|
| 283 |
$prod_ean = !empty($eans[0]) ? $eans[0] : '';
|
| 284 |
}
|
| 285 |
}
|
| 286 |
-
$prod_id = (!empty($oneLine[0])) ? str_replace("\t",'',$oneLine[0]) : '';
|
| 287 |
-
$brand = (!empty($oneLine3)) ? str_replace("\t",'',$oneLine[3]. '|') : '';
|
| 288 |
-
$model = (!empty($oneLine12)) ? str_replace("\t",'',$oneLine[12].'|') : '';
|
| 289 |
-
$family = (!empty($oneLine21)) ? preg_replace("/\s+/", "",$oneLine[21].'|') : '';
|
| 290 |
-
|
| 291 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 292 |
}catch(Exception $e){
|
| 293 |
Mage::log("connector issue: {$e->getMessage()}");
|
| 294 |
}
|
| 295 |
}
|
|
|
|
| 296 |
}
|
| 297 |
-
|
| 298 |
-
|
| 299 |
-
|
| 300 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 301 |
|
| 302 |
-
$hostname = $config->host;
|
| 303 |
-
$user = $config->username;
|
| 304 |
-
$password = $config->password;
|
| 305 |
-
$dbname = $config->dbname;
|
| 306 |
-
|
| 307 |
-
// write csv file into temp table
|
| 308 |
-
if (!$is_info_file) {
|
| 309 |
-
$sql = 'LOAD DATA LOCAL INFILE "'.$csvFile.'" INTO TABLE '.$tableName.'_temp ( prod_id, supplier_id, prod_name, prod_img );';
|
| 310 |
-
file_put_contents($sql_file,$sql);
|
| 311 |
-
$res = system("mysql -u$user -p$password -h$hostname $dbname < \"$sql_file\" ");
|
| 312 |
-
file_put_contents($testfile, "mysql -u$user -p$password -h$hostname $dbname < $sql_file",FILE_APPEND);
|
| 313 |
-
//$connection->query('LOAD DATA LOCAL INFILE "'.$csvFile.'" INTO TABLE '.$tableName.'_temp ( prod_id, supplier_id, prod_name, prod_img )');
|
| 314 |
-
$connection->query("DROP TABLE IF EXISTS `".$tableName."_old`");
|
| 315 |
-
$connection->query("rename table `".$tableName."` to `".$tableName."_old`, `".$tableName."_temp` to ".$tableName);
|
| 316 |
-
$connection->commit();
|
| 317 |
-
fclose($fileHandler);
|
| 318 |
-
unlink($csvFile);
|
| 319 |
-
} else {
|
| 320 |
-
$sql = 'LOAD DATA LOCAL INFILE "'.$csvFile.'" INTO TABLE '.$tableName.'_products ( prod_id, prod_title,prod_ean );';
|
| 321 |
-
file_put_contents($sql_file,$sql);
|
| 322 |
-
$res = system("mysql -u$user -p$password -h$hostname $dbname < \"$sql_file\" ");
|
| 323 |
-
file_put_contents($testfile, "mysql -u$user -p$password -h$hostname $dbname < $sql_file", FILE_APPEND);
|
| 324 |
-
$connection->commit();
|
| 325 |
-
fclose($fileHandler);
|
| 326 |
-
unlink($csvFile);
|
| 327 |
-
}
|
| 328 |
}
|
| 329 |
} catch (Exception $e) {
|
| 330 |
-
|
| 331 |
throw new Exception("Icecat Import Terminated: {$e->getMessage()}");
|
| 332 |
}
|
| 333 |
}
|
| 6 |
*
|
| 7 |
*/
|
| 8 |
class Bintime_Icecatimport_Model_Observer
|
| 9 |
+
{
|
| 10 |
+
/**
|
| 11 |
+
* Our process ID.
|
| 12 |
+
*/
|
| 13 |
+
private $process_id = 'bintime_icecat';
|
| 14 |
+
private $indexProcess;
|
| 15 |
+
|
| 16 |
+
|
| 17 |
private $errorMessage;
|
| 18 |
private $connection;
|
| 19 |
+
private $test_connection;
|
| 20 |
private $freeExportURLs = 'http://data.icecat.biz/export/freeurls/export_urls_rich.txt.gz';
|
| 21 |
private $fullExportURLs = 'http://data.icecat.biz/export/export_urls_rich.txt.gz';
|
| 22 |
private $productinfoUrL = 'http://data.icecat.biz/prodid/prodid_d.txt.gz';
|
| 33 |
* root method for uploading images to DB
|
| 34 |
*/
|
| 35 |
public function load(){
|
| 36 |
+
|
| 37 |
+
|
| 38 |
$loadUrl = $this->getLoadURL();
|
| 39 |
ini_set('max_execution_time', 0);
|
| 40 |
try {
|
| 41 |
+
$this->indexProcess = new Mage_Index_Model_Process();
|
| 42 |
+
$this->indexProcess->setId($this->process_id);
|
| 43 |
+
|
| 44 |
+
if ($this->indexProcess->isLocked()) {
|
| 45 |
+
throw new Exception('Error! Another icecat module cron process is running!');
|
| 46 |
+
}
|
| 47 |
+
|
| 48 |
+
$this->indexProcess->lockAndBlock();
|
| 49 |
+
|
| 50 |
$this->_productFile = $this->_prepareFile(basename($loadUrl));
|
| 51 |
$this->_supplierFile = $this->_prepareFile(basename($this->_supplierMappingUrl));
|
| 52 |
echo "Data file downloading started <br>";
|
| 75 |
$this->loadFileToDb();
|
| 76 |
|
| 77 |
echo " Product Data File Processed Succesfully<br>";
|
| 78 |
+
$this->indexProcess->unlock();
|
| 79 |
} catch( Exception $e) {
|
| 80 |
echo $e->getMessage();
|
| 81 |
Mage::log($e->getMessage());
|
| 169 |
* @param string $productManufacturer
|
| 170 |
*/
|
| 171 |
public function getImageURL($productSku, $productManufacturer, $productId = ''){
|
| 172 |
+
|
| 173 |
$connection = $this->getDbConnection();
|
|
|
|
| 174 |
try {
|
| 175 |
|
| 176 |
$tableName = Mage::getSingleton('core/resource')->getTableName('icecatimport/data');
|
| 204 |
}
|
| 205 |
|
| 206 |
if (empty($imageURL)){
|
| 207 |
+
$this->errorMessage = "Given product id is not present in database";
|
| 208 |
return $imageURL;
|
| 209 |
}
|
| 210 |
return $imageURL;
|
| 214 |
}
|
| 215 |
}
|
| 216 |
|
| 217 |
+
/**
|
| 218 |
+
* Singletong for TestDB connection
|
| 219 |
+
*/
|
| 220 |
+
private function getTestDbConnection(){
|
| 221 |
+
if ($this->test_connection){
|
| 222 |
+
return $this->test_connection;
|
| 223 |
+
}
|
| 224 |
+
//$this->connection = Mage::getSingleton('core/resource')->getConnection('core_read');
|
| 225 |
+
$config = Mage::getConfig()->getResourceConnectionConfig(Mage_Core_Model_Resource::DEFAULT_WRITE_RESOURCE);
|
| 226 |
+
$hostname = $config->host;
|
| 227 |
+
$user = $config->username;
|
| 228 |
+
$password = $config->password;
|
| 229 |
+
$dbname = $config->dbname;
|
| 230 |
+
|
| 231 |
+
$this->test_connection = @mysql_connect($hostname, $user, $password, true, 128);
|
| 232 |
+
mysql_select_db($dbname,$this->test_connection);
|
| 233 |
+
|
| 234 |
+
return $this->test_connection;
|
| 235 |
+
}
|
| 236 |
+
|
| 237 |
/**
|
| 238 |
* Singletong for DB connection
|
| 239 |
*/
|
| 242 |
return $this->connection;
|
| 243 |
}
|
| 244 |
$this->connection = Mage::getSingleton('core/resource')->getConnection('core_read');
|
| 245 |
+
|
| 246 |
return $this->connection;
|
| 247 |
}
|
| 248 |
|
| 249 |
+
/**
|
| 250 |
* Upload Data file to DP
|
| 251 |
*/
|
| 252 |
private function loadFileToDb(){
|
| 253 |
+
$connection = $this->getTestDbConnection();
|
| 254 |
$testfile = Mage::getBaseDir('var') . $this->_connectorDir . 'newt.txt';
|
| 255 |
$tableName = Mage::getSingleton('core/resource')->getTableName('icecatimport/data');
|
| 256 |
$is_info_file = strpos($this->_productFile,'prodid_d.txt');
|
| 257 |
+
$max_counter = 8000;
|
| 258 |
try {
|
| 259 |
+
mysql_query("START TRANSACTION",$connection);
|
| 260 |
$fileHandler = fopen($this->XMLfile, "r");
|
| 261 |
if ($fileHandler) {
|
| 262 |
if (!$is_info_file) {
|
| 263 |
+
mysql_query("DROP TABLE IF EXISTS `".$tableName."_temp`",$connection);
|
| 264 |
+
mysql_query("CREATE TABLE `".$tableName."_temp` (
|
| 265 |
+
`prod_id` varchar(255) NOT NULL,
|
| 266 |
+
`supplier_id` int(11) DEFAULT NULL,
|
| 267 |
+
`prod_name` varchar(255) DEFAULT NULL,
|
| 268 |
+
`prod_img` varchar(255) DEFAULT NULL,
|
| 269 |
+
KEY `PRODUCT_MPN` (`prod_id`),
|
| 270 |
+
KEY `supplier_id` (`supplier_id`)
|
| 271 |
+
) ENGINE=InnoDB DEFAULT CHARSET=utf8
|
| 272 |
+
",$connection);
|
| 273 |
+
|
| 274 |
} else {
|
| 275 |
+
|
| 276 |
+
mysql_query("DROP TABLE IF EXISTS `".$tableName."_products`",$connection);
|
| 277 |
+
mysql_query("CREATE TABLE `".$tableName."_products` (
|
| 278 |
+
`prod_id` varchar(255) NOT NULL,
|
| 279 |
+
`prod_title` varchar(255) DEFAULT NULL,
|
| 280 |
+
`prod_ean` varchar(255) NOT NULL,
|
| 281 |
+
KEY `prod_id` (`prod_id`),
|
| 282 |
+
KEY `PRODUCT_EAN` (`prod_ean`)
|
| 283 |
+
) ENGINE=InnoDB DEFAULT CHARSET=utf8
|
| 284 |
+
",$connection);
|
| 285 |
}
|
| 286 |
if (!$is_info_file) {
|
| 287 |
+
$csvFile = Mage::getBaseDir('var') . $this->_connectorDir . 'ice_cat_temp.csv';
|
| 288 |
} else {
|
| 289 |
+
$csvFile = Mage::getBaseDir('var') . $this->_connectorDir . 'ice_cat_temp_prod.csv';
|
| 290 |
}
|
| 291 |
|
| 292 |
+
$csvFile = str_replace("\\", "\\\\", $csvFile);
|
| 293 |
$csvFileRes = fopen($csvFile, "w+");
|
| 294 |
+
$counter = 0;
|
| 295 |
+
$sql = "";
|
| 296 |
+
$test_sql = "";
|
| 297 |
+
|
| 298 |
while (!feof($fileHandler)) {
|
| 299 |
$row = fgets($fileHandler);
|
| 300 |
$oneLine = explode("\t", $row);
|
| 301 |
|
| 302 |
if ($oneLine[0]!= 'product_id' && $oneLine[0]!= '' && !$is_info_file) {
|
| 303 |
+
|
| 304 |
try{
|
| 305 |
|
| 306 |
+
$prod_id = (!empty($oneLine[1])) ? addslashes($oneLine[1]) : '';
|
| 307 |
+
$prod_img = (!empty($oneLine[6])) ? addslashes($oneLine[6]) : addslashes($oneLine[5]);
|
| 308 |
+
$prod_name = (!empty($oneLine[12])) ? addslashes($oneLine[12]) : '';
|
| 309 |
+
$supplier_id = (!empty($oneLine[4])) ? addslashes($oneLine[4]) : '';
|
|
|
|
| 310 |
|
| 311 |
+
if ($counter == 1 ) {
|
| 312 |
+
$sql = " INSERT INTO ".$tableName."_temp ( prod_id, supplier_id, prod_name, prod_img ) VALUES(\"$prod_id\",\"$supplier_id\",\"$prod_name\",\"$prod_img\") ";
|
| 313 |
+
} else if ($counter % $max_counter == 0) {
|
| 314 |
+
|
| 315 |
+
mysql_query($sql,$connection);
|
| 316 |
+
$sql = " INSERT INTO ".$tableName."_temp ( prod_id, supplier_id, prod_name, prod_img ) VALUES(\"$prod_id\",\"$supplier_id\",\"$prod_name\",\"$prod_img\") ";
|
| 317 |
+
} else {
|
| 318 |
+
$sql .= " , (\"$prod_id\",\"$supplier_id\",\"$prod_name\",\"$prod_img\") ";
|
| 319 |
+
}
|
| 320 |
+
|
| 321 |
}catch(Exception $e){
|
| 322 |
Mage::log("connector issue: {$e->getMessage()}");
|
| 323 |
}
|
| 334 |
$prod_ean = !empty($eans[0]) ? $eans[0] : '';
|
| 335 |
}
|
| 336 |
}
|
| 337 |
+
$prod_id = (!empty($oneLine[0])) ? addslashes(str_replace("\t",'',$oneLine[0])) : '';
|
| 338 |
+
$brand = (!empty($oneLine3)) ? addslashes(str_replace("\t",'',$oneLine[3]. '|')) : '';
|
| 339 |
+
$model = (!empty($oneLine12)) ? addslashes(str_replace("\t",'',$oneLine[12].'|')) : '';
|
| 340 |
+
$family = (!empty($oneLine21)) ? addslashes(preg_replace("/\s+/", "",$oneLine[21].'|')) : '';
|
| 341 |
+
|
| 342 |
+
if ($counter == 1) {
|
| 343 |
+
$sql = " INSERT INTO ".$tableName."_products ( prod_id, prod_title,prod_ean ) VALUES(\"$prod_id\",\"$brand$family$model\",\"$prod_ean\") ";
|
| 344 |
+
} else if ($counter % $max_counter == 0) {
|
| 345 |
+
|
| 346 |
+
mysql_query($sql,$connection);
|
| 347 |
+
$sql = " INSERT INTO ".$tableName."_products ( prod_id, prod_title,prod_ean ) VALUES(\"$prod_id\",\"$brand$family$model\",\"$prod_ean\") ";
|
| 348 |
+
} else {
|
| 349 |
+
$sql .= " , (\"$prod_id\",\"$brand$family$model\",\"$prod_ean\") ";
|
| 350 |
+
}
|
| 351 |
}catch(Exception $e){
|
| 352 |
Mage::log("connector issue: {$e->getMessage()}");
|
| 353 |
}
|
| 354 |
}
|
| 355 |
+
$counter++;
|
| 356 |
}
|
| 357 |
+
if (!$is_info_file) {
|
| 358 |
+
mysql_query($sql,$connection);
|
| 359 |
+
mysql_query("DROP TABLE IF EXISTS `".$tableName."_old`",$connection);
|
| 360 |
+
mysql_query("rename table `".$tableName."` to `".$tableName."_old`, `".$tableName."_temp` to ".$tableName,$connection);
|
| 361 |
+
mysql_query("COMMIT",$connection);
|
| 362 |
+
} else{
|
| 363 |
+
mysql_query($sql,$connection);
|
| 364 |
+
mysql_query("COMMIT",$connection);
|
| 365 |
+
}
|
| 366 |
+
|
| 367 |
+
fclose($fileHandler);
|
| 368 |
+
|
| 369 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 370 |
}
|
| 371 |
} catch (Exception $e) {
|
| 372 |
+
mysql_query("ROLLBACK",$connection);
|
| 373 |
throw new Exception("Icecat Import Terminated: {$e->getMessage()}");
|
| 374 |
}
|
| 375 |
}
|
|
@@ -0,0 +1,160 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
<?php
|
| 2 |
+
class Bintime_Icecatimport_Helper_Output extends Mage_Catalog_Helper_Output
|
| 3 |
+
{
|
| 4 |
+
|
| 5 |
+
private $iceCatModel;
|
| 6 |
+
private $error = false;
|
| 7 |
+
private $systemError;
|
| 8 |
+
|
| 9 |
+
/**
|
| 10 |
+
* @var isFirstTime spike for getProductDescription that is called many times from template
|
| 11 |
+
*/
|
| 12 |
+
private $isFirstTime = true;
|
| 13 |
+
|
| 14 |
+
/**
|
| 15 |
+
* Prepare product attribute html output
|
| 16 |
+
*
|
| 17 |
+
* @param Mage_Catalog_Model_Product $product
|
| 18 |
+
* @param string $attributeHtml
|
| 19 |
+
* @param string $attributeName
|
| 20 |
+
* @return string
|
| 21 |
+
*/
|
| 22 |
+
public function productAttribute($product, $attributeHtml, $attributeName){
|
| 23 |
+
|
| 24 |
+
$productId = $product->getId();
|
| 25 |
+
|
| 26 |
+
if (!mage::registry('product')) {
|
| 27 |
+
Mage::register('product', $product);
|
| 28 |
+
Mage::register('current_product', $product);
|
| 29 |
+
// return parent::productAttribute($product, $attributeHtml, $attributeName);
|
| 30 |
+
}
|
| 31 |
+
|
| 32 |
+
if ($attributeName == 'image') {
|
| 33 |
+
return parent::productAttribute($product, $attributeHtml, $attributeName);
|
| 34 |
+
}
|
| 35 |
+
|
| 36 |
+
$productDescriptionPriority = Mage::getStoreConfig('icecat_root/icecat/descript_priority');
|
| 37 |
+
$productShortDescrPriority = Mage::getStoreConfig('icecat_root/icecat/shortdescr_priority');
|
| 38 |
+
$productNamePriority = Mage::getStoreConfig('icecat_root/icecat/name_priority');
|
| 39 |
+
|
| 40 |
+
|
| 41 |
+
|
| 42 |
+
$dbDescriptionPriority = false;
|
| 43 |
+
$dbShortDescriptionPriority = false;
|
| 44 |
+
$current_page = Mage::app()->getFrontController()->getRequest()->getControllerName();
|
| 45 |
+
if ($productDescriptionPriority == 'Db' && $attributeName == 'description') {
|
| 46 |
+
$dbDescriptionPriority = true;
|
| 47 |
+
}
|
| 48 |
+
if ($productShortDescrPriority == 'Db' && $attributeName == 'short_description') {
|
| 49 |
+
$dbShortDescriptionPriority = true;
|
| 50 |
+
}
|
| 51 |
+
|
| 52 |
+
if ($current_page == 'product') {
|
| 53 |
+
$bin_prod = new Bintime_Icecatimport_Model_Catalog_Product();
|
| 54 |
+
if ($attributeName == 'description' || $attributeName == 'short_description') {
|
| 55 |
+
$descr = $bin_prod->checkIcecatProdDescription($productId,$attributeName);
|
| 56 |
+
}
|
| 57 |
+
}
|
| 58 |
+
$prod_source = Bintime_Icecatimport_Model_Catalog_Product::$_product_source;
|
| 59 |
+
|
| 60 |
+
if( $prod_source == 'DB' && empty($descr) ) {
|
| 61 |
+
$dbDescriptionPriority = true;
|
| 62 |
+
$dbShortDescriptionPriority = true;
|
| 63 |
+
}
|
| 64 |
+
|
| 65 |
+
if ($dbShortDescriptionPriority || ($current_page != 'product'
|
| 66 |
+
&& $prod_source != 'DB' ) && $attributeName != 'name') {
|
| 67 |
+
if ($attributeName == 'short_description') {
|
| 68 |
+
$attributeHtml = $product->getData('short_description');
|
| 69 |
+
}
|
| 70 |
+
return parent::productAttribute($product, $attributeHtml, $attributeName);
|
| 71 |
+
}
|
| 72 |
+
$this->iceCatModel = Mage::getSingleton('icecatimport/import');
|
| 73 |
+
|
| 74 |
+
if ($this->isFirstTime){
|
| 75 |
+
$helper = Mage::helper('icecatimport/getdata');
|
| 76 |
+
$helper->getProductDescription($product);
|
| 77 |
+
|
| 78 |
+
if ($helper->hasError() && $attributeName != 'name') {
|
| 79 |
+
$this->error = true;
|
| 80 |
+
}
|
| 81 |
+
$this->isFirstTime = false;
|
| 82 |
+
}
|
| 83 |
+
|
| 84 |
+
if ($this->error){
|
| 85 |
+
if ($attributeName != 'description' && $attributeName != 'short_description') {
|
| 86 |
+
return parent::productAttribute($product, $attributeHtml, $attributeName);
|
| 87 |
+
} else {
|
| 88 |
+
return '';
|
| 89 |
+
}
|
| 90 |
+
|
| 91 |
+
}
|
| 92 |
+
|
| 93 |
+
$id = $product->getData('entity_id');
|
| 94 |
+
|
| 95 |
+
if ($attributeName == 'name' && $productNamePriority != 'Db'){
|
| 96 |
+
//if we on product page then mage::registry('product') exist
|
| 97 |
+
if ($product->getId() == $this->iceCatModel->entityId && $name = $this->iceCatModel->getProductName()) {
|
| 98 |
+
return $name;
|
| 99 |
+
} else if(!empty($descr)) {
|
| 100 |
+
return $descr;
|
| 101 |
+
}
|
| 102 |
+
$manufacturerId = Mage::getStoreConfig('icecat_root/icecat/manufacturer');
|
| 103 |
+
$mpn = Mage::getStoreConfig('icecat_root/icecat/sku_field');
|
| 104 |
+
$collection = Mage::getResourceModel('catalog/product_collection');
|
| 105 |
+
$collection->addAttributeToSelect($manufacturerId)->addAttributeToSelect($mpn)
|
| 106 |
+
->addAttributeToSelect('name')
|
| 107 |
+
->addAttributeToFilter('entity_id', array('eq' => $id));
|
| 108 |
+
$product = $collection->getFirstItem() ;
|
| 109 |
+
return $product->getName();
|
| 110 |
+
}
|
| 111 |
+
|
| 112 |
+
if ($attributeName == 'short_description' && !$dbShortDescriptionPriority ) {
|
| 113 |
+
$icecat_descr = $this->iceCatModel->getShortProductDescription();
|
| 114 |
+
if (!empty($descr)) {
|
| 115 |
+
return $descr;
|
| 116 |
+
} else if(!empty($icecat_descr)) {
|
| 117 |
+
return $icecat_descr;
|
| 118 |
+
} else {
|
| 119 |
+
$attributeHtml = $product->getData('short_description');
|
| 120 |
+
return parent::productAttribute($product, $attributeHtml, $attributeName);
|
| 121 |
+
}
|
| 122 |
+
}
|
| 123 |
+
if ($attributeName == 'description' && !$dbDescriptionPriority) {
|
| 124 |
+
$icecat_full_descr = $this->iceCatModel->getFullProductDescription();
|
| 125 |
+
if (!empty($icecat_full_descr)) {
|
| 126 |
+
return str_replace("\\n", "<br>",$icecat_full_descr);
|
| 127 |
+
} else {
|
| 128 |
+
$attributeHtml = $product->getData('description');
|
| 129 |
+
}
|
| 130 |
+
}
|
| 131 |
+
return parent::productAttribute($product, $attributeHtml, $attributeName);
|
| 132 |
+
}
|
| 133 |
+
|
| 134 |
+
|
| 135 |
+
public function getWarrantyInfo(){
|
| 136 |
+
return $this->iceCatModel->getWarrantyInfo();
|
| 137 |
+
}
|
| 138 |
+
|
| 139 |
+
public function getShortSummaryDescription(){
|
| 140 |
+
return $this->iceCatModel->getShortSummaryDescription();
|
| 141 |
+
}
|
| 142 |
+
|
| 143 |
+
public function getLongSummaryDescription(){
|
| 144 |
+
return $this->iceCatModel->getLongSummaryDescription();
|
| 145 |
+
}
|
| 146 |
+
|
| 147 |
+
public function getManualPDF(){
|
| 148 |
+
return $this->iceCatModel->getManualPDF();
|
| 149 |
+
}
|
| 150 |
+
|
| 151 |
+
public function getPDF(){
|
| 152 |
+
return $this->iceCatModel->getPDF();
|
| 153 |
+
}
|
| 154 |
+
|
| 155 |
+
public function getIceCatMedia(){
|
| 156 |
+
$media = (array)$this->iceCatModel->getIceCatMedia();
|
| 157 |
+
return (array_key_exists('@attributes', $media)) ? $media['@attributes'] : array();
|
| 158 |
+
}
|
| 159 |
+
}
|
| 160 |
+
?>
|
|
@@ -0,0 +1,13 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
<?php
|
| 2 |
+
class Bintime_Icecatimport_Model_System_Config_Imagepriority
|
| 3 |
+
{
|
| 4 |
+
public function toOptionArray()
|
| 5 |
+
{
|
| 6 |
+
return array(
|
| 7 |
+
'Icecat' => 'From Icecat',
|
| 8 |
+
'Db' => 'From Database'
|
| 9 |
+
);
|
| 10 |
+
|
| 11 |
+
}
|
| 12 |
+
}
|
| 13 |
+
?>
|
|
@@ -0,0 +1,13 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
<?php
|
| 2 |
+
class Bintime_Icecatimport_Model_System_Config_Namepriority
|
| 3 |
+
{
|
| 4 |
+
public function toOptionArray()
|
| 5 |
+
{
|
| 6 |
+
return array(
|
| 7 |
+
'Icecat' => 'From Icecat',
|
| 8 |
+
'Db' => 'From Database'
|
| 9 |
+
);
|
| 10 |
+
|
| 11 |
+
}
|
| 12 |
+
}
|
| 13 |
+
?>
|
|
@@ -0,0 +1,13 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
<?php
|
| 2 |
+
class Bintime_Icecatimport_Model_System_Config_Productpriority
|
| 3 |
+
{
|
| 4 |
+
public function toOptionArray()
|
| 5 |
+
{
|
| 6 |
+
return array(
|
| 7 |
+
'Show' => 'Show all products',
|
| 8 |
+
'Hide' => 'Hide products not from Icecat'
|
| 9 |
+
);
|
| 10 |
+
|
| 11 |
+
}
|
| 12 |
+
}
|
| 13 |
+
?>
|
|
@@ -0,0 +1,13 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
<?php
|
| 2 |
+
class Bintime_Icecatimport_Model_System_Config_Shortdescrpriority
|
| 3 |
+
{
|
| 4 |
+
public function toOptionArray()
|
| 5 |
+
{
|
| 6 |
+
return array(
|
| 7 |
+
'Icecat' => 'From Icecat',
|
| 8 |
+
'Db' => 'From Database'
|
| 9 |
+
);
|
| 10 |
+
|
| 11 |
+
}
|
| 12 |
+
}
|
| 13 |
+
?>
|
|
@@ -24,9 +24,8 @@
|
|
| 24 |
<product_view_media>Bintime_Icecatimport_Block_Media</product_view_media>
|
| 25 |
<product_list_related>Bintime_Icecatimport_Block_Related</product_list_related>
|
| 26 |
<product_list_upsell>Bintime_Icecatimport_Block_Upsell</product_list_upsell>
|
| 27 |
-
|
| 28 |
-
</catalog>
|
| 29 |
-
|
| 30 |
</blocks>
|
| 31 |
<models>
|
| 32 |
<icecatimport>
|
|
@@ -139,7 +138,7 @@
|
|
| 139 |
<crontab>
|
| 140 |
<jobs>
|
| 141 |
<icecatimport>
|
| 142 |
-
<schedule><cron_expr>
|
| 143 |
<run><model>icecatimport/observer::load</model></run>
|
| 144 |
</icecatimport>
|
| 145 |
</jobs>
|
| 24 |
<product_view_media>Bintime_Icecatimport_Block_Media</product_view_media>
|
| 25 |
<product_list_related>Bintime_Icecatimport_Block_Related</product_list_related>
|
| 26 |
<product_list_upsell>Bintime_Icecatimport_Block_Upsell</product_list_upsell>
|
| 27 |
+
</rewrite>
|
| 28 |
+
</catalog>
|
|
|
|
| 29 |
</blocks>
|
| 30 |
<models>
|
| 31 |
<icecatimport>
|
| 138 |
<crontab>
|
| 139 |
<jobs>
|
| 140 |
<icecatimport>
|
| 141 |
+
<schedule><cron_expr>0 0 * * 1</cron_expr></schedule>
|
| 142 |
<run><model>icecatimport/observer::load</model></run>
|
| 143 |
</icecatimport>
|
| 144 |
</jobs>
|
|
@@ -89,6 +89,33 @@
|
|
| 89 |
<show_in_website>1</show_in_website>
|
| 90 |
<show_in_store>1</show_in_store>
|
| 91 |
</descript_priority>
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 92 |
</fields>
|
| 93 |
</icecat>
|
| 94 |
</groups>
|
| 89 |
<show_in_website>1</show_in_website>
|
| 90 |
<show_in_store>1</show_in_store>
|
| 91 |
</descript_priority>
|
| 92 |
+
<shortdescr_priority translate="label">
|
| 93 |
+
<label>Use Short description from </label>
|
| 94 |
+
<frontend_type>select</frontend_type>
|
| 95 |
+
<source_model>icecatimport/system_config_shortdescrpriority</source_model>
|
| 96 |
+
<sort_order>70</sort_order>
|
| 97 |
+
<show_in_default>1</show_in_default>
|
| 98 |
+
<show_in_website>1</show_in_website>
|
| 99 |
+
<show_in_store>1</show_in_store>
|
| 100 |
+
</shortdescr_priority>
|
| 101 |
+
<name_priority translate="label">
|
| 102 |
+
<label>Use Product Name from </label>
|
| 103 |
+
<frontend_type>select</frontend_type>
|
| 104 |
+
<source_model>icecatimport/system_config_namepriority</source_model>
|
| 105 |
+
<sort_order>70</sort_order>
|
| 106 |
+
<show_in_default>1</show_in_default>
|
| 107 |
+
<show_in_website>1</show_in_website>
|
| 108 |
+
<show_in_store>1</show_in_store>
|
| 109 |
+
</name_priority>
|
| 110 |
+
<image_priority translate="label">
|
| 111 |
+
<label>Use Product Image from </label>
|
| 112 |
+
<frontend_type>select</frontend_type>
|
| 113 |
+
<source_model>icecatimport/system_config_imagepriority</source_model>
|
| 114 |
+
<sort_order>70</sort_order>
|
| 115 |
+
<show_in_default>1</show_in_default>
|
| 116 |
+
<show_in_website>1</show_in_website>
|
| 117 |
+
<show_in_store>1</show_in_store>
|
| 118 |
+
</image_priority>
|
| 119 |
</fields>
|
| 120 |
</icecat>
|
| 121 |
</groups>
|
|
@@ -1,30 +1,35 @@
|
|
| 1 |
<?xml version="1.0"?>
|
| 2 |
<package>
|
| 3 |
<name>IcecatLive</name>
|
| 4 |
-
<version>1.
|
| 5 |
<stability>stable</stability>
|
| 6 |
<license uri="http://opensource.org/licenses/osl-3.0.php">OSL v.3</license>
|
| 7 |
<channel>community</channel>
|
| 8 |
<extends/>
|
| 9 |
<summary>ICEcat to Magento Open Source Connector</summary>
|
| 10 |
<description>ICEcat to Magento Open Source Connector - rich content in your magento shop</description>
|
| 11 |
-
<notes
|
| 12 |
-
- Added support of Multilanguage stores
|
| 13 |
-
- Added new setting Description
|
| 14 |
-
- Added
|
| 15 |
-
- Added
|
| 16 |
-
- Added
|
| 17 |
-
-
|
| 18 |
-
-
|
| 19 |
-
-
|
| 20 |
-
-
|
| 21 |
-
-
|
| 22 |
-
- Fixed problems with
|
| 23 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 24 |
<authors><author><name>IceShop</name><user>IceShop</user><email>support@iceshop.nl</email></author></authors>
|
| 25 |
-
<date>2013-07-
|
| 26 |
-
<time>
|
| 27 |
-
<contents><target name="magelocal"><dir name="Bintime"><dir name="Icecatimport"><dir name="Block"><file name="Attributes.php" hash="ae93e0a964e8880e5b65fb5d08f1edf9"/><file name="Media.php" hash="
|
| 28 |
<compatible/>
|
| 29 |
<dependencies><required><php><min>5.2.0</min><max>6.0.0</max></php></required></dependencies>
|
| 30 |
</package>
|
| 1 |
<?xml version="1.0"?>
|
| 2 |
<package>
|
| 3 |
<name>IcecatLive</name>
|
| 4 |
+
<version>1.4.0</version>
|
| 5 |
<stability>stable</stability>
|
| 6 |
<license uri="http://opensource.org/licenses/osl-3.0.php">OSL v.3</license>
|
| 7 |
<channel>community</channel>
|
| 8 |
<extends/>
|
| 9 |
<summary>ICEcat to Magento Open Source Connector</summary>
|
| 10 |
<description>ICEcat to Magento Open Source Connector - rich content in your magento shop</description>
|
| 11 |
+
<notes>- Added mapping by EAN/UPC codes&#xD;
|
| 12 |
+
- Added support of Multilanguage stores&#xD;
|
| 13 |
+
- Added new setting Description Priority&#xD;
|
| 14 |
+
- Added new setting Short Description Priority&#xD;
|
| 15 |
+
- Added new setting Product Name Priority&#xD;
|
| 16 |
+
- Added new setting Product Images Priority&#xD;
|
| 17 |
+
- Added loading products description from DB when icecat info is missing and config setting product descr source is set to icecat &#xD; 
|
| 18 |
+
- Added saving icecat images to server and display from there &#xD; 
|
| 19 |
+
- Added saving product title to db from file and display it on list page &#xD; 
|
| 20 |
+
- Added cron process lock - only one icecat cron process can be running at a time &#xD; 
|
| 21 |
+
- LOAD DATA replaced with insert queries &#xD;
|
| 22 |
+
- Fixed problems with Icecat names&#xD;
|
| 23 |
+
- Fixed problems with images on product listing/shopping cart.&#xD;
|
| 24 |
+
- Fixed problems with correct displaying attributes on product detail page&#xD;
|
| 25 |
+
- Fixed problems with description on product detail page &#xD;
|
| 26 |
+
- Fixed product info in breadcrumbs &#xD;
|
| 27 |
+
- Fixed problems with loading icecat data for each product on product listing page &#xD;
|
| 28 |
+
- Fixed problems with product images and gallery&#xD;</notes>
|
| 29 |
<authors><author><name>IceShop</name><user>IceShop</user><email>support@iceshop.nl</email></author></authors>
|
| 30 |
+
<date>2013-07-18</date>
|
| 31 |
+
<time>16:03:03</time>
|
| 32 |
+
<contents><target name="magelocal"><dir name="Bintime"><dir name="Icecatimport"><dir name="Block"><file name="Attributes.php" hash="ae93e0a964e8880e5b65fb5d08f1edf9"/><file name="Media.php" hash="1ada42f85cff27882bb181995ffc5579"/><file name="Related.php" hash="7ca2ad6520f2644ad1302c02d1cd6853"/><file name="Upsell.php" hash="f7a79cee4cb7ecb679f65e7ec7a487c4"/></dir><dir name="Helper"><dir name="Catalog"><file name="Image.php" hash="93e3d8339089349f1d7d0f2589e5399f"/></dir><file name="Getdata.php" hash="0bb4c9c6d89f7d233aea87e4e2cb0d2a"/><file name="Image.php" hash="b55ed2b8ea0b05f07f208370a285300e"/><file name="Output.php" hash="e75ca556697178724135a33b7e58a8c9"/></dir><dir name="Model"><dir name="Catalog"><file name="Category.php" hash="21abeb7a7c2c85db8ce4d2f4ed203f50"/><file name="Product.php" hash="5ebed9c1318ae03acd671e6147de878c"/><file name="Search.php" hash="99c7eb706e67e01ea8167ebe88fe72d9"/></dir><file name="Imagescollection.php" hash="718b575ef9472f85c323fa40f80bbd05"/><file name="Import.php" hash="30f17bd2d367f3a1104a1e6092753ddf"/><file name="Observer.php" hash="bf8f785e791e94dd870f6d309701110a"/><file name="Relatedcollection.php" hash="2ddf62c43a66c3fd70bf651d0078dbc1"/><dir name="System"><dir name="Config"><file name="Attributes.php" hash="23284e0d38677b4544fc87642a6bc8b5"/><file name="Descriptionpriority.php" hash="e32f7b5893ded762a45c742d4e6944fd"/><file name="Imagepriority.php" hash="d3e623e8c1523f1edd555bea43f9950d"/><file name="LanguageList.xml" hash="391ef56fab212879709780df5a7710e7"/><file name="Locales.php" hash="b8c699fa2a6f657b6d52d86e656872cc"/><file name="Namepriority.php" hash="8c24c8dffd826e7b8259546d61f33ea7"/><file name="Shortdescrpriority.php" hash="4afecd1d5046e0e7813364c26ad5e857"/><file name="Subscription.php" hash="62168986f7a4eb3f10d38ac627aa6510"/></dir></dir></dir><dir name="controllers"><file name="ImageController.php" hash="cdf4984c268346088729831b7abdf026"/></dir><dir name="etc"><file name="config.xml" hash="13d5b3c94451f13119c90a8added2374"/><file name="system.xml" hash="ecc6cbc5084c070ed537c524c89e63f0"/></dir><dir name="sql"><dir name="icecatimport_setup"><file name="mysql4-install-0.1.0.php" hash="08f5875b240c2f229b95194b6335f9a6"/><file name="mysql4-upgrade-0.1.0-0.1.1.php" hash="c0581c5b00420492714bd7e3cc66cb6d"/></dir></dir></dir></dir></target><target name="mageetc"><dir name="modules"><file name="Bintime_Icecatimport.xml" hash="daf681aae3e710568d210313816a9d5f"/></dir></target></contents>
|
| 33 |
<compatible/>
|
| 34 |
<dependencies><required><php><min>5.2.0</min><max>6.0.0</max></php></required></dependencies>
|
| 35 |
</package>
|
