IcecatLive - Version 1.6.0

Version Notes

- Changed namespaces, renamed Bintime to Iceshop
- Fixed cache mechanizm
- Fixed mapping via EAN
- Fixed images display with CloudZoom
- Fixed mapping with Brand (if the attribute type Pulldown)
- Added import button to module settings, and possibility to run import via admin part
- Added log file, administrator of the shop can see what is going on with import.

Download this release

Release Info

Developer IceShop
Extension IcecatLive
Version 1.6.0
Comparing to
See all releases


Code changes from version 1.5.0 to 1.6.0

Files changed (75) hide show
  1. app/code/local/Bintime/Icecatimport/Block/Attributes.php +0 -98
  2. app/code/local/Bintime/Icecatimport/Block/Media.php +0 -49
  3. app/code/local/Bintime/Icecatimport/Block/Product/List/Toolbar.php +0 -70
  4. app/code/local/Bintime/Icecatimport/CatalogSearch/Block/Result.php +0 -32
  5. app/code/local/Bintime/Icecatimport/Helper/Catalog/Image.php +0 -65
  6. app/code/local/Bintime/Icecatimport/Helper/Getdata.php +0 -190
  7. app/code/local/Bintime/Icecatimport/Helper/Image.php +0 -47
  8. app/code/local/Bintime/Icecatimport/Helper/Output.php +0 -169
  9. app/code/local/Bintime/Icecatimport/Model/Catalog/Category.php +0 -19
  10. app/code/local/Bintime/Icecatimport/Model/Catalog/Product.php +0 -212
  11. app/code/local/Bintime/Icecatimport/Model/Catalog/Search.php +0 -15
  12. app/code/local/Bintime/Icecatimport/Model/Imagescollection.php +0 -45
  13. app/code/local/Bintime/Icecatimport/Model/Import.php +0 -573
  14. app/code/local/Bintime/Icecatimport/Model/Observer.php +0 -447
  15. app/code/local/Bintime/Icecatimport/Model/Output.php +0 -160
  16. app/code/local/Bintime/Icecatimport/Model/Relatedcollection.php +0 -71
  17. app/code/local/Bintime/Icecatimport/Model/System/Config/Attributes.php +0 -21
  18. app/code/local/Bintime/Icecatimport/Model/System/Config/Descriptionpriority.php +0 -13
  19. app/code/local/Bintime/Icecatimport/Model/System/Config/Imagepriority.php +0 -13
  20. app/code/local/Bintime/Icecatimport/Model/System/Config/LanguageList.xml +0 -399
  21. app/code/local/Bintime/Icecatimport/Model/System/Config/Locales.php +0 -45
  22. app/code/local/Bintime/Icecatimport/Model/System/Config/Namepriority.php +0 -13
  23. app/code/local/Bintime/Icecatimport/Model/System/Config/Productpriority.php +0 -13
  24. app/code/local/Bintime/Icecatimport/Model/System/Config/Shortdescrpriority.php +0 -13
  25. app/code/local/Bintime/Icecatimport/Model/System/Config/Subscription.php +0 -18
  26. app/code/local/Bintime/Icecatimport/controllers/ImageController.php +0 -16
  27. app/code/local/Bintime/Icecatimport/etc/config.xml +0 -154
  28. app/code/local/Bintime/Icecatimport/etc/system.xml +0 -133
  29. app/code/local/Bintime/Icecatimport/sql/icecatimport_setup/mysql4-install-0.1.0.php +0 -24
  30. app/code/local/Bintime/Icecatimport/sql/icecatimport_setup/mysql4-upgrade-0.1.0-0.1.1.php +0 -12
  31. app/code/local/Iceshop/Icecatlive/Block/Adminhtml/System/Config/Form/Button.php +57 -0
  32. app/code/local/Iceshop/Icecatlive/Block/Attributes.php +89 -0
  33. app/code/local/Iceshop/Icecatlive/Block/Media.php +41 -0
  34. app/code/local/Iceshop/Icecatlive/Block/Product/List/Toolbar.php +84 -0
  35. app/code/local/{Bintime/Icecatimport → Iceshop/Icecatlive}/Block/Related.php +17 -18
  36. app/code/local/{Bintime/Icecatimport → Iceshop/Icecatlive}/Block/Upsell.php +12 -12
  37. app/code/local/Iceshop/Icecatlive/CatalogSearch/Block/Result.php +34 -0
  38. app/code/local/Iceshop/Icecatlive/Helper/Catalog/Image.php +58 -0
  39. app/code/local/Iceshop/Icecatlive/Helper/Data.php +4 -0
  40. app/code/local/Iceshop/Icecatlive/Helper/Getdata.php +211 -0
  41. app/code/local/Iceshop/Icecatlive/Helper/Image.php +49 -0
  42. app/code/local/Iceshop/Icecatlive/Helper/Output.php +179 -0
  43. app/code/local/Iceshop/Icecatlive/Model/Catalog/Category.php +19 -0
  44. app/code/local/Iceshop/Icecatlive/Model/Catalog/Product.php +237 -0
  45. app/code/local/Iceshop/Icecatlive/Model/Catalog/Search.php +15 -0
  46. app/code/local/Iceshop/Icecatlive/Model/Imagescollection.php +47 -0
  47. app/code/local/Iceshop/Icecatlive/Model/Import.php +616 -0
  48. app/code/local/Iceshop/Icecatlive/Model/Observer.php +493 -0
  49. app/code/local/Iceshop/Icecatlive/Model/Relatedcollection.php +69 -0
  50. app/code/local/Iceshop/Icecatlive/Model/System/Config/Attributes.php +21 -0
  51. app/code/local/Iceshop/Icecatlive/Model/System/Config/Descriptionpriority.php +14 -0
  52. app/code/local/Iceshop/Icecatlive/Model/System/Config/Imagepriority.php +14 -0
  53. app/code/local/Iceshop/Icecatlive/Model/System/Config/Importdata.php +13 -0
  54. app/code/local/Iceshop/Icecatlive/Model/System/Config/LanguageList.xml +399 -0
  55. app/code/local/Iceshop/Icecatlive/Model/System/Config/Locales.php +50 -0
  56. app/code/local/Iceshop/Icecatlive/Model/System/Config/Namepriority.php +14 -0
  57. app/code/local/Iceshop/Icecatlive/Model/System/Config/Productpriority.php +14 -0
  58. app/code/local/Iceshop/Icecatlive/Model/System/Config/Shortdescrpriority.php +14 -0
  59. app/code/local/Iceshop/Icecatlive/Model/System/Config/Subscription.php +18 -0
  60. app/code/local/Iceshop/Icecatlive/controllers/Adminhtml/ImportdataController.php +16 -0
  61. app/code/local/Iceshop/Icecatlive/controllers/Adminhtml/ImportprogressController.php +19 -0
  62. app/code/local/Iceshop/Icecatlive/controllers/ImageController.php +18 -0
  63. app/code/local/Iceshop/Icecatlive/etc/config.xml +185 -0
  64. app/code/local/Iceshop/Icecatlive/etc/system.xml +142 -0
  65. app/code/local/Iceshop/Icecatlive/sql/icecatlive_setup/mysql4-install-1.6.0.php +44 -0
  66. app/code/local/Iceshop/Icecatlive/sql/icecatlive_setup/mysql4-upgrade-0.1.0-1.6.0.php +45 -0
  67. app/code/local/Iceshop/Icecatlive/sql/icecatlive_setup/mysql4-upgrade-0.1.1-1.6.0.php +45 -0
  68. app/code/local/Iceshop/Icecatlive/sql/icecatlive_setup/mysql4-upgrade-1.5.0-1.6.0.php +45 -0
  69. app/code/local/Iceshop/Icecatlive/sql/icecatlive_setup/uninstall-old-version.php +54 -0
  70. app/design/adminhtml/default/default/template/iceshop/icecatlive/ajaxstatusimport.phtml +84 -0
  71. app/design/frontend/base/default/layout/IcecatGroupAttributes.xml +0 -17
  72. app/design/frontend/default/default/layout/iceshop/icecatlive/groupattributes.xml +25 -0
  73. app/design/frontend/{base/default/template/icecatlive/attributesasgroup/groupview.phtml → default/default/template/iceshop/icecatlive/groupattributes.phtml} +1 -1
  74. app/etc/modules/{Bintime_Icecatimport.xml → Iceshop_Icecatlive.xml} +5 -2
  75. package.xml +11 -25
app/code/local/Bintime/Icecatimport/Block/Attributes.php DELETED
@@ -1,98 +0,0 @@
1
- <?php
2
-
3
- class Bintime_Icecatimport_Block_Attributes extends Mage_Core_Block_Template
4
- {
5
- public function getProduct()
6
- {
7
- if (!$this->_product) {
8
- $this->_product = Mage::registry('product');
9
- }
10
- return $this->_product;
11
- }
12
-
13
- public function getAdditionalData(array $excludeAttr = array())
14
- {
15
- $data = $this->getAttributesArray();
16
-
17
- $data2 = array();
18
- foreach($data as $_data) {
19
- if ($_data['label'] != '' && $_data['value'] != '' && $_data['label'] != 'id') {
20
- $value = $_data['value'];
21
- /* $data2[] = array(
22
- 'label'=>$_data['label'],
23
- 'value'=>$_data['value'],
24
- 'code'=>''
25
- );*/
26
- $group = 0;
27
- if ($tmp = $_data["id"]) {
28
- $group = $tmp;
29
- }
30
-
31
- $data2[$group]['items'][$_data['label']] = array(
32
- 'label' => $_data['label'],
33
- 'value' => $value,
34
- 'code' => $_data['label']
35
- );
36
-
37
- $data2[$group]['attrid'] = $_data["id"];
38
-
39
- } else if (!empty($_data['code']) && $_data['code'] == 'header') {
40
- $data2[$_data['id']]["title"] = $_data['value'];
41
- }
42
- }
43
-
44
- return $data2;
45
- }
46
-
47
- public function formatValue($value) {
48
- if($value == "Y"){
49
- //return "Yes";
50
- return '<img border="0" alt="" src="http://prf.icecat.biz/imgs/yes.gif"/>';
51
- }
52
- else if ($value == "N"){
53
- // return "No";
54
- return '<img border="0" alt="" src="http://prf.icecat.biz/imgs/no.gif"/>';
55
- }
56
- return str_replace("\\n", "<br>",htmlspecialchars($value));
57
- }
58
-
59
- public function getAttributesArray() {
60
- $iceModel = Mage::getSingleton('icecatimport/import');
61
- $descriptionsListArray = $iceModel->getProductDescriptionList();
62
- $id = '';
63
- $arr = array();
64
- foreach($descriptionsListArray as $key=>$ma)
65
- { $id = $key;
66
- foreach($ma as $key=>$value)
67
- {
68
- $arr[$key] = $value;
69
- $arr[$key]["id"] = $id;
70
- }
71
- }
72
-
73
- $data = array();
74
- foreach ($arr as $key => $value) {
75
- //$attributes = Mage::getModel('catalog/product')->getAttributesFromIcecat($this->getProduct()->getEntityId(), $value);
76
- // @todo @someday @maybe make headers
77
- $data[] = array(
78
- 'label' => '',
79
- 'value' => $key,
80
- 'code' => 'header',
81
- 'id' => $value["id"]
82
- );
83
- $attributes = $value;
84
- foreach ($attributes as $attributeLabel => $attributeValue) {
85
- $data[] = array(
86
- 'label' => $attributeLabel,
87
- 'value' => $this->formatValue($attributeValue),
88
- 'code' => 'descript',
89
- 'id' => $value["id"]
90
- );
91
- }
92
- }
93
- return $data;
94
- }
95
-
96
-
97
-
98
- }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
app/code/local/Bintime/Icecatimport/Block/Media.php DELETED
@@ -1,49 +0,0 @@
1
- <?php
2
-
3
- class Bintime_Icecatimport_Block_Media extends Mage_Catalog_Block_Product_View_Media
4
- {
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
-
29
-
30
-
31
- public function getGalleryUrl($image=null)
32
- {
33
- $iceCatModel = Mage::getSingleton('icecatimport/import');
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;
43
- } else {
44
- return parent::getGalleryUrl($image);
45
- }
46
- }
47
-
48
-
49
- }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
app/code/local/Bintime/Icecatimport/Block/Product/List/Toolbar.php DELETED
@@ -1,70 +0,0 @@
1
- <?php
2
-
3
- class Bintime_Icecatimport_Block_Product_List_Toolbar extends Mage_Catalog_Block_Product_List_Toolbar
4
- {
5
- public static $_productCollection = null;
6
- public static $_totalRecords = null;
7
-
8
- public function getCollection()
9
- {
10
- $ProductPriority = Mage::getStoreConfig('icecat_root/icecat/product_priority');
11
- $_productCollection = parent::getCollection();
12
-
13
- if (!$_productCollection->count() || $ProductPriority == 'Show') {
14
- return $_productCollection;
15
- } else {
16
- foreach ($_productCollection as $_product) {
17
- $icecat_prod = $this->CheckIcecatData($_product);
18
- if ($icecat_prod === false) {
19
- $_productCollection->removeItemByKey($_product->getId());
20
- }
21
- }
22
-
23
- self::$_productCollection = $_productCollection;
24
-
25
- return $_productCollection;
26
- }
27
- }
28
- public function getTotalNum() {
29
- if (self::$_productCollection === null) {
30
- return parent::getTotalNum();
31
- }
32
- self::$_totalRecords = count(self::$_productCollection->getItems());
33
- return intval(self::$_totalRecords);
34
- }
35
-
36
- public function CheckIcecatData($_product) {
37
- $connection = Mage::getSingleton('core/resource')->getConnection('core_read');
38
- $mpn = Mage::getModel('catalog/product')->load($_product->getId())->getData(Mage::getStoreConfig('icecat_root/icecat/sku_field'));
39
- $tableName = Mage::getSingleton('core/resource')->getTableName('icecatimport/data').'_products';
40
- $selectCondition = $connection->select()
41
- ->from(array('connector' => $tableName), new Zend_Db_Expr('connector.prod_title'))
42
- ->where('connector.prod_id = ? ', $mpn);
43
- $icecatName = $connection->fetchOne($selectCondition);
44
- if (!empty($icecatName)) {
45
- return true;
46
- } else {
47
- $tableName = Mage::getSingleton('core/resource')->getTableName('icecatimport/data');
48
- $mappingTable = Mage::getSingleton('core/resource')->getTableName('icecatimport/supplier_mapping');
49
- $ean = Mage::getModel('catalog/product')->load($_product->getId())->getData(Mage::getStoreConfig('icecat_root/icecat/ean_code'));
50
- $manufacturer = Mage::getModel('catalog/product')->load($_product->getId())->getData(Mage::getStoreConfig('icecat_root/icecat/manufacturer'));
51
- if (isset($manufacturer) && !empty($manufacturer)) {
52
- $selectCondition = $connection->select()
53
- ->from(array('connector' => $tableName), new Zend_Db_Expr('connector.prod_img'))
54
- ->joinInner(array('supplier' => $mappingTable), "connector.supplier_id = supplier.supplier_id AND supplier.supplier_symbol = {$connection->quote($manufacturer)}")
55
- ->where('connector.prod_id = ?', $mpn);
56
- $imageURL = $connection->fetchOne($selectCondition);
57
- }
58
- if (empty($imageURL) && !empty($ean)) {
59
- $selectCondition = $connection->select()
60
- ->from(array('connector' => $tableName), new Zend_Db_Expr('connector.prod_img'))
61
- ->joinLeft(array('products' => $tableName.'_products'), "connector.prod_id = products.prod_id")
62
- ->where('products.prod_ean = ?', trim($ean));
63
- $imageURL = $connection->fetchOne($selectCondition);
64
- }
65
- $icecat_prod = !empty($imageURL) ? true : false;
66
- return $icecat_prod;
67
- }
68
- }
69
- }
70
- ?>
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
app/code/local/Bintime/Icecatimport/CatalogSearch/Block/Result.php DELETED
@@ -1,32 +0,0 @@
1
- <?php
2
- class Bintime_Icecatimport_CatalogSearch_Block_Result extends Mage_CatalogSearch_Block_Result {
3
-
4
- /**
5
- * Retrieve search result count
6
- *
7
- * @return string
8
- */
9
- public function getResultCount()
10
- {
11
- $ProductPriority = Mage::getStoreConfig('icecat_root/icecat/product_priority');
12
-
13
- if ($ProductPriority == 'Show') {
14
- return parent::getResultCount();
15
- }
16
-
17
- $products = $this->_getProductCollection();
18
- $toolbar = new Bintime_Icecatimport_Block_Product_List_Toolbar();
19
- foreach ($products as $_product) {
20
- $icecat_prod = $toolbar->CheckIcecatData($_product);
21
- if ($icecat_prod === false) {
22
- $products->removeItemByKey($_product->getId());
23
- }
24
- }
25
- $size = count($products->getItems());
26
- $this->_getQuery()->setNumResults($size);
27
- $this->setResultCount($size);
28
- return $this->getData('result_count');
29
- }
30
-
31
- }
32
- ?>
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
app/code/local/Bintime/Icecatimport/Helper/Catalog/Image.php DELETED
@@ -1,65 +0,0 @@
1
- <?php
2
- /**
3
- * Overloaded catalog helper to substitute magento images
4
- * @author Sergey Gozhedrianov <info@bintime.com>
5
- *
6
- */
7
- class Bintime_Icecatimport_Helper_Catalog_Image extends Mage_Catalog_Helper_Image
8
- {
9
-
10
- /**
11
- * Overriden method provides product with images from icecatimport data table
12
- * @param $product Mage_Catalog_Model_Product
13
- * @param $attributeName string
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 ) {
30
- $imageFile = Mage::helper('icecatimport/image')->getImage($product);
31
- } else if ($attributeName == 'small_image' && $imageFile == null) {
32
- $imageFile = Mage::helper('icecatimport/image')->getImage($product);
33
- if (!$imageFile) {
34
- $iceImport = new Bintime_Icecatimport_Model_Import();
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 {
42
- $imageFile = $iceCatModel->saveImg($product->getEntityId(),$imageFile,$attributeName);
43
- }
44
- }
45
-
46
- return parent::init($product, $attributeName, $imageFile);
47
- }
48
-
49
- /**
50
- * Return icecat image URL if set
51
- */
52
-
53
- public function __toString()
54
- {
55
- $url = parent::__toString();
56
-
57
- if ( $this->getImageFile() && strpos( $this->getImageFile(), 'icecat.biz') && strpos($url, 'placeholder') ) {
58
- $url = $this->getImageFile();
59
- }
60
-
61
- return $url;
62
- }
63
-
64
- }
65
- ?>
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
app/code/local/Bintime/Icecatimport/Helper/Getdata.php DELETED
@@ -1,190 +0,0 @@
1
- <?php
2
- /**
3
- *
4
- * Class achieves icecat description from Model by recieved SKU and manufacturer
5
- * @author Sergey Gozhedrianov <info@bintime.com>
6
- *
7
- */
8
- class Bintime_Icecatimport_Helper_Getdata extends Mage_Core_Helper_Abstract
9
- {
10
- private $iceCatModel;
11
- private $error;
12
- private $systemError;
13
-
14
- /**
15
- * Gets product Data and delegates it to Model
16
- * @param Mage_Catalog_Model_Product $_product
17
- * @return Bintime_Icecatimport_Helper_Getdata
18
- */
19
-
20
- public function getEntityTypeId() {
21
- $connection = Mage::getSingleton('core/resource')->getConnection('core_read');
22
- $query = $connection->select()
23
- ->from(Mage::getSingleton('core/resource')
24
- ->getTableName('eav_entity_type'),'entity_type_id')
25
- ->where('entity_type_code = ?', 'catalog_product')
26
- ->limit(1);
27
- $this->entityTypeId = $connection->fetchOne($query);
28
- return $this->entityTypeId;
29
- }
30
-
31
- public function getProductDescription($_product) {
32
- try {
33
- $entityId = $_product->getEntityId();
34
- $entity_type_id = $this->getEntityTypeId();
35
- $connection = Mage::getSingleton('core/resource')->getConnection('core_read');
36
- $mpn = $_product->getData(Mage::getStoreConfig('icecat_root/icecat/sku_field'));
37
- $ean_code = $_product->getData(Mage::getStoreConfig('icecat_root/icecat/ean_code'));
38
- $manufacturerId = $_product->getData(Mage::getStoreConfig('icecat_root/icecat/manufacturer'));
39
- $attributeInfo = Mage::getResourceModel('eav/entity_attribute_collection')
40
- ->setCodeFilter(Mage::getStoreConfig('icecat_root/icecat/manufacturer'))
41
- ->setEntityTypeFilter($entity_type_id)
42
- ->getFirstItem();
43
- if ($attributeInfo->getData('backend_type') == 'int' ||
44
- ($attributeInfo->getData('frontend_input') == 'select' && $attributeInfo->getData('backend_type') == 'static' )) {
45
- $attribute = $attributeInfo->setEntity($_product->getResource());
46
- $manufacturer = $attribute->getSource()->getOptionText($manufacturerId);
47
- } else {
48
- $manufacturer = $manufacturerId;
49
- }
50
-
51
- $locale = Mage::getStoreConfig('icecat_root/icecat/language');
52
- if ($locale == '0'){
53
- $systemLocale = explode("_", Mage::app()->getLocale()->getLocaleCode());
54
- $locale = $systemLocale[0];
55
- }
56
- $userLogin = Mage::getStoreConfig('icecat_root/icecat/login');
57
- $userPass = Mage::getStoreConfig('icecat_root/icecat/password');
58
- $this->iceCatModel = Mage::getSingleton('icecatimport/import');
59
- if (!$this->iceCatModel->getProductDescription($mpn, $manufacturer, $locale, $userLogin, $userPass, $entityId, $ean_code)){
60
- $this->error = $this->iceCatModel->getErrorMessage();
61
- $this->systemError = $this->iceCatModel->getSystemError();
62
- return $this;
63
- }
64
- } catch (Exception $e) {
65
- Mage::log('Icecat getProductDescription error'.$e);
66
- }
67
- return $this;
68
- }
69
-
70
- /**
71
- * returns true if error during data fetch occured else false
72
- */
73
- public function hasError(){
74
- if ($this->error || $this->systemError){
75
- return true;
76
- }
77
- return false;
78
- }
79
-
80
- /**
81
- * return error message
82
- */
83
- public function getError(){}
84
-
85
- /**
86
- * return system error
87
- */
88
- public function hasSystemError(){
89
- if ($this->systemError){
90
- return $this->systemError;
91
- }
92
- return false;
93
- }
94
-
95
- public function getProductDescriptionList(){
96
- return $this->iceCatModel->getProductDescriptionList();
97
- }
98
-
99
- public function getShortProductDescription(){
100
- return $this->iceCatModel->getShortProductDescription();
101
- }
102
-
103
- public function getLowPicUrl(){
104
- return $this->iceCatModel->getLowPicUrl();
105
- }
106
- public function getThumbPicture(){
107
- return $this->iceCatModel->getThumbPicture();
108
- }
109
-
110
- public function getGalleryPhotos(){
111
- return $this->iceCatModel->getGalleryPhotos();
112
- }
113
-
114
- public function getProductName(){
115
- return $this->iceCatModel->getProductName();
116
- }
117
- public function getVendor(){
118
- return $this->iceCatModel->getVendor();
119
- }
120
-
121
- public function getFullProductDescription(){
122
- return $this->iceCatModel->getFullProductDescription();
123
- }
124
-
125
- public function getMPN(){
126
- return $this->iceCatModel->getMPN();
127
- }
128
- public function getEAN(){
129
- return $this->iceCatModel->getEAN();
130
- }
131
-
132
- /**
133
- * Form related products list according to store products
134
- */
135
- public function getRelatedProducts(){
136
- if (!$this->iceCatModel) {
137
- $this->iceCatModel = Mage::getSingleton('icecatimport/import');
138
- }
139
- $relatedProducts = $this->iceCatModel->getRelatedProducts();
140
- if (empty($relatedProducts)){
141
- return array();
142
- }
143
- $sku = Mage::getStoreConfig('icecat_root/icecat/sku_field');
144
- $collection = Mage::getModel('catalog/product')->getCollection();
145
- $filterArray = array();
146
- foreach($relatedProducts as $mpn => $valueArray){
147
- array_push($filterArray, array('attribute'=>$sku,'eq'=>$mpn));
148
- }
149
- $collection->addFieldToFilter($filterArray);
150
- $collection->addAttributeToSelect($sku);
151
- $collection->addAttributeToSelect('category_ids');
152
- $relatedProductsList = array();
153
- foreach ($collection as $product) {
154
- $categoryIds = $product->getCategoryIds();
155
- if (!empty($categoryIds)){
156
- if (is_array($categoryIds)){
157
- $catogoriesArray = $categoryIds;
158
- }
159
- if (is_string($categoryIds)){
160
- $catogoriesArray = explode(",",$product->getCategoryIds());
161
- }
162
- foreach($catogoriesArray as $categoryId){
163
- if (!array_key_exists($product->getData($sku), $relatedProducts)){
164
- continue;
165
- }
166
- $relatedProductInfo = $relatedProducts[$product->getData($sku)];
167
- $relatedProductInfo['mpn'] = $product->getData($sku);
168
- $relatedProductInfo['url'] = preg_replace( '/\/\d+\/$/',"/".$categoryId."/",$product->getProductUrl());;
169
- if (!array_key_exists($categoryId, $relatedProductsList)){
170
- $relatedProductsList[$categoryId]= array();
171
- }
172
- array_push($relatedProductsList[$categoryId], $relatedProductInfo);
173
- }
174
- } else {
175
- if (!array_key_exists($product->getData($sku), $relatedProducts)){
176
- continue;
177
- }
178
- $relatedProductInfo = $relatedProducts[$product->getData($sku)];
179
- $relatedProductInfo['mpn'] = $product->getData($sku);
180
- $relatedProductInfo['url'] = preg_replace( '/category\/\d+\/$/','',$product->getProductUrl());;
181
- if (!array_key_exists('a', $relatedProductsList)){
182
- $relatedProductsList['a']= array();
183
- }
184
- array_push($relatedProductsList['a'], $relatedProductInfo);
185
- }
186
- }
187
- return $relatedProductsList;
188
- }
189
- }
190
- ?>
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
app/code/local/Bintime/Icecatimport/Helper/Image.php DELETED
@@ -1,47 +0,0 @@
1
- <?php
2
- /**
3
- * Class retrieves images from icecatimport data table
4
- * @author Sergey Gozhedrianov <info@bintime.com>
5
- *
6
- */
7
- class Bintime_Icecatimport_Helper_Image extends Mage_Core_Helper_Abstract
8
- {
9
- /**
10
- * Fetch Image URL from DB
11
- * @param Mage_Catalog_Model_Product $_product
12
- * @return string image URL
13
- */
14
- public function getImage($_product) {
15
- $_product = $_product->load($_product->getId());
16
- $sku = $_product->getData(Mage::getStoreConfig('icecat_root/icecat/sku_field'));
17
- $manufacturerId = $_product->getData(Mage::getStoreConfig('icecat_root/icecat/manufacturer'));
18
-
19
- $connection = Mage::getSingleton('core/resource')->getConnection('core_read');
20
- $query = $connection->select()
21
- ->from(Mage::getSingleton('core/resource')->getTableName('eav_entity_type'),'entity_type_id')
22
- ->where('entity_type_code = ?', 'catalog_product')
23
- ->limit(1);
24
- $entityTypeId = $connection->fetchOne($query);
25
- $attributeInfo = Mage::getResourceModel('eav/entity_attribute_collection')
26
- ->setCodeFilter(Mage::getStoreConfig('icecat_root/icecat/manufacturer'))
27
- ->setEntityTypeFilter($_product->getResource()->getTypeId())
28
- ->getFirstItem();
29
- switch ($attributeInfo->getData('backend_type')) {
30
- case 'int':
31
- $attribute = $attributeInfo->setEntity($_product->getResource());
32
- $manufacturer = $attribute->getSource()->getOptionText($manufacturerId);
33
- break;
34
- default:
35
- $manufacturer = $manufacturerId;
36
- break;
37
- }
38
- $this->observer = Mage::getSingleton('icecatimport/observer');
39
-
40
- $url = $this->observer->getImageURL($sku, $manufacturer,$_product->getId());
41
- return $url;
42
- }
43
-
44
- public function getGallery() {
45
- return Mage::getSingleton('icecatimport/import')->getGalleryPhotos();
46
- }
47
- }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
app/code/local/Bintime/Icecatimport/Helper/Output.php DELETED
@@ -1,169 +0,0 @@
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
-
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 {
94
- return '';
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;
105
- } else if(!empty($descr)) {
106
- return $descr;
107
- }
108
- $manufacturerId = Mage::getStoreConfig('icecat_root/icecat/manufacturer');
109
- $mpn = Mage::getStoreConfig('icecat_root/icecat/sku_field');
110
- $collection = Mage::getResourceModel('catalog/product_collection');
111
- $collection->addAttributeToSelect($manufacturerId)->addAttributeToSelect($mpn)
112
- ->addAttributeToSelect('name')
113
- ->addAttributeToFilter('entity_id', array('eq' => $id));
114
- $product = $collection->getFirstItem() ;
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;
123
- } else if(!empty($icecat_descr)) {
124
- return $icecat_descr;
125
- } else {
126
- $attributeHtml = $product->getData('short_description');
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);
136
- } else {
137
- $attributeHtml = $product->getData('description');
138
- }
139
- }
140
- return parent::productAttribute($product, $attributeHtml, $attributeName);
141
- }
142
-
143
-
144
- public function getWarrantyInfo(){
145
- return $this->iceCatModel->getWarrantyInfo();
146
- }
147
-
148
- public function getShortSummaryDescription(){
149
- return $this->iceCatModel->getShortSummaryDescription();
150
- }
151
-
152
- public function getLongSummaryDescription(){
153
- return $this->iceCatModel->getLongSummaryDescription();
154
- }
155
-
156
- public function getManualPDF(){
157
- return $this->iceCatModel->getManualPDF();
158
- }
159
-
160
- public function getPDF(){
161
- return $this->iceCatModel->getPDF();
162
- }
163
-
164
- public function getIceCatMedia(){
165
- $media = (array)$this->iceCatModel->getIceCatMedia();
166
- return (array_key_exists('@attributes', $media)) ? $media['@attributes'] : array();
167
- }
168
- }
169
- ?>
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
app/code/local/Bintime/Icecatimport/Model/Catalog/Category.php DELETED
@@ -1,19 +0,0 @@
1
- <?php
2
- /**
3
- * class overrides category getProductCollection function to provide products with needed attributes
4
- * @author Sergey Gozhedrianov <info@bintime.com>
5
- *
6
- */
7
- class Bintime_Icecatimport_Model_Catalog_Category extends Mage_Catalog_Model_Category
8
- {
9
- /**
10
- * add product manufacturer attribute to category collection
11
- */
12
- public function getProductCollection()
13
- {
14
- $collection = parent::getProductCollection();
15
- $collection->addAttributeToSelect(Mage::getStoreConfig('icecat_root/icecat/manufacturer'));
16
- return $collection;
17
- }
18
- }
19
- ?>
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
app/code/local/Bintime/Icecatimport/Model/Catalog/Product.php DELETED
@@ -1,212 +0,0 @@
1
- <?php
2
- /**
3
- * Class overrides base Product Model to provide products icecat data
4
- * @author Sergey Gozhedrianov <info@bintime.com>
5
- *
6
- */
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())
26
- ->getFirstItem();
27
- switch ($attributeInfo->getData('backend_type')) {
28
- case 'int':
29
- $attribute = $attributeInfo->setEntity($this->getResource());
30
- $manufacturer = $attribute->getSource()->getOptionText($manufacturerId);
31
- break;
32
- default:
33
- $manufacturer = $manufacturerId;
34
- break;
35
- }
36
-
37
- $tableName = Mage::getSingleton('core/resource')->getTableName('icecatimport/data').'_products';
38
- $selectCondition = $connection->select()
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
-
51
-
52
- public function getImage(){
53
- if(!parent::getImage()||parent::getImage() == 'no_selection'){
54
- return "true";
55
- }else {
56
- return parent::getImage();
57
- }
58
- }
59
-
60
- public function getShortDescription() {
61
-
62
- if( !isset(self::$_product_source) ) {
63
- $this->checkIcecatProdDescription();
64
- }
65
-
66
- $source = self::$_product_source;
67
-
68
- if ('Icecat' == Mage::getStoreConfig('icecat_root/icecat/descript_priority') and $source != 'DB') {
69
- return true;
70
- } else {
71
- return parent::getShortDescription();
72
- }
73
- }
74
-
75
- public function getDescription() {
76
-
77
- if( !isset(self::$_product_source) ) {
78
- $this->checkIcecatProdDescription();
79
- }
80
-
81
- $source = self::$_product_source;
82
-
83
-
84
- if ('Icecat' == Mage::getStoreConfig('icecat_root/icecat/descript_priority') and $source != 'DB' ) {
85
- return true;
86
- } else {
87
- return parent::getDescription();
88
- }
89
- }
90
-
91
- public function checkIcecatProdDescription($productId = '',$attributeName = '') {
92
-
93
- $iceImport = new Bintime_Icecatimport_Model_Import();
94
-
95
- if (empty($productId)) {
96
- $productId = Mage::registry('current_product')->getId();
97
- }
98
-
99
- //$productId = Mage::registry('current_product')->getId();
100
- $model = Mage::getModel('catalog/product');
101
- $_product = $model->load($productId);
102
-
103
- $mpn = $_product->getData(Mage::getStoreConfig('icecat_root/icecat/sku_field'));
104
- $ean_code = $_product->getData(Mage::getStoreConfig('icecat_root/icecat/ean_code'));
105
- $manufacturer = $_product->getData(Mage::getStoreConfig('icecat_root/icecat/manufacturer'));
106
- $locale = Mage::getStoreConfig('icecat_root/icecat/language');
107
- if ($locale == '0'){
108
- $systemLocale = explode("_", Mage::app()->getLocale()->getLocaleCode());
109
- $locale = $systemLocale[0];
110
- }
111
- $userLogin = Mage::getStoreConfig('icecat_root/icecat/login');
112
- $userPass = Mage::getStoreConfig('icecat_root/icecat/password');
113
- $entityId = $_product->getEntityId();
114
-
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') {
124
- $descr[1] = $iceImport->getShortProductDescription();
125
- }
126
- //$productTag = $iceImport->simpleDoc->Product;
127
- // $descr[1] = (string) $productTag->ProductDescription['ShortDesc'];
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
-
142
- /**
143
- * Entity code.
144
- * Can be used as part of method name for entity processing
145
- */
146
- const ENTITY = 'catalog_product';
147
-
148
- const CACHE_TAG = 'catalog_product';
149
- protected $_cacheTag = 'catalog_product';
150
- protected $_eventPrefix = 'catalog_product';
151
- protected $_eventObject = 'product';
152
- protected $_canAffectOptions = false;
153
-
154
- /**
155
- * Product type instance
156
- *
157
- * @var Mage_Catalog_Model_Product_Type_Abstract
158
- */
159
- protected $_typeInstance = null;
160
-
161
- /**
162
- * Product type instance as singleton
163
- */
164
- protected $_typeInstanceSingleton = null;
165
-
166
- /**
167
- * Product link instance
168
- *
169
- * @var Mage_Catalog_Model_Product_Link
170
- */
171
- protected $_linkInstance;
172
-
173
- /**
174
- * Product object customization (not stored in DB)
175
- *
176
- * @var array
177
- */
178
- protected $_customOptions = array();
179
-
180
- /**
181
- * Product Url Instance
182
- *
183
- * @var Mage_Catalog_Model_Product_Url
184
- */
185
- protected $_urlModel = null;
186
- protected static $_url;
187
- protected static $_urlRewrite;
188
- protected $_errors = array();
189
- protected $_optionInstance;
190
- protected $_options = array();
191
-
192
- /**
193
- * Product reserved attribute codes
194
- */
195
- protected $_reservedAttributes;
196
-
197
- /**
198
- * Flag for available duplicate function
199
- *
200
- * @var boolean
201
- */
202
- protected $_isDuplicable = true;
203
-
204
- /**
205
- * Source of product data
206
- *
207
- * @var string
208
- */
209
- public static $_product_source = '';
210
-
211
- }
212
- ?>
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
app/code/local/Bintime/Icecatimport/Model/Catalog/Search.php DELETED
@@ -1,15 +0,0 @@
1
- <?php
2
- /**
3
- * class overrides search getProductCollection function to provide products with needed attributes
4
- * @author Sergey Gozhedrianov <info@bintime.com>
5
- *
6
- */
7
- class Bintime_Icecatimport_Model_Catalog_Search extends Mage_CatalogSearch_Model_Mysql4_Fulltext_Collection
8
- {
9
- public function _beforeLoad()
10
- {
11
- $this->addAttributeToSelect(Mage::getStoreConfig('icecat_root/icecat/manufacturer'));
12
- return parent::_beforeLoad();
13
- }
14
- }
15
- ?>
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
app/code/local/Bintime/Icecatimport/Model/Imagescollection.php DELETED
@@ -1,45 +0,0 @@
1
- <?php
2
-
3
- class Bintime_Icecatimport_Model_Imagescollection extends Varien_Data_Collection {
4
-
5
- protected $_data = array();
6
-
7
- public function __construct() {
8
- parent::__construct();
9
-
10
- // not extends Varien_Object
11
- $args = func_get_args();
12
- if (empty($args[0])) {
13
- $args[0] = array();
14
- }
15
- $this->_data = $args[0];
16
- if (isset($this->_data['product'])) {
17
-
18
- $helper = new Bintime_Icecatimport_Helper_Image();
19
- if (isset($this->_data['is_media']) && $this->_data['is_media']){
20
- // add product main image also
21
- // @todo @someday if needed add product image also
22
- }
23
- $gallery = $helper->getGallery();
24
- foreach ($gallery as $item) {
25
- $this->addItem($this->convertIcecatImageToVarienObject($item));
26
- }
27
-
28
- }
29
- }
30
-
31
- private function convertIcecatImageToVarienObject($image) {
32
- $data = array(
33
- // 'id'=>$image['product_picture_id'],
34
- // 'value_id'=>$image['product_picture_id'],
35
- 'file'=>$image['pic'],
36
- 'thumb'=>$image['thumb']
37
- );
38
- $item = new Varien_Object();
39
- $item->addData($data);
40
- return $item;
41
- }
42
-
43
- }
44
-
45
- ?>
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
app/code/local/Bintime/Icecatimport/Model/Import.php DELETED
@@ -1,573 +0,0 @@
1
- <?php
2
- /**
3
- * Class performs Curl request to ICEcat and fetches xml data with product description
4
- * @author Sergey Gozhedrianov <info@bintime.com>
5
- *
6
- */
7
- class Bintime_Icecatimport_Model_Import extends Mage_Core_Model_Abstract {
8
-
9
- public $entityId;
10
- private $productDescriptionList = array();
11
- private $productDescription;
12
- private $fullProductDescription;
13
- private $lowPicUrl;
14
- private $highPicUrl;
15
- private $errorMessage;
16
- private $galleryPhotos = array();
17
- private $productName;
18
- private $relatedProducts = array();
19
- private $thumb;
20
- private $errorSystemMessage; //depricated
21
- private $_cacheKey = 'bintime_icecatimport_';
22
-
23
- private $_warrantyInfo = '';
24
- private $_shortSummaryDesc = '';
25
- private $_longSummaryDesc = '';
26
-
27
- private $_manualPdfUrl = '';
28
- private $_pdfUrl = '';
29
- private $_multimedia = '';
30
-
31
- protected function _construct() {
32
- $this->_init('icecatimport/import');
33
- }
34
-
35
- /**
36
- * Perform Curl request with corresponding param check and error processing
37
- * @param int $productId
38
- * @param string $vendorName
39
- * @param string $locale
40
- * @param string $userName
41
- * @param string $userPass
42
- */
43
- public function getProductDescription($productId, $vendorName, $locale, $userName, $userPass, $entityId, $ean_code){
44
-
45
- $this->entityId = $entityId;
46
- $error = '';
47
- if (null === $this->simpleDoc) {
48
-
49
- if (true || (!$cacheDataXml = Mage::app()->getCache()->load($this->_cacheKey . $entityId . '_' . $locale))) {
50
-
51
- $dataUrl = 'http://data.icecat.biz/xml_s3/xml_server3.cgi';
52
- $successRespondByMPNVendorFlag = false;
53
- if ( empty($userName)) {
54
- $this->errorMessage = "No ICEcat login provided";
55
- return false;
56
- }
57
- if (empty($userPass)){
58
- $this->errorMessage = "No ICEcat password provided";
59
- return false;
60
- }
61
- if (empty($locale)) {
62
- $this->errorMessage = "Please specify product description locale";
63
- return false;
64
- }
65
- if ((empty($productId) && empty($ean_code))
66
- || (empty($vendorName) && empty($ean_code))) {
67
- $this->errorMessage = 'Given product has invalid IceCat data';
68
- return false;
69
- }
70
-
71
- if (!empty($productId) && !empty($vendorName)) {
72
-
73
- $resultString = $this->_getIceCatData($userName, $userPass, $dataUrl, array(
74
- "prod_id" => $productId,
75
- "lang" => $locale,
76
- "vendor" => $vendorName,
77
- "output" => 'productxml'
78
- ));
79
-
80
- if ($this->parseXml($resultString)) {
81
- if (!$this->checkIcecatResponse()) {
82
- $successRespondByMPNVendorFlag = true;
83
- }
84
- }
85
- }
86
-
87
- // if get data by MPN & brand name wrong => trying by Ean code
88
- if (!$successRespondByMPNVendorFlag) {
89
- if (!empty($ean_code)) {
90
- $resultString = $this->_getIceCatData($userName, $userPass, $dataUrl, array(
91
- 'ean_upc' => trim($ean_code),
92
- 'lang' => $locale,
93
- 'output' => 'productxml'
94
- ));
95
-
96
-
97
- if (!$this->parseXml($resultString)) {
98
- $error = true;
99
- $this->simpleDoc = null;
100
- }
101
- if ($this->checkIcecatResponse()) {
102
- $error = true;
103
- $this->simpleDoc = null;
104
- }
105
- } else {
106
- $error = true;
107
- }
108
- if ($error) {
109
- $this->errorMessage = 'Given product has invalid IceCat data';
110
- return false;
111
- }
112
- }
113
- Mage::app()->getCache()->save($resultString, $this->_cacheKey . $entityId . '_' . $locale);
114
- } else {
115
- $resultString = $cacheDataXml;
116
-
117
- if (!$this->parseXml($resultString)){
118
- return false;
119
- }
120
- if ($this->checkIcecatResponse()){
121
- return false;
122
- }
123
- }
124
-
125
- $this->loadProductDescriptionList();
126
- $this->loadOtherProductParams($productId);
127
- $this->loadGalleryPhotos();
128
- Varien_Profiler::start('Bintime FILE RELATED');
129
- $this->loadRelatedProducts();
130
- Varien_Profiler::stop('Bintime FILE RELATED');
131
-
132
- }
133
- return true;
134
- }
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);
142
- $webClient->setHeaders('Content-Type: text/xml; charset=UTF-8');
143
- $webClient->setParameterGet($productAttributes);
144
- $webClient->setAuth($userName, $userPass, Zend_Http_CLient::AUTH_BASIC);
145
- $response = $webClient->request();
146
- if ($response->isError()){
147
- $this->errorMessage = 'Response Status: '.$response->getStatus()." Response Message: ".$response->getMessage();
148
- return false;
149
- }
150
- } catch (Exception $e) {
151
- $this->errorMessage = "Warning: cannot connect to ICEcat. {$e->getMessage()}";
152
- return false;
153
- }
154
- return $response->getBody();
155
- }
156
-
157
- public function getSystemError(){
158
- return $this->errorSystemMessage;
159
- }
160
-
161
- public function getProductName(){
162
- return $this->productName;
163
- }
164
-
165
- public function getGalleryPhotos(){
166
- return $this->galleryPhotos;
167
- }
168
-
169
- public function getThumbPicture(){
170
- return $this->thumb;
171
- }
172
-
173
- public function getImg($productId) {
174
- $model = Mage::getModel('catalog/product');
175
- $_product = $model->load($productId);
176
- $entity_id = $_product->getEntityId();
177
- $ean_code = $_product->getData(Mage::getStoreConfig('icecat_root/icecat/ean_code'));
178
- $vendorName = $_product->getData(Mage::getStoreConfig('icecat_root/icecat/manufacturer'));
179
- $locale = Mage::getStoreConfig('icecat_root/icecat/language');
180
- if ($locale == '0'){
181
- $systemLocale = explode("_", Mage::app()->getLocale()->getLocaleCode());
182
- $locale = $systemLocale[0];
183
- }
184
- $userLogin = Mage::getStoreConfig('icecat_root/icecat/login');
185
- $userPass = Mage::getStoreConfig('icecat_root/icecat/password');
186
- $mpn = $_product->getData(Mage::getStoreConfig('icecat_root/icecat/sku_field'));
187
- $this->getProductDescription($mpn, $vendorName, $locale, $userLogin, $userPass, $entity_id, $ean_code);
188
- if ($this->simpleDoc) {
189
- return $this->highPicUrl;
190
- }
191
- }
192
-
193
- /**
194
- * load Gallery array from XML
195
- */
196
- private function loadGalleryPhotos(){
197
- $galleryPhotos = $this->simpleDoc->Product->ProductGallery->ProductPicture;
198
- if (!count($galleryPhotos)){
199
- return false;
200
- }
201
- foreach($galleryPhotos as $photo) {
202
- if ($photo["Size"] > 0) {
203
- $picUrl = (string)$photo["Pic"];
204
- if (!empty($picUrl) && strpos($picUrl,'feature_logo') <= 0) {
205
- $picHeight = (int)$photo["PicHeight"];
206
- $picWidth = (int)$photo["PicWidth"];
207
- $thumbUrl = (string)$photo["ThumbPic"];
208
-
209
-
210
- array_push($this->galleryPhotos, array(
211
- 'height' => $picHeight,
212
- 'width' => $picWidth,
213
- 'thumb' => $thumbUrl,
214
- 'pic' => $picUrl
215
- ));
216
- }
217
- }
218
- }
219
- }
220
-
221
- public function getErrorMessage(){
222
- return $this->errorMessage;
223
- }
224
-
225
- /**
226
- * Checks response XML for error messages
227
- */
228
- private function checkIcecatResponse(){
229
- $errorMessage = $this->simpleDoc->Product['ErrorMessage'];
230
- if ($errorMessage != ''){
231
- if (preg_match('/^No xml data/', $errorMessage)){
232
- $this->errorSystemMessage = $errorMessage;
233
- return true;
234
- }
235
- if (preg_match('/^The specified vendor does not exist$/', $errorMessage)) {
236
- $this->errorSystemMessage = $errorMessage;
237
- return true;
238
- }
239
- $this->errorMessage = "Ice Cat Error: ".$errorMessage;
240
- return true;
241
- }
242
- return false;
243
- }
244
-
245
- public function getProductDescriptionList(){
246
- return $this->productDescriptionList;
247
- }
248
-
249
- public function getShortProductDescription(){
250
- return $this->productDescription;
251
- }
252
-
253
- public function getFullProductDescription(){
254
- return $this->fullProductDescription;
255
- }
256
-
257
- public function getLowPicUrl(){
258
- return $this->highPicUrl;
259
- }
260
-
261
- public function getRelatedProducts(){
262
- return $this->relatedProducts;
263
- }
264
-
265
- public function getVendor(){
266
- return $this->vendor;
267
- }
268
-
269
- public function getMPN(){
270
- return $this->productId;
271
- }
272
-
273
- public function getEAN(){
274
- return $this->EAN;
275
- }
276
-
277
- public function getWarrantyInfo(){
278
- return $this->_warrantyInfo;
279
- }
280
-
281
- public function getShortSummaryDescription(){
282
- return $this->_shortSummaryDesc;
283
- }
284
-
285
- public function getLongSummaryDescription(){
286
- return $this->_longSummaryDesc;
287
- }
288
-
289
- public function getManualPDF(){
290
- return $this->_manualPdfUrl;
291
- }
292
-
293
- public function getPDF(){
294
- return $this->_pdfUrl;
295
- }
296
-
297
- public function getIceCatMedia(){
298
- return $this->_multimedia;
299
- }
300
-
301
- /**
302
- * Form related products Array
303
- */
304
- private function loadRelatedProducts(){
305
- $relatedProductsArray = $this->simpleDoc->Product->ProductRelated;
306
- if (count($relatedProductsArray)){
307
- foreach($relatedProductsArray as $product){
308
- $productArray = array();
309
- $productNS = $product->Product;
310
- $productArray['name'] = (string)$productNS['Name'];
311
- $productArray['thumb'] = (string)$productNS['ThumbPic'];
312
- $mpn = (string)$productNS['Prod_id'];
313
- $productSupplier = $productNS->Supplier;
314
- $productSupplierId = (int)$productSupplier['ID'];
315
- $productArray['supplier_thumb'] = 'http://images2.icecat.biz/thumbs/SUP'.$productSupplierId.'.jpg';
316
- $productArray['supplier_name'] = (string)$productSupplier['Name'];
317
- $this->relatedProducts[$mpn] = $productArray;
318
- }
319
- }
320
- }
321
-
322
- /**
323
- * Form product feature Arrray
324
- */
325
- private function loadProductDescriptionList(){
326
- $descriptionArray = array();
327
- $specGroups = $this->simpleDoc->Product->CategoryFeatureGroup;
328
- $specFeatures = $this->simpleDoc->Product->ProductFeature;
329
- foreach($specFeatures as $feature){
330
- $id = (int)$feature['CategoryFeatureGroup_ID'];
331
- $featureText = (string)$feature["Presentation_Value"];
332
- $featureValue = (string)$feature["Value"];
333
- $featureName = (string)$feature->Feature->Name["Value"];
334
- if ($featureValue == 'Y' || $featureValue == 'N') {
335
- $featureText = $featureValue;
336
- }
337
- foreach($specGroups as $group){
338
- $groupId = (int)$group["ID"];
339
- if ($groupId == $id){
340
- $groupName = (string) $group->FeatureGroup->Name["Value"];
341
- $rating = (int)$group['No'];
342
- $descriptionArray[$rating][$groupName][$featureName] = $featureText;
343
- break;
344
- }
345
- }
346
- }
347
- krsort($descriptionArray);
348
- $this->productDescriptionList = $descriptionArray;
349
- }
350
-
351
- /**
352
- * Form Array of non feature-value product params
353
- */
354
- private function loadOtherProductParams($productId){
355
- $productTag = $this->simpleDoc->Product;
356
- $this->productDescription = (string)$productTag->ProductDescription['ShortDesc'];
357
- $this->fullProductDescription = (string)$productTag->ProductDescription['LongDesc'];
358
- $this->_warrantyInfo = (string)$productTag->ProductDescription['WarrantyInfo'];
359
- $this->_shortSummaryDesc = (string)$productTag->SummaryDescription->ShortSummaryDescription;
360
- $this->_longSummaryDesc = (string)$productTag->SummaryDescription->LongSummaryDescription;
361
- $this->_manualPdfUrl = (string)$productTag->ProductDescription['ManualPDFURL'];
362
- $this->_pdfUrl = (string)$productTag->ProductDescription['PDFURL'];
363
- $this->_multimedia = $productTag->ProductMultimediaObject->MultimediaObject;
364
-
365
- $Imagepriority = Mage::getStoreConfig('icecat_root/icecat/image_priority');
366
- if ($Imagepriority != 'Db') {
367
- if (!empty($productTag["HighPic"])) {
368
- $this->highPicUrl = $this->saveImg($this->entityId,(string)$productTag["HighPic"]);
369
- } else if (!empty($productTag["LowPic"])) {
370
- $this->lowPicUrl = $this->saveImg($this->entityId,(string)$productTag["LowPic"],'small');
371
- } else {
372
- $this->thumb = $this->saveImg($this->entityId,(string)$productTag["ThumbPic"],'thumb');
373
- }
374
- }
375
- $this->productName = (string)$productTag["Title"];
376
- $this->productId = (string)$productTag['Prod_id'];
377
- $this->vendor = (string)$productTag->Supplier['Name'];
378
- $prodEAN = $productTag->EANCode;
379
- $EANstr = '';
380
- $EANarr = null;
381
- $j = 0;//counter
382
- foreach($prodEAN as $ellEAN){
383
- $EANarr[]=$ellEAN['EAN'];$j++;
384
- }
385
- $i = 0;
386
- $str = '';
387
- for ($i=0;$i<$j;$i++) {
388
- $g = $i%2;
389
- if ($g == '0') {
390
- if($j == 1){
391
- $str .= $EANarr[$i].'<br>';
392
- } else {$str .= $EANarr[$i].', ';}
393
- } else {if($i != $j-1){$str .= $EANarr[$i].', <br>';}else {$str .= $EANarr[$i].' <br>';}}
394
- }
395
- $this->EAN = $str;
396
- }
397
-
398
- /**
399
- * parse response XML: to SimpleXml
400
- * @param string $stringXml
401
- */
402
- private function parseXml($stringXml){
403
- libxml_use_internal_errors(true);
404
- $this->simpleDoc = simplexml_load_string($stringXml);
405
- if ($this->simpleDoc){
406
- return true;
407
- }
408
- $this->simpleDoc = simplexml_load_string(utf8_encode($stringXml));
409
- if ($this->simpleDoc){
410
- return true;
411
- }
412
- return false;
413
- }
414
-
415
- /**
416
- * save icecat img
417
- * @param int $productId
418
- * @param string $img_url
419
- * @param string $img_type
420
- */
421
- public function saveImg($productId,$img_url,$imgtype = '') {
422
-
423
- $pathinfo = pathinfo($img_url);
424
- $img_type= $pathinfo["extension"];
425
-
426
- if (strpos($img_url,'high') > 0) {
427
- $img_name = str_replace("http://images.icecat.biz/img/norm/high/","",$img_url);
428
- $img_name = md5($img_name);
429
- } else if (strpos($img_url,'low') > 0) {
430
- $img_name = str_replace("http://images.icecat.biz/img/norm/low/","",$img_url);
431
- $img_name = md5($img_name);
432
- } else {
433
- $img_name = md5($img_url);
434
- }
435
-
436
- $img = $img_name.".".$img_type;
437
- $baseDir = Mage::getSingleton('catalog/product_media_config')->getBaseMediaPath().'/';
438
- $local_img = strstr($img_url,Mage::getStoreConfig('web/unsecure/base_url'));
439
-
440
- if (!file_exists($baseDir.$img) && !$local_img) {
441
- $client = new Zend_Http_Client($img_url);
442
- $content=$client->request();
443
- if ($content->isError()) {
444
- return $img_url;
445
- }
446
- $file = file_put_contents($baseDir.$img,$content->getBody());
447
- if ($file) {
448
- $this->addProductImageQuery($productId,$img,$imgtype);
449
- return $img;
450
- } else {
451
- return $img_url;
452
- }
453
- } else if($local_img) {
454
- return $img_url;
455
- } else {
456
-
457
- $db = Mage::getSingleton('core/resource')->getConnection('core_write');
458
- $tablePrefix = (array)Mage::getConfig()->getTablePrefix();
459
- if (!empty($tablePrefix[0])) {
460
- $tablePrefix = $tablePrefix[0];
461
- } else {
462
- $tablePrefix = '';
463
- }
464
- $attr_query = "SELECT @product_entity_type_id := `entity_type_id` FROM `" .$tablePrefix . "eav_entity_type` WHERE
465
- entity_type_code = 'catalog_product';
466
- SELECT @attribute_set_id := `entity_type_id` FROM `" . $tablePrefix . "eav_entity_type` WHERE
467
- entity_type_code = 'catalog_product';
468
- SELECT @gallery := `attribute_id` FROM `" . $tablePrefix . "eav_attribute` WHERE
469
- `attribute_code` = 'media_gallery' AND entity_type_id = @product_entity_type_id;
470
- SELECT @base := `attribute_id` FROM `" . $tablePrefix . "eav_attribute` WHERE `attribute_code` = 'image' AND entity_type_id = @product_entity_type_id;
471
- SELECT @small := `attribute_id` FROM `" . $tablePrefix . "eav_attribute` WHERE
472
- `attribute_code` = 'small_image' AND entity_type_id = @product_entity_type_id;
473
- SELECT @thumb := `attribute_id` FROM `" . $tablePrefix . "eav_attribute` WHERE
474
- `attribute_code` = 'thumbnail' AND entity_type_id = @product_entity_type_id;";
475
-
476
- $attr_set = Mage::getModel('catalog/product')->getResource()->getEntityType()->getDefaultAttributeSetId();
477
-
478
- $db->query($attr_query, array(':attribute_set' => $attr_set));
479
-
480
- $img_check = $db->fetchAll("SELECT COUNT(*) FROM `" .$tablePrefix . "catalog_product_entity_varchar`
481
- WHERE attribute_id IN (@base ,@small,@thumb)
482
- AND entity_id =:entity_id AND value =:img ",array(
483
- ':entity_id' => $productId,
484
- ':img' => $img));
485
-
486
- $gal_check = $db->fetchAll("SELECT COUNT(*) FROM `" .$tablePrefix . "catalog_product_entity_media_gallery`
487
- WHERE attribute_id = @gallery AND entity_id =:entity_id AND value =:img ",array(
488
- ':entity_id' => $productId,
489
- ':img' => $img));
490
- if ((isset($img_check[0]["COUNT(*)"]) && isset($gal_check[0]["COUNT(*)"]))
491
- && ($img_check[0]["COUNT(*)"] == 0 && $gal_check[0]["COUNT(*)"] == 0)) {
492
- $this->addProductImageQuery($productId,$img,$imgtype);
493
- }
494
- return $img;
495
- }
496
- }
497
-
498
- public function addProductImageQuery($productId,$img,$type = '') {
499
- $db = Mage::getSingleton('core/resource')->getConnection('core_write');
500
- $tablePrefix = (array)Mage::getConfig()->getTablePrefix();
501
- if (!empty($tablePrefix[0])) {
502
- $tablePrefix = $tablePrefix[0];
503
- } else {
504
- $tablePrefix = '';
505
- }
506
-
507
- $attr_query = "SELECT @product_entity_type_id := `entity_type_id` FROM `" .$tablePrefix . "eav_entity_type` WHERE
508
- entity_type_code = 'catalog_product';
509
- SELECT @attribute_set_id := `entity_type_id` FROM `" . $tablePrefix . "eav_entity_type` WHERE
510
- entity_type_code = 'catalog_product';
511
- SELECT @gallery := `attribute_id` FROM `" . $tablePrefix . "eav_attribute` WHERE
512
- `attribute_code` = 'media_gallery' AND entity_type_id = @product_entity_type_id;
513
- SELECT @base := `attribute_id` FROM `" . $tablePrefix . "eav_attribute` WHERE `attribute_code` = 'image' AND entity_type_id = @product_entity_type_id;
514
- SELECT @small := `attribute_id` FROM `" . $tablePrefix . "eav_attribute` WHERE
515
- `attribute_code` = 'small_image' AND entity_type_id = @product_entity_type_id;
516
- SELECT @thumb := `attribute_id` FROM `" . $tablePrefix . "eav_attribute` WHERE
517
- `attribute_code` = 'thumbnail' AND entity_type_id = @product_entity_type_id;";
518
-
519
- $db->query($attr_query, array(':attribute_set' => Mage::getModel('catalog/product')->getResource()->getEntityType()->getDefaultAttributeSetId() ));
520
-
521
- $DefaultStoreId = Mage::app()->getWebsite()->getDefaultGroup()->getDefaultStoreId();
522
-
523
- if (empty($type) || $type == 'image') {
524
-
525
- $db->query(" INSERT INTO `" .$tablePrefix . "catalog_product_entity_varchar`
526
- (entity_type_id,attribute_id,store_id,entity_id,value)
527
- VALUES(@product_entity_type_id,@base,:store_id,:entity_id,:img )
528
- ON DUPLICATE KEY UPDATE value = :img",array(
529
- ':store_id' => $DefaultStoreId,
530
- ':entity_id' => $productId,
531
- ':img' => $img));
532
-
533
- $db->query(" INSERT INTO `" .$tablePrefix . "catalog_product_entity_varchar`
534
- (entity_type_id,attribute_id,store_id,entity_id,value)
535
- VALUES(@product_entity_type_id,@small,:store_id,:entity_id,:img )
536
- ON DUPLICATE KEY UPDATE value = :img",array(
537
- ':store_id' => $DefaultStoreId,
538
- ':entity_id' => $productId,
539
- ':img' => $img));
540
-
541
- $db->query(" INSERT INTO `" .$tablePrefix . "catalog_product_entity_varchar`
542
- (entity_type_id,attribute_id,store_id,entity_id,value)
543
- VALUES(@product_entity_type_id,@thumb,:store_id,:entity_id,:img )
544
- ON DUPLICATE KEY UPDATE value = :img",array(
545
- ':store_id' => $DefaultStoreId,
546
- ':entity_id' => $productId,
547
- ':img' => $img));
548
- }
549
-
550
-
551
-
552
- $db->query(" INSERT INTO `" .$tablePrefix . "catalog_product_entity_media_gallery` (attribute_id,entity_id,value)
553
- VALUES(@gallery,:entity_id,:img )",array(
554
- ':entity_id' => $productId,
555
- ':img' => $img ));
556
-
557
- $db->query(" INSERT INTO `" .$tablePrefix . "catalog_product_entity_media_gallery_value`
558
- (value_id,store_id,label,position,disabled)
559
- VALUES(LAST_INSERT_ID(),:store_id,'',1,0 )",array(
560
- ':store_id' => $DefaultStoreId));
561
-
562
- /*$rows = $db->fetchAll("SELECT value_id FROM `" .$tablePrefix . "catalog_product_entity_media_gallery`
563
- WHERE attribute_id = @gallery AND entity_id =:entity_id ",array(
564
- ':entity_id' => $productId));
565
- if (count($rows > 0)) {
566
- echo '<pre>'; var_dump($rows); echo " ============ ";
567
- }*/
568
-
569
- }
570
-
571
- }
572
-
573
- ?>
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
app/code/local/Bintime/Icecatimport/Model/Observer.php DELETED
@@ -1,447 +0,0 @@
1
- <?php
2
- /**
3
- * Class provides category page with images, cron processing
4
- *
5
- * @author Sergey Gozhedrianov <info@bintime.com>
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';
23
- protected $_supplierMappingUrl = 'http://data.icecat.biz/export/freeurls/supplier_mapping.xml';
24
- protected $_connectorDir = '/bintime/icecatimport/';
25
- protected $_productFile;
26
- protected $_supplierFile;
27
-
28
- protected function _construct(){
29
- $this->_init('icecatimport/observer');
30
- }
31
-
32
- /**
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>";
53
- $this->downloadFile($this->_productFile, $loadUrl);
54
-
55
- echo "Start of supplier mapping file download<br>";
56
- $this->downloadFile($this->_supplierFile, $this->_supplierMappingUrl);
57
- $this->XMLfile = Mage::getBaseDir('var') . $this->_connectorDir . basename($loadUrl, ".gz");
58
-
59
- echo "Start Unzipping Data File<br>";
60
- $this->unzipFile();
61
- echo "Start File Processing<br>";
62
-
63
- $this->_loadSupplierListToDb();
64
- $this->loadFileToDb();
65
- echo "File Processed Succesfully<br>";
66
-
67
- //Start load product data file
68
- $loadUrl = $this->productinfoUrL;
69
- $this->_productFile = $this->_prepareFile(basename($loadUrl));
70
- echo " Product Data file downloading started <br>";
71
- $this->downloadFile($this->_productFile, $loadUrl);
72
- echo "Start Unzipping Data File<br>";
73
- $this->unzipFile();
74
- echo "Start File Processing<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());
82
- }
83
- }
84
-
85
- /**
86
- * parse given XML to SIMPLE XML
87
- * @param string $stringXml
88
- */
89
- protected function _parseXml($stringXml){
90
- libxml_use_internal_errors(true);
91
- $simpleDoc = simplexml_load_string($stringXml);
92
- if ($simpleDoc){
93
- return $simpleDoc;
94
- }
95
- $simpleDoc = simplexml_load_string(utf8_encode($stringXml));
96
- if ($simpleDoc){
97
- return $simpleDoc;
98
- }
99
- return false;
100
- }
101
-
102
- /**
103
- * Upload supplier mapping list to Database
104
- */
105
- protected function _loadSupplierListToDb(){
106
- $connection = $this->getDbConnection();
107
- $mappingTable = Mage::getSingleton('core/resource')->getTableName('icecatimport/supplier_mapping');
108
- try {
109
- $connection->beginTransaction();
110
- $xmlString = file_get_contents($this->_supplierFile);
111
- $xmlDoc = $this->_parseXml($xmlString);
112
- if ($xmlDoc) {
113
- $connection->query("DROP TABLE IF EXISTS `".$mappingTable."_temp`");
114
- $connection->query("
115
- CREATE TABLE `".$mappingTable."_temp` (
116
- `supplier_id` int(11) NOT NULL,
117
- `supplier_symbol` varchar(255) DEFAULT NULL,
118
- KEY `supplier_id` (`supplier_id`)
119
- ) ENGINE=InnoDB DEFAULT CHARSET=utf8
120
- ");
121
-
122
- $supplierList = $xmlDoc->SupplierMappings->SupplierMapping;
123
- foreach ($supplierList as $supplier) {
124
- $supplierSymbolList = $supplier->Symbol;
125
- $supplierId = $supplier['supplier_id'];
126
- $connection->insert($mappingTable."_temp", array('supplier_id' => $supplierId, 'supplier_symbol' => (string)$supplier['name']));
127
- foreach($supplierSymbolList as $symbol) {
128
- $symbolName = (string)$symbol;
129
- $connection->insert($mappingTable."_temp", array('supplier_id' => $supplierId, 'supplier_symbol' => $symbolName));
130
- }
131
- }
132
-
133
- $connection->query("DROP TABLE IF EXISTS `".$mappingTable."_old`");
134
- $connection->query("rename table `".$mappingTable."` to `".$mappingTable."_old`, `".$mappingTable."_temp` to ".$mappingTable);
135
- $connection->commit();
136
- } else {
137
- throw new Exception('Unable to process supplier file');
138
- }
139
- } catch (Exception $e) {
140
- $connection->rollBack();
141
- throw new Exception("Icecat Import Terminated: {$e->getMessage()}");
142
- }
143
- }
144
-
145
- /**
146
- * retrieve URL of data file that corresponds ICEcat account
147
- */
148
- private function getLoadURL(){
149
- $subscripionLevel = Mage::getStoreConfig('icecat_root/icecat/icecat_type');
150
-
151
- if ($subscripionLevel === 'full'){
152
- return $this->fullExportURLs;
153
- }
154
- else {
155
- return $this->freeExportURLs;
156
- }
157
- }
158
-
159
- /**
160
- * return error messages
161
- */
162
- public function getErrorMessage(){
163
- return $this->errorMessage;
164
- }
165
-
166
- /**
167
- * getImage URL from DB
168
- * @param string $productSku
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');
177
- $mappingTable = Mage::getSingleton('core/resource')->getTableName('icecatimport/supplier_mapping');
178
- $model = Mage::getModel('catalog/product');
179
- $_product = $model->load($productId);
180
- $ean_code = $_product->getData(Mage::getStoreConfig('icecat_root/icecat/ean_code'));
181
- $imageURL = '';
182
-
183
- if (isset($productManufacturer) && !empty($productManufacturer)) {
184
- $selectCondition = $connection->select()
185
- ->from(array('connector' => $tableName), new Zend_Db_Expr('connector.prod_img'))
186
- ->joinInner(array('supplier' => $mappingTable), "connector.supplier_id = supplier.supplier_id AND supplier.supplier_symbol = {$this->connection->quote($productManufacturer)}")
187
- ->where('connector.prod_id = ?', $productSku);
188
- $imageURL = $connection->fetchOne($selectCondition);
189
- }
190
- if (empty($imageURL) && !empty($ean_code)) {
191
- $selectCondition = $connection->select()
192
- ->from(array('connector' => $tableName), new Zend_Db_Expr('connector.prod_img'))
193
- ->joinLeft(array('products' => $tableName.'_products'), "connector.prod_id = products.prod_id")
194
- ->where('products.prod_ean = ?', trim($ean_code));
195
- $imageURL = $connection->fetchOne($selectCondition);
196
- }
197
-
198
- if (!empty($imageURL)) {
199
- $iceCatModel = Mage::getSingleton('icecatimport/import');
200
-
201
- if(isset($productId) && !empty($productId)) {
202
- $imageURL = $iceCatModel->saveImg($productId,$imageURL);
203
- }
204
- }
205
-
206
- if (empty($imageURL)){
207
- $this->errorMessage = "Given product id is not present in database";
208
- return $imageURL;
209
- }
210
- return $imageURL;
211
- } catch (Exception $e) {
212
- $this->errorMessage = "DB ERROR: {$e->getMessage()}";
213
- return false;
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
- */
240
- private function getDbConnection(){
241
- if ($this->connection){
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
- }
324
- } else if ($is_info_file && $oneLine[0]!= 'Part number') {
325
- try{
326
- $oneLine3 = trim($oneLine[3]);
327
- $oneLine12 = trim($oneLine[12]);
328
- $oneLine21 = trim($oneLine[21]);
329
- $oneLine15 = trim($oneLine[15]);
330
- if (!empty($oneLine15)) {
331
- $prod_ean = $oneLine15;
332
- $eans = explode(';',$oneLine15);
333
- if (is_array($eans) && count($eans) > 0 && array_key_exists(0,$eans)) {
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
- }
376
-
377
- /**
378
- * unzip Uploaded file
379
- */
380
- private function unzipFile(){
381
- $gz = gzopen ( $this->_productFile, 'rb' );
382
- if (file_exists($this->XMLfile)){
383
- unlink($this->XMLfile);
384
- }
385
- $fileToWrite = @fopen($this->XMLfile, 'w+');
386
- if (!$fileToWrite){
387
- $this->errorMessage = 'Unable to open output txt file. Please remove all *.txt files from '.
388
- Mage::getBaseDir('var'). $this->_connectorDir .'folder';
389
- return false;
390
- }
391
- while (!gzeof($gz)) {
392
- $buffer = gzgets($gz, 100000);
393
- fputs($fileToWrite, $buffer) ;
394
- }
395
- gzclose ($gz);
396
- fclose($fileToWrite);
397
- }
398
-
399
- /**
400
- * Process downloading files
401
- * @param string $destinationFile
402
- * @param string $loadUrl
403
- */
404
- private function downloadFile($destinationFile, $loadUrl){
405
- $userName = Mage::getStoreConfig('icecat_root/icecat/login');
406
- $userPass = Mage::getStoreConfig('icecat_root/icecat/password');
407
- $fileToWrite = @fopen($destinationFile, 'w+');
408
-
409
- try{
410
- $webClient = new Zend_Http_Client();
411
- $webClient->setUri($loadUrl);
412
- $webClient->setConfig(array('maxredirects' => 0, 'timeout' => 60));
413
- $webClient->setMethod(Zend_Http_Client::GET);
414
- $webClient->setHeaders('Content-Type: text/xml; charset=UTF-8');
415
- $webClient->setAuth($userName, $userPass, Zend_Http_CLient::AUTH_BASIC);
416
- $response = $webClient->request('GET');
417
- if ($response->isError()){
418
- throw new Exception('<br>ERROR Occured.<br>Response Status: '.$response->getStatus()."<br>Response Message: ".$response->getMessage().
419
- "<br>Please, make sure that you added correct icecat username and password to <strong>Icecat Live!</strong> configuration <br>
420
- and you have your webshop's correct IP in <strong>Allowed IP addresses</strong> field in your icecat account.");
421
- }
422
- }
423
- catch (Exception $e) {
424
- throw new Exception("Warning: cannot connect to ICEcat. {$e->getMessage()}");
425
- }
426
- $resultString = $response->getBody();
427
- fwrite($fileToWrite, $resultString);
428
- fclose($fileToWrite);
429
- }
430
-
431
- /**
432
- * Prepares file and folder for futur download
433
- * @param string $fileName
434
- */
435
- protected function _prepareFile($fileName){
436
- $varDir = Mage::getBaseDir('var') . $this->_connectorDir;
437
- $filePath = $varDir . $fileName;
438
- if (!is_dir($varDir)){
439
- mkdir($varDir, 0777, true);
440
- }
441
- if (file_exists($filePath)){
442
- unlink($filePath);
443
- }
444
- return $filePath;
445
- }
446
- }
447
- ?>
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
app/code/local/Bintime/Icecatimport/Model/Output.php DELETED
@@ -1,160 +0,0 @@
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
- ?>
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
app/code/local/Bintime/Icecatimport/Model/Relatedcollection.php DELETED
@@ -1,71 +0,0 @@
1
- <?php
2
- class Bintime_Icecatimport_Model_Relatedcollection extends Varien_Data_Collection {
3
-
4
- protected $_data = array();
5
- protected $_collection;
6
-
7
- public function __construct() {
8
- parent::__construct();
9
-
10
- // not extends Varien_Object
11
- $args = func_get_args();
12
- if (empty($args[0])) {
13
- $args[0] = array();
14
- }
15
- $this->_data = $args[0];
16
- }
17
- public function getCollection()
18
- {
19
- $sku = Mage::getStoreConfig('icecat_root/icecat/sku_field');
20
- $model = Mage::getModel('catalog/product');
21
- $collection = $model->getCollection();
22
-
23
- $filterArray = array();
24
- $rel = array();
25
- foreach($this->_data as $res)
26
- {
27
- foreach($res as $r)
28
- {
29
- $rel[] = $r;
30
- }
31
- }
32
- foreach($rel as $item){
33
- array_push($filterArray, array('attribute' => $sku,'eq' => $item['mpn']));
34
- }
35
- $collection->addFieldToFilter($filterArray);
36
-
37
- $collection->joinField('is_in_stock',
38
- 'cataloginventory/stock_item',
39
- 'is_in_stock',
40
- 'product_id=entity_id',
41
- 'is_in_stock=1',
42
- '{{table}}.stock_id=1',
43
- 'left');
44
-
45
- $myCollection = clone $collection;
46
- $relCnt = count($rel);
47
- foreach($myCollection as &$col)
48
- {
49
- $model->load($col->getId());
50
- $price = $model->getPrice();
51
- $mpn = $col->getData($sku);
52
- $specialPrice = $model->getSpecialPrice();
53
-
54
- for($i = 0; $i<$relCnt; $i++)
55
- {
56
- if($rel[$i]['mpn'] == $mpn)
57
- {
58
- $col->setData('name', $rel[$i]['name']);
59
- $col->setData('thumbnail', $rel[$i]['thumb']);
60
- $col->setData('status', Mage_Catalog_Model_Product_Status::STATUS_ENABLED);
61
- $col->setData('price', $price);
62
- $col->setData('special_price', $specialPrice);
63
- }
64
- }
65
- }
66
- return $myCollection;
67
-
68
- }
69
- }
70
-
71
- ?>
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
app/code/local/Bintime/Icecatimport/Model/System/Config/Attributes.php DELETED
@@ -1,21 +0,0 @@
1
- <?php
2
- /**
3
- * Class Provides product Attributes for BO menu
4
- * @author Sergey Gozhedrianov <info@bintime.com>
5
- *
6
- */
7
- class Bintime_Icecatimport_Model_System_Config_Attributes
8
- {
9
- public function toOptionArray()
10
- {
11
- $attributesArray = Mage::getResourceModel('eav/entity_attribute_collection')
12
- ->setAttributeSetFilter(Mage::getResourceSingleton('catalog/product')->getEntityType()->getDefaultAttributeSetId());
13
- $outputAttributeArray = array();
14
- foreach($attributesArray as $attribute){
15
- $outputAttributeArray[$attribute['attribute_code']]=$attribute['attribute_code'];
16
- }
17
- ksort($outputAttributeArray);
18
- return $outputAttributeArray;
19
- }
20
- }
21
- ?>
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
app/code/local/Bintime/Icecatimport/Model/System/Config/Descriptionpriority.php DELETED
@@ -1,13 +0,0 @@
1
- <?php
2
- class Bintime_Icecatimport_Model_System_Config_Descriptionpriority
3
- {
4
- public function toOptionArray()
5
- {
6
- return array(
7
- 'Icecat' => 'From Icecat',
8
- 'Db' => 'From Database'
9
- );
10
-
11
- }
12
- }
13
- ?>
 
 
 
 
 
 
 
 
 
 
 
 
 
app/code/local/Bintime/Icecatimport/Model/System/Config/Imagepriority.php DELETED
@@ -1,13 +0,0 @@
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
- ?>
 
 
 
 
 
 
 
 
 
 
 
 
 
app/code/local/Bintime/Icecatimport/Model/System/Config/LanguageList.xml DELETED
@@ -1,399 +0,0 @@
1
- <?xml version="1.0"?>
2
- <!DOCTYPE ICECAT-interface SYSTEM "http://data.icecat.biz/dtd/ICECAT-interface_response.dtd">
3
- <!-- source: ICEcat.biz 2009 -->
4
- <ICECAT-interface>
5
- <Response ID="50564949" Status="1" Date="Thu Oct 22 04:26:04 2009" Request_ID="1256178364">
6
- <LanguageList>
7
- <Language Code="portuguese" ID="11" ShortCode="PT" Sid="6184">
8
- <Name ID="40191" Value="Portuguese-Portuguese" langid="1"/>
9
- <Name ID="40192" Value="Portuguese-Portuguese" langid="2"/>
10
- <Name ID="40193" Value="Portuguese-Portuguese" langid="3"/>
11
- <Name ID="40194" Value="Portuguese-Portuguese" langid="4"/>
12
- <Name ID="40195" Value="Portuguese-Portuguese" langid="5"/>
13
- <Name ID="40196" Value="Portuguese-Portuguese" langid="6"/>
14
- <Name ID="198032" Value="Португальский-португальский" langid="8"/>
15
- <Name ID="50889" Value="" langid="12"/>
16
- <Name ID="205069" Value="Португальcька-Португалія" langid="25"/>
17
- </Language>
18
- <Language Code="bulgarian" ID="21" ShortCode="BG" Sid="9218">
19
- <Name ID="147616" Value="Bulgarian" langid="1"/>
20
- <Name ID="198042" Value="Болгарский" langid="8"/>
21
- <Name ID="205079" Value="Болгарська" langid="25"/>
22
- </Language>
23
- <Language Code="danish" ID="7" ShortCode="DK" Sid="6058">
24
- <Name ID="39312" Value="Danish" langid="1"/>
25
- <Name ID="39313" Value="Danish" langid="2"/>
26
- <Name ID="39314" Value="Danish" langid="3"/>
27
- <Name ID="39315" Value="Danish" langid="4"/>
28
- <Name ID="39316" Value="Danish" langid="5"/>
29
- <Name ID="39317" Value="Danish" langid="6"/>
30
- <Name ID="39318" Value="Danish" langid="7"/>
31
- <Name ID="198028" Value="Датский" langid="8"/>
32
- <Name ID="40294" Value="Danish" langid="9"/>
33
- <Name ID="40295" Value="Danish" langid="10"/>
34
- <Name ID="40296" Value="Danish" langid="11"/>
35
- <Name ID="40297" Value="Danish" langid="12"/>
36
- <Name ID="40298" Value="Danish" langid="13"/>
37
- <Name ID="40299" Value="Danish" langid="14"/>
38
- <Name ID="40300" Value="Danish" langid="15"/>
39
- <Name ID="40301" Value="Danish" langid="16"/>
40
- <Name ID="40302" Value="Danish" langid="17"/>
41
- <Name ID="205065" Value="Датська" langid="25"/>
42
- </Language>
43
- <Language Code="japanese" ID="26" ShortCode="JA" Sid="9635">
44
- <Name ID="224188" Value="Japanese" langid="1"/>
45
- <Name ID="224189" Value="Japanese" langid="2"/>
46
- <Name ID="224190" Value="Japanese" langid="3"/>
47
- <Name ID="224191" Value="Japanese" langid="4"/>
48
- <Name ID="224192" Value="Japanese" langid="5"/>
49
- <Name ID="224193" Value="Japanese" langid="6"/>
50
- <Name ID="224194" Value="Японский" langid="8"/>
51
- <Name ID="224195" Value="Японська" langid="25"/>
52
- <Name ID="224196" Value="Japanese" langid="26"/>
53
- </Language>
54
- <Language Code="finnish" ID="17" ShortCode="FI" Sid="6190">
55
- <Name ID="40227" Value="Finnish" langid="1"/>
56
- <Name ID="40228" Value="Finnish" langid="2"/>
57
- <Name ID="40229" Value="Finnish" langid="3"/>
58
- <Name ID="40230" Value="Finnish" langid="4"/>
59
- <Name ID="40231" Value="Finnish" langid="5"/>
60
- <Name ID="40232" Value="Finnish" langid="6"/>
61
- <Name ID="198038" Value="Финский" langid="8"/>
62
- <Name ID="50895" Value="" langid="12"/>
63
- <Name ID="205075" Value="Фінська" langid="25"/>
64
- </Language>
65
- <Language Code="dutch" ID="2" ShortCode="NL" Sid="3">
66
- <Name ID="3" Value="Dutch" langid="1"/>
67
- <Name ID="4" Value="Dutch" langid="2"/>
68
- <Name ID="6074" Value="Dutch" langid="3"/>
69
- <Name ID="14099" Value="Dutch" langid="4"/>
70
- <Name ID="18231" Value="Dutch" langid="5"/>
71
- <Name ID="22363" Value="Dutch" langid="6"/>
72
- <Name ID="34054" Value="Hollandsk" langid="7"/>
73
- <Name ID="198023" Value="Голландский" langid="8"/>
74
- <Name ID="40244" Value="Dutch" langid="9"/>
75
- <Name ID="40245" Value="Dutch" langid="10"/>
76
- <Name ID="40246" Value="Dutch" langid="11"/>
77
- <Name ID="40247" Value="Dutch" langid="12"/>
78
- <Name ID="40248" Value="Dutch" langid="13"/>
79
- <Name ID="40249" Value="Dutch" langid="14"/>
80
- <Name ID="40250" Value="Dutch" langid="15"/>
81
- <Name ID="40251" Value="Dutch" langid="16"/>
82
- <Name ID="40252" Value="Dutch" langid="17"/>
83
- <Name ID="205060" Value="Голландська" langid="25"/>
84
- </Language>
85
- <Language Code="georgian" ID="22" ShortCode="KA" Sid="9271">
86
- <Name ID="154954" Value="Georgian" langid="1"/>
87
- <Name ID="198043" Value="Грузинский" langid="8"/>
88
- <Name ID="205080" Value="Грузинська" langid="25"/>
89
- </Language>
90
- <Language Code="english" ID="1" ShortCode="EN" Sid="2">
91
- <Name ID="1" Value="English" langid="1"/>
92
- <Name ID="2" Value="English" langid="2"/>
93
- <Name ID="6073" Value="English" langid="3"/>
94
- <Name ID="14098" Value="English" langid="4"/>
95
- <Name ID="18230" Value="English" langid="5"/>
96
- <Name ID="22362" Value="English" langid="6"/>
97
- <Name ID="34053" Value="Engelsk" langid="7"/>
98
- <Name ID="198022" Value="Английский" langid="8"/>
99
- <Name ID="40234" Value="English" langid="9"/>
100
- <Name ID="40235" Value="English" langid="10"/>
101
- <Name ID="40236" Value="English" langid="11"/>
102
- <Name ID="40237" Value="English" langid="12"/>
103
- <Name ID="40238" Value="English" langid="13"/>
104
- <Name ID="40239" Value="English" langid="14"/>
105
- <Name ID="40240" Value="English" langid="15"/>
106
- <Name ID="40241" Value="English" langid="16"/>
107
- <Name ID="40242" Value="English" langid="17"/>
108
- <Name ID="205059" Value="Англійська" langid="25"/>
109
- </Language>
110
- <Language Code="greek" ID="18" ShortCode="EL" Sid="8587">
111
- <Name ID="113508" Value="Greek" langid="1"/>
112
- <Name ID="113509" Value="Greek" langid="2"/>
113
- <Name ID="113510" Value="Greek" langid="3"/>
114
- <Name ID="113511" Value="Greek" langid="4"/>
115
- <Name ID="113512" Value="Greek" langid="5"/>
116
- <Name ID="113513" Value="Greek" langid="6"/>
117
- <Name ID="198039" Value="Греческий" langid="8"/>
118
- <Name ID="205076" Value="Грецька" langid="25"/>
119
- </Language>
120
- <Language Code="romanian" ID="23" ShortCode="RO" Sid="9390">
121
- <Name ID="169100" Value="Romanian" langid="1"/>
122
- <Name ID="169101" Value="Romanian" langid="2"/>
123
- <Name ID="169102" Value="Romanian" langid="3"/>
124
- <Name ID="169103" Value="Romanian" langid="4"/>
125
- <Name ID="169104" Value="Romanian" langid="5"/>
126
- <Name ID="169105" Value="Romanian" langid="6"/>
127
- <Name ID="198044" Value="Румынский" langid="8"/>
128
- <Name ID="205081" Value="Румунська" langid="25"/>
129
- </Language>
130
- <Language Code="hungarian" ID="16" ShortCode="HU" Sid="6189">
131
- <Name ID="40221" Value="Hungarian" langid="1"/>
132
- <Name ID="40222" Value="Hungarian" langid="2"/>
133
- <Name ID="40223" Value="Hungarian" langid="3"/>
134
- <Name ID="40224" Value="Hungarian" langid="4"/>
135
- <Name ID="40225" Value="Hungarian" langid="5"/>
136
- <Name ID="40226" Value="Hungarian" langid="6"/>
137
- <Name ID="198037" Value="Венгерский" langid="8"/>
138
- <Name ID="50894" Value="" langid="12"/>
139
- <Name ID="205074" Value="Угорська" langid="25"/>
140
- </Language>
141
- <Language Code="swedish" ID="13" ShortCode="SE" Sid="6186">
142
- <Name ID="40203" Value="Swedish" langid="1"/>
143
- <Name ID="40204" Value="Swedish" langid="2"/>
144
- <Name ID="40205" Value="Swedish" langid="3"/>
145
- <Name ID="40206" Value="Swedish" langid="4"/>
146
- <Name ID="40207" Value="Swedish" langid="5"/>
147
- <Name ID="40208" Value="Swedish" langid="6"/>
148
- <Name ID="198034" Value="Шведский" langid="8"/>
149
- <Name ID="50891" Value="" langid="12"/>
150
- <Name ID="205071" Value="Швецька" langid="25"/>
151
- </Language>
152
- <Language Code="croatian" ID="29" ShortCode="HR" Sid="10132">
153
- <Name ID="270273" Value="Croatian" langid="1"/>
154
- <Name ID="270274" Value="Croatian" langid="2"/>
155
- <Name ID="270275" Value="Croatian" langid="3"/>
156
- <Name ID="270276" Value="Croatian" langid="4"/>
157
- <Name ID="270277" Value="Croatian" langid="5"/>
158
- <Name ID="270278" Value="Croatian" langid="6"/>
159
- <Name ID="270280" Value="Hrvatski" langid="29"/>
160
- </Language>
161
- <Language Code="catalan" ID="27" ShortCode="CA" Sid="9662">
162
- <Name ID="231955" Value="Catalan" langid="1"/>
163
- <Name ID="231956" Value="Catalan" langid="2"/>
164
- <Name ID="231957" Value="Catalan" langid="3"/>
165
- <Name ID="231958" Value="Catalan" langid="4"/>
166
- <Name ID="231959" Value="Catalan" langid="5"/>
167
- <Name ID="231960" Value="Catalan" langid="6"/>
168
- <Name ID="231962" Value="Каталанский" langid="8"/>
169
- <Name ID="231963" Value="Каталанська" langid="25"/>
170
- <Name ID="231961" Value="Català" langid="27"/>
171
- </Language>
172
- <Language Code="ukrainian" ID="25" ShortCode="UK" Sid="9577">
173
- <Name ID="198046" Value="Ukrainian" langid="1"/>
174
- <Name ID="198047" Value="Ukrainian" langid="2"/>
175
- <Name ID="198048" Value="Ukrainian" langid="3"/>
176
- <Name ID="198049" Value="Ukrainian" langid="4"/>
177
- <Name ID="198050" Value="Ukrainian" langid="5"/>
178
- <Name ID="198051" Value="Ukrainian" langid="6"/>
179
- <Name ID="198052" Value="Украинский" langid="8"/>
180
- <Name ID="198053" Value="Українська" langid="25"/>
181
- </Language>
182
- <Language Code="spanish" ID="6" ShortCode="ES" Sid="4797">
183
- <Name ID="14094" Value="Spanish" langid="1"/>
184
- <Name ID="14095" Value="Spanish" langid="2"/>
185
- <Name ID="14096" Value="Spanish" langid="3"/>
186
- <Name ID="18228" Value="Spanish" langid="4"/>
187
- <Name ID="106485" Value="Processo di simulazione dell'alba (intensità 0)" langid="5"/>
188
- <Name ID="26492" Value="Spanish" langid="6"/>
189
- <Name ID="38094" Value="Spansk" langid="7"/>
190
- <Name ID="198027" Value="Испанский" langid="8"/>
191
- <Name ID="40284" Value="Spanish" langid="9"/>
192
- <Name ID="40285" Value="Spanish" langid="10"/>
193
- <Name ID="40286" Value="Spanish" langid="11"/>
194
- <Name ID="40287" Value="Spanish" langid="12"/>
195
- <Name ID="40288" Value="Spanish" langid="13"/>
196
- <Name ID="40289" Value="Spanish" langid="14"/>
197
- <Name ID="40290" Value="Spanish" langid="15"/>
198
- <Name ID="40291" Value="Spanish" langid="16"/>
199
- <Name ID="40292" Value="Spanish" langid="17"/>
200
- <Name ID="205064" Value="Іспанська" langid="25"/>
201
- </Language>
202
- <Language Code="argentinian-spanish" ID="28" ShortCode="AR" Sid="9835">
203
- <Name ID="244259" Value="Argentinian-Spanish" langid="1"/>
204
- <Name ID="244260" Value="Argentinian-Spanish" langid="2"/>
205
- <Name ID="244261" Value="Argentinian-Spanish" langid="3"/>
206
- <Name ID="244262" Value="Argentinian-Spanish" langid="4"/>
207
- <Name ID="244263" Value="Argentinian-Spanish" langid="5"/>
208
- <Name ID="244264" Value="Argentinian-Spanish" langid="6"/>
209
- <Name ID="244265" Value="Argentinian-Spanish" langid="7"/>
210
- <Name ID="244266" Value="Argentinian-Spanish" langid="8"/>
211
- <Name ID="244267" Value="Argentinian-Spanish" langid="9"/>
212
- <Name ID="244268" Value="Argentinian-Spanish" langid="10"/>
213
- <Name ID="244269" Value="Argentinian-Spanish" langid="11"/>
214
- <Name ID="244270" Value="Argentinian-Spanish" langid="12"/>
215
- <Name ID="244271" Value="Argentinian-Spanish" langid="13"/>
216
- <Name ID="244272" Value="Argentinian-Spanish" langid="14"/>
217
- <Name ID="244273" Value="Argentinian-Spanish" langid="15"/>
218
- <Name ID="244274" Value="Argentinian-Spanish" langid="16"/>
219
- <Name ID="244275" Value="Argentinian-Spanish" langid="17"/>
220
- <Name ID="244276" Value="Argentinian-Spanish" langid="18"/>
221
- <Name ID="244277" Value="Argentinian-Spanish" langid="19"/>
222
- <Name ID="244278" Value="Argentinian-Spanish" langid="20"/>
223
- <Name ID="244279" Value="Argentinian-Spanish" langid="21"/>
224
- <Name ID="244280" Value="Argentinian-Spanish" langid="22"/>
225
- <Name ID="244281" Value="Argentinian-Spanish" langid="23"/>
226
- <Name ID="244282" Value="Argentinian-Spanish" langid="24"/>
227
- <Name ID="244283" Value="Argentinian-Spanish" langid="25"/>
228
- <Name ID="244284" Value="Argentinian-Spanish" langid="26"/>
229
- <Name ID="244285" Value="Argentinian-Spanish" langid="27"/>
230
- <Name ID="244286" Value="Argentinian-Spanish" langid="28"/>
231
- </Language>
232
- <Language Code="french" ID="3" ShortCode="FR" Sid="3036">
233
- <Name ID="6071" Value="French" langid="1"/>
234
- <Name ID="6072" Value="French" langid="2"/>
235
- <Name ID="8815" Value="French" langid="3"/>
236
- <Name ID="16579" Value="French" langid="4"/>
237
- <Name ID="103145" Value="Rapporto di compressione" langid="5"/>
238
- <Name ID="24843" Value="French" langid="6"/>
239
- <Name ID="36551" Value="Fransk" langid="7"/>
240
- <Name ID="198024" Value="Французский" langid="8"/>
241
- <Name ID="40254" Value="French" langid="9"/>
242
- <Name ID="40255" Value="French" langid="10"/>
243
- <Name ID="40256" Value="French" langid="11"/>
244
- <Name ID="40257" Value="French" langid="12"/>
245
- <Name ID="40258" Value="French" langid="13"/>
246
- <Name ID="40259" Value="French" langid="14"/>
247
- <Name ID="40260" Value="French" langid="15"/>
248
- <Name ID="40261" Value="French" langid="16"/>
249
- <Name ID="40262" Value="French" langid="17"/>
250
- <Name ID="205061" Value="Французька" langid="25"/>
251
- </Language>
252
- <Language Code="us english" ID="9" ShortCode="US" Sid="6182">
253
- <Name ID="40179" Value="US English" langid="1"/>
254
- <Name ID="40180" Value="US English" langid="2"/>
255
- <Name ID="40181" Value="US English" langid="3"/>
256
- <Name ID="40182" Value="US English" langid="4"/>
257
- <Name ID="40183" Value="US English" langid="5"/>
258
- <Name ID="40184" Value="US English" langid="6"/>
259
- <Name ID="198030" Value="Американский английский" langid="8"/>
260
- <Name ID="50887" Value="" langid="12"/>
261
- <Name ID="205067" Value="Англійська США" langid="25"/>
262
- </Language>
263
- <Language Code="chinese" ID="12" ShortCode="ZH" Sid="6185">
264
- <Name ID="40197" Value="Chinese" langid="1"/>
265
- <Name ID="40198" Value="Chinese" langid="2"/>
266
- <Name ID="40199" Value="Chinese" langid="3"/>
267
- <Name ID="40200" Value="Chinese" langid="4"/>
268
- <Name ID="40201" Value="Chinese" langid="5"/>
269
- <Name ID="40202" Value="Chinese" langid="6"/>
270
- <Name ID="198033" Value="Китайский" langid="8"/>
271
- <Name ID="50890" Value="" langid="12"/>
272
- <Name ID="205070" Value="Китайська" langid="25"/>
273
- </Language>
274
- <Language Code="turkish" ID="20" ShortCode="TR" Sid="8665">
275
- <Name ID="118819" Value="Turkish" langid="1"/>
276
- <Name ID="118820" Value="Turkish" langid="2"/>
277
- <Name ID="118821" Value="Turkish" langid="3"/>
278
- <Name ID="118822" Value="Turkish" langid="4"/>
279
- <Name ID="118823" Value="Turkish" langid="5"/>
280
- <Name ID="118824" Value="Turkish" langid="6"/>
281
- <Name ID="198041" Value="Турецкий" langid="8"/>
282
- <Name ID="205078" Value="Турецька" langid="25"/>
283
- </Language>
284
- <Language Code="polish" ID="14" ShortCode="PL" Sid="6187">
285
- <Name ID="40209" Value="Polish" langid="1"/>
286
- <Name ID="40210" Value="Polish" langid="2"/>
287
- <Name ID="40211" Value="Polish" langid="3"/>
288
- <Name ID="40212" Value="Polish" langid="4"/>
289
- <Name ID="40213" Value="Polish" langid="5"/>
290
- <Name ID="40214" Value="Polish" langid="6"/>
291
- <Name ID="198035" Value="Польский" langid="8"/>
292
- <Name ID="50892" Value="" langid="12"/>
293
- <Name ID="205072" Value="Польська" langid="25"/>
294
- </Language>
295
- <Language Code="czech" ID="15" ShortCode="CZ" Sid="6188">
296
- <Name ID="40215" Value="Czech" langid="1"/>
297
- <Name ID="40216" Value="Czech" langid="2"/>
298
- <Name ID="40217" Value="Czech" langid="3"/>
299
- <Name ID="40218" Value="Czech" langid="4"/>
300
- <Name ID="40219" Value="Czech" langid="5"/>
301
- <Name ID="40220" Value="Czech" langid="6"/>
302
- <Name ID="198036" Value="Чешский" langid="8"/>
303
- <Name ID="50893" Value="" langid="12"/>
304
- <Name ID="205073" Value="Чеська" langid="25"/>
305
- </Language>
306
- <Language Code="russian" ID="8" ShortCode="RU" Sid="6181">
307
- <Name ID="40173" Value="Russian" langid="1"/>
308
- <Name ID="40174" Value="Russian" langid="2"/>
309
- <Name ID="40175" Value="Russian" langid="3"/>
310
- <Name ID="40176" Value="Russian" langid="4"/>
311
- <Name ID="40177" Value="Russian" langid="5"/>
312
- <Name ID="40178" Value="Russian" langid="6"/>
313
- <Name ID="40303" Value="Russian" langid="7"/>
314
- <Name ID="198029" Value="Русский" langid="8"/>
315
- <Name ID="40305" Value="Russian" langid="9"/>
316
- <Name ID="40306" Value="Russian" langid="10"/>
317
- <Name ID="40307" Value="Russian" langid="11"/>
318
- <Name ID="40308" Value="Russian" langid="12"/>
319
- <Name ID="40309" Value="Russian" langid="13"/>
320
- <Name ID="40310" Value="Russian" langid="14"/>
321
- <Name ID="40311" Value="Russian" langid="15"/>
322
- <Name ID="40312" Value="Russian" langid="16"/>
323
- <Name ID="40313" Value="Russian" langid="17"/>
324
- <Name ID="205066" Value="Російська" langid="25"/>
325
- </Language>
326
- <Language Code="german" ID="4" ShortCode="DE" Sid="4795">
327
- <Name ID="14088" Value="German" langid="1"/>
328
- <Name ID="14089" Value="German" langid="2"/>
329
- <Name ID="14090" Value="German" langid="3"/>
330
- <Name ID="18226" Value="German" langid="4"/>
331
- <Name ID="104573" Value="Luce per una lettura agevole" langid="5"/>
332
- <Name ID="26490" Value="German" langid="6"/>
333
- <Name ID="38092" Value="Tysk" langid="7"/>
334
- <Name ID="198025" Value="Немецкий" langid="8"/>
335
- <Name ID="40264" Value="German" langid="9"/>
336
- <Name ID="40265" Value="German" langid="10"/>
337
- <Name ID="40266" Value="German" langid="11"/>
338
- <Name ID="40267" Value="German" langid="12"/>
339
- <Name ID="40268" Value="German" langid="13"/>
340
- <Name ID="40269" Value="German" langid="14"/>
341
- <Name ID="40270" Value="German" langid="15"/>
342
- <Name ID="40271" Value="German" langid="16"/>
343
- <Name ID="40272" Value="German" langid="17"/>
344
- <Name ID="205062" Value="Німецька" langid="25"/>
345
- </Language>
346
- <Language Code="serbian" ID="24" ShortCode="SR" Sid="9443">
347
- <Name ID="170887" Value="Serbian" langid="1"/>
348
- <Name ID="170888" Value="Serbian" langid="2"/>
349
- <Name ID="170889" Value="Serbian" langid="3"/>
350
- <Name ID="170890" Value="Serbian" langid="4"/>
351
- <Name ID="170891" Value="Serbian" langid="5"/>
352
- <Name ID="170892" Value="Serbian" langid="6"/>
353
- <Name ID="198045" Value="Сербский" langid="8"/>
354
- <Name ID="205082" Value="Сербська" langid="25"/>
355
- </Language>
356
- <Language Code="norwegian" ID="19" ShortCode="NO" Sid="8664">
357
- <Name ID="118813" Value="Norwegian" langid="1"/>
358
- <Name ID="118814" Value="Norwegian" langid="2"/>
359
- <Name ID="118815" Value="Norwegian" langid="3"/>
360
- <Name ID="118816" Value="Norwegian" langid="4"/>
361
- <Name ID="118817" Value="Norwegian" langid="5"/>
362
- <Name ID="118818" Value="Norwegian" langid="6"/>
363
- <Name ID="198040" Value="Норвежский" langid="8"/>
364
- <Name ID="205077" Value="Норвезька" langid="25"/>
365
- </Language>
366
- <Language Code="brazilian-portuguese" ID="10" ShortCode="BR" Sid="6183">
367
- <Name ID="40185" Value="Brazilian-Portuguese" langid="1"/>
368
- <Name ID="40186" Value="Brazilian-Portuguese" langid="2"/>
369
- <Name ID="40187" Value="Brazilian-Portuguese" langid="3"/>
370
- <Name ID="40188" Value="Brazilian-Portuguese" langid="4"/>
371
- <Name ID="40189" Value="Brazilian-Portuguese" langid="5"/>
372
- <Name ID="40190" Value="Brazilian-Portuguese" langid="6"/>
373
- <Name ID="198031" Value="Бразильский-португальский" langid="8"/>
374
- <Name ID="50888" Value="" langid="12"/>
375
- <Name ID="205068" Value="Португальська-Бразилія" langid="25"/>
376
- </Language>
377
- <Language Code="italian" ID="5" ShortCode="IT" Sid="4796">
378
- <Name ID="14091" Value="Italian" langid="1"/>
379
- <Name ID="14092" Value="Italian" langid="2"/>
380
- <Name ID="14093" Value="Italian" langid="3"/>
381
- <Name ID="18227" Value="Italian" langid="4"/>
382
- <Name ID="104579" Value="Funzione di on/off luce" langid="5"/>
383
- <Name ID="26491" Value="Italian" langid="6"/>
384
- <Name ID="38093" Value="Italiensk" langid="7"/>
385
- <Name ID="198026" Value="Итальянский" langid="8"/>
386
- <Name ID="40274" Value="Italian" langid="9"/>
387
- <Name ID="40275" Value="Italian" langid="10"/>
388
- <Name ID="40276" Value="Italian" langid="11"/>
389
- <Name ID="40277" Value="Italian" langid="12"/>
390
- <Name ID="40278" Value="Italian" langid="13"/>
391
- <Name ID="40279" Value="Italian" langid="14"/>
392
- <Name ID="40280" Value="Italian" langid="15"/>
393
- <Name ID="40281" Value="Italian" langid="16"/>
394
- <Name ID="40282" Value="Italian" langid="17"/>
395
- <Name ID="205063" Value="Італійська" langid="25"/>
396
- </Language>
397
- </LanguageList>
398
- </Response>
399
- </ICECAT-interface>
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
app/code/local/Bintime/Icecatimport/Model/System/Config/Locales.php DELETED
@@ -1,45 +0,0 @@
1
- <?php
2
- /**
3
- * Class Provides locales list for Magento BO
4
- * @author Sergey Gozhedrianov <info@bintime.com>
5
- *
6
- */
7
- class Bintime_Icecatimport_Model_System_Config_Locales
8
- {
9
- private $domDoc;
10
- public function toOptionArray()
11
- {
12
- $pathToFile = Mage::getRoot().'/code/local/Bintime/Icecatimport/Model/System/Config/';
13
- $fileContent = file_get_contents($pathToFile.'LanguageList.xml');
14
- if(!$this->parseXml(utf8_encode($fileContent))){
15
- return false;
16
- }
17
-
18
- $values = $this->parseLocaleValues();
19
- return $values;
20
- }
21
-
22
- private function parseLocaleValues(){
23
- $languageArray = $this->domDoc->getElementsByTagName('Language');
24
- $resultArray = array();
25
- foreach($languageArray as $language){
26
- $languageShortCode = strtolower($language->getAttribute('ShortCode'));
27
- $languageCode = ucfirst($language->getAttribute('Code'));
28
- $resultArray[$languageShortCode]=$languageCode;
29
- }
30
- ksort($resultArray);
31
- array_unshift($resultArray, 'Use Store Locale');
32
- return $resultArray;
33
- }
34
-
35
- private function parseXml($stringXml){
36
- $this->domDoc = new DOMDocument();
37
- $result = $this->domDoc->loadXML($stringXml);
38
- if (!$this->domDoc->validate()){
39
- echo "Document is not Valid<br>";
40
- return false;
41
- }
42
- return true;
43
- }
44
- }
45
- ?>
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
app/code/local/Bintime/Icecatimport/Model/System/Config/Namepriority.php DELETED
@@ -1,13 +0,0 @@
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
- ?>
 
 
 
 
 
 
 
 
 
 
 
 
 
app/code/local/Bintime/Icecatimport/Model/System/Config/Productpriority.php DELETED
@@ -1,13 +0,0 @@
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
- ?>
 
 
 
 
 
 
 
 
 
 
 
 
 
app/code/local/Bintime/Icecatimport/Model/System/Config/Shortdescrpriority.php DELETED
@@ -1,13 +0,0 @@
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
- ?>
 
 
 
 
 
 
 
 
 
 
 
 
 
app/code/local/Bintime/Icecatimport/Model/System/Config/Subscription.php DELETED
@@ -1,18 +0,0 @@
1
- <?php
2
- /**
3
- * Class provides data for Magento BO
4
- * @author Sergey Gozhedrianov <info@bintime.com>
5
- *
6
- */
7
- class Bintime_Icecatimport_Model_System_Config_Subscription
8
- {
9
- public function toOptionArray()
10
- {
11
- $paramsArray = array(
12
- 'free' => 'OpenIcecat XML',
13
- 'full' => 'FullIcecat XML'
14
- );
15
- return $paramsArray;
16
- }
17
- }
18
- ?>
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
app/code/local/Bintime/Icecatimport/controllers/ImageController.php DELETED
@@ -1,16 +0,0 @@
1
- <?php
2
- /**
3
- * Class provides controller for import image debug
4
- * @author Sergey Gozhedrianov <info@bintime.com>
5
- *
6
- */
7
- class Bintime_Icecatimport_ImageController extends Mage_Adminhtml_Controller_Action{
8
-
9
- /**
10
- * Action calls load method which uploads data to bintime connector data table
11
- */
12
- public function viewAction(){
13
- $result = Mage::getModel('icecatimport/observer')->load();
14
- }
15
- }
16
- ?>
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
app/code/local/Bintime/Icecatimport/etc/config.xml DELETED
@@ -1,154 +0,0 @@
1
- <?xml version="1.0"?>
2
- <config>
3
- <modules>
4
- <Bintime_Icecatimport>
5
- <version>1.5.0</version>
6
- </Bintime_Icecatimport>
7
- </modules>
8
- <global>
9
- <helpers>
10
- <icecatimport>
11
- <class>Bintime_Icecatimport_Helper</class>
12
- </icecatimport>
13
- <catalog>
14
- <rewrite>
15
- <image>Bintime_Icecatimport_Helper_Catalog_Image</image>
16
- <output>Bintime_Icecatimport_Helper_Output</output>
17
- </rewrite>
18
- </catalog>
19
- </helpers>
20
- <blocks>
21
- <Bintime_Icecatimport>
22
- <class>Bintime_Icecatimport_Block</class>
23
- </Bintime_Icecatimport>
24
- <catalog>
25
- <rewrite>
26
- <product_view_media>Bintime_Icecatimport_Block_Media</product_view_media>
27
- <product_list_related>Bintime_Icecatimport_Block_Related</product_list_related>
28
- <product_list_upsell>Bintime_Icecatimport_Block_Upsell</product_list_upsell>
29
- <product_list_toolbar>Bintime_Icecatimport_Block_Product_List_Toolbar</product_list_toolbar>
30
- </rewrite>
31
- </catalog>
32
- <catalogsearch>
33
- <rewrite>
34
- <result>Bintime_Icecatimport_CatalogSearch_Block_Result</result>
35
- </rewrite>
36
- </catalogsearch>
37
- </blocks>
38
- <models>
39
- <icecatimport>
40
- <class>Bintime_Icecatimport_Model</class>
41
- <resourceModel>icecatimport_resource_eav_mysql4</resourceModel>
42
- </icecatimport>
43
- <icecatimport_resource_eav_mysql4>
44
- <entities>
45
- <data><table>bintime_connector_data</table></data>
46
- <supplier_mapping><table>bintime_supplier_mapping</table></supplier_mapping>
47
- </entities>
48
- </icecatimport_resource_eav_mysql4>
49
- <catalog>
50
- <rewrite>
51
- <product>Bintime_Icecatimport_Model_Catalog_Product</product>
52
- <category>Bintime_Icecatimport_Model_Catalog_Category</category>
53
- </rewrite>
54
- </catalog>
55
- <catalogsearch_mysql4>
56
- <rewrite>
57
- <fulltext_collection>Bintime_Icecatimport_Model_Catalog_Search</fulltext_collection>
58
- </rewrite>
59
- </catalogsearch_mysql4>
60
- </models>
61
- <!--
62
- <routers>
63
- <catalog>
64
- <rewrite>
65
- <product>
66
- <to>Bintime_Icecatimport/product</to>
67
- <override_actions>false</override_actions>
68
- <actions>
69
- <view><to>Bintime_Icecatimport/product/view</to></view>
70
- </actions>
71
- </product>
72
- </rewrite>
73
- </catalog>
74
- </routers>
75
- -->
76
- <resources>
77
- <icecatimport_setup>
78
- <setup>
79
- <module>Bintime_Icecatimport</module>
80
- </setup>
81
- <connection>
82
- <use>core_setup</use>
83
- </connection>
84
- </icecatimport_setup>
85
- </resources>
86
- </global>
87
- <frontend>
88
- <routers>
89
- <icecatimport>
90
- <use>standard</use>
91
- <args>
92
- <module>Bintime_Icecatimport</module>
93
- <frontName>icecatimport</frontName>
94
- </args>
95
- </icecatimport>
96
- </routers>
97
- <layout>
98
- <updates>
99
- <IcecatGroupAttributes>
100
- <file>IcecatGroupAttributes.xml</file>
101
- </IcecatGroupAttributes>
102
- </updates>
103
- </layout>
104
- <translate>
105
- <modules>
106
- <icecatimport>
107
- <files>
108
- <default>Bintime_Icecatimport.csv</default>
109
- </files>
110
- </icecatimport>
111
- </modules>
112
- </translate>
113
- </frontend>
114
- <adminhtml>
115
- <acl>
116
- <resources>
117
- <admin>
118
- <children>
119
- <system>
120
- <children>
121
- <config>
122
- <children>
123
- <icecat_root translate="title" module="customer">
124
- <title>Ice Cat Module powered by Bintime company</title>
125
- <sort_order>200</sort_order>
126
- </icecat_root>
127
- </children>
128
- </config>
129
- </children>
130
- </system>
131
- </children>
132
- </admin>
133
- </resources>
134
- </acl>
135
- <events></events>
136
- <translate>
137
- <modules>
138
- <mage_adminhtml>
139
- <files>
140
- <icecatimport>Bintime_Icecatimport.csv</icecatimport>
141
- </files>
142
- </mage_adminhtml>
143
- </modules>
144
- </translate>
145
- </adminhtml>
146
- <crontab>
147
- <jobs>
148
- <icecatimport>
149
- <schedule><cron_expr>0 0 * * 1</cron_expr></schedule>
150
- <run><model>icecatimport/observer::load</model></run>
151
- </icecatimport>
152
- </jobs>
153
- </crontab>
154
- </config>
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
app/code/local/Bintime/Icecatimport/etc/system.xml DELETED
@@ -1,133 +0,0 @@
1
- <?xml version="1.0" encoding="UTF-8"?>
2
- <config>
3
- <sections>
4
- <icecat_root translate="label" module="catalog">
5
- <class>separator-top</class>
6
- <label>Icecat Live!</label>
7
- <tab>catalog</tab>
8
- <frontend_type>text</frontend_type>
9
- <sort_order>200</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
- <icecat translate="label">
15
- <label>Icecat Live! 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
- <login translate="label">
23
- <label>Icecat User name</label>
24
- <frontend_type>text</frontend_type>
25
- <sort_order>10</sort_order>
26
- <show_in_default>1</show_in_default>
27
- <show_in_website>1</show_in_website>
28
- <show_in_store>1</show_in_store>
29
- </login>
30
- <password translate="label">
31
- <label>Icecat Password</label>
32
- <frontend_type>text</frontend_type>
33
- <sort_order>20</sort_order>
34
- <show_in_default>1</show_in_default>
35
- <show_in_website>1</show_in_website>
36
- <show_in_store>1</show_in_store>
37
- </password>
38
- <icecat_type translate="label">
39
- <label>Subscription level</label>
40
- <frontend_type>select</frontend_type>
41
- <source_model>icecatimport/system_config_subscription</source_model>
42
- <sort_order>25</sort_order>
43
- <show_in_default>1</show_in_default>
44
- <show_in_website>1</show_in_website>
45
- <show_in_store>1</show_in_store>
46
- </icecat_type>
47
- <language translate="label">
48
- <label>Language</label>
49
- <frontend_type>select</frontend_type>
50
- <source_model>icecatimport/system_config_locales</source_model>
51
- <sort_order>30</sort_order>
52
- <show_in_default>1</show_in_default>
53
- <show_in_website>1</show_in_website>
54
- <show_in_store>1</show_in_store>
55
- </language>
56
- <sku_field translate="label">
57
- <label>MPN</label>
58
- <frontend_type>select</frontend_type>
59
- <source_model>icecatimport/system_config_attributes</source_model>
60
- <sort_order>40</sort_order>
61
- <show_in_default>1</show_in_default>
62
- <show_in_website>1</show_in_website>
63
- <show_in_store>1</show_in_store>
64
- </sku_field>
65
- <manufacturer translate="label">
66
- <label>Manufacturer Name</label>
67
- <frontend_type>select</frontend_type>
68
- <source_model>icecatimport/system_config_attributes</source_model>
69
- <sort_order>50</sort_order>
70
- <show_in_default>1</show_in_default>
71
- <show_in_website>1</show_in_website>
72
- <show_in_store>1</show_in_store>
73
- </manufacturer>
74
- <ean_code translate="label">
75
- <label>Ean Code</label>
76
- <frontend_type>select</frontend_type>
77
- <source_model>icecatimport/system_config_attributes</source_model>
78
- <sort_order>60</sort_order>
79
- <show_in_default>1</show_in_default>
80
- <show_in_website>1</show_in_website>
81
- <show_in_store>1</show_in_store>
82
- </ean_code>
83
- <descript_priority translate="label">
84
- <label>Use Description from </label>
85
- <frontend_type>select</frontend_type>
86
- <source_model>icecatimport/system_config_descriptionpriority</source_model>
87
- <sort_order>70</sort_order>
88
- <show_in_default>1</show_in_default>
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
- <product_priority translate="label">
120
- <label>Show/Hide products not presented at icecat</label>
121
- <frontend_type>select</frontend_type>
122
- <source_model>icecatimport/system_config_productpriority</source_model>
123
- <sort_order>70</sort_order>
124
- <show_in_default>1</show_in_default>
125
- <show_in_website>1</show_in_website>
126
- <show_in_store>1</show_in_store>
127
- </product_priority>
128
- </fields>
129
- </icecat>
130
- </groups>
131
- </icecat_root>
132
- </sections>
133
- </config>
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
app/code/local/Bintime/Icecatimport/sql/icecatimport_setup/mysql4-install-0.1.0.php DELETED
@@ -1,24 +0,0 @@
1
- <?php
2
- $installer = $this;
3
- /* @var $installer Mage_Catalog_Model_Resource_Eav_Mysql4_Setup */
4
-
5
- $installer->startSetup();
6
-
7
- $installer->run("
8
- DROP TABLE IF EXISTS {$this->getTable('icecatimport/data')};
9
- CREATE TABLE {$this->getTable('icecatimport/data')} (
10
- `prod_id` varchar(255) NOT NULL,
11
- `prod_img` varchar(255),
12
- KEY `PRODUCT_MPN` (`prod_id`)
13
- ) ENGINE=InnoDB DEFAULT CHARSET=utf8 COMMENT='Bintime Connector product image table';
14
-
15
- DROP TABLE IF EXISTS {$this->getTable('icecatimport/supplier_mapping')};
16
- CREATE TABLE {$this->getTable('icecatimport/supplier_mapping')} (
17
- `supplier_id` int(11) NOT NULL,
18
- `supplier_symbol` VARCHAR(255),
19
- KEY `supplier_id` (`supplier_id`)
20
- ) ENGINE=InnoDB DEFAULT CHARSET=utf8 COMMENT='Bintime Connector supplier mapping table';
21
-
22
- ");
23
-
24
- $installer->endSetup();
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
app/code/local/Bintime/Icecatimport/sql/icecatimport_setup/mysql4-upgrade-0.1.0-0.1.1.php DELETED
@@ -1,12 +0,0 @@
1
- <?php
2
- $installer = $this;
3
- /* @var $installer Mage_Catalog_Model_Resource_Eav_Mysql4_Setup */
4
-
5
- $installer->startSetup();
6
- $installer->run("
7
- ALTER TABLE {$this->getTable('icecatimport/data')} ADD COLUMN `prod_name` VARCHAR(255) AFTER `prod_id`;
8
- ALTER TABLE {$this->getTable('icecatimport/data')} ADD COLUMN `supplier_id` int(11) AFTER `prod_id`;
9
- ALTER TABLE {$this->getTable('icecatimport/data')} ADD KEY `supplier_id` (`supplier_id`);
10
- ");
11
- $installer->endSetup();
12
- ?>
 
 
 
 
 
 
 
 
 
 
 
 
app/code/local/Iceshop/Icecatlive/Block/Adminhtml/System/Config/Form/Button.php ADDED
@@ -0,0 +1,57 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ class Iceshop_Icecatlive_Block_Adminhtml_System_Config_Form_Button extends Mage_Adminhtml_Block_System_Config_Form_Field
3
+ {
4
+ /*
5
+ * Set templated
6
+ */
7
+ protected function _construct()
8
+ {
9
+ parent::_construct();
10
+
11
+ $this->setTemplate('iceshop/icecatlive/ajaxstatusimport.phtml');
12
+ }
13
+
14
+ /**
15
+ * Return element html
16
+ *
17
+ * @param Varien_Data_Form_Element_Abstract $element
18
+ * @return string
19
+ */
20
+ protected function _getElementHtml(Varien_Data_Form_Element_Abstract $element)
21
+ {
22
+ return $this->_toHtml();
23
+ }
24
+
25
+ /**
26
+ * Return ajax url for button
27
+ *
28
+ * @return string
29
+ */
30
+ public function getAjaxCheckUrl()
31
+ {
32
+ return Mage::helper('adminhtml')->getUrl('adminhtml/adminhtml_importdata/check');
33
+ }
34
+
35
+ /**
36
+ * Generate button html
37
+ *
38
+ * @return string
39
+ */
40
+ public function getButtonHtml()
41
+ {
42
+ $userLogin = Mage::getStoreConfig('icecat_root/icecat/login');
43
+ $userPass = Mage::getStoreConfig('icecat_root/icecat/password');
44
+ if (!empty($userLogin) && !empty($userPass)) {
45
+ $button = $this->getLayout()->createBlock('adminhtml/widget_button')
46
+ ->setData(array(
47
+ 'id' => 'icecatlive_button',
48
+ 'label' => $this->helper('adminhtml')->__('Import'),
49
+ 'onclick' => 'javascript:check(); return false;'
50
+ ));
51
+
52
+ return $button->toHtml();
53
+ } else {
54
+ return 'Please type your login and pass from IceCat and press Save Config button. After that you can see Import button, for start import data from IceCat to you DB.';
55
+ }
56
+ }
57
+ }
app/code/local/Iceshop/Icecatlive/Block/Attributes.php ADDED
@@ -0,0 +1,89 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ class Iceshop_Icecatlive_Block_Attributes extends Mage_Core_Block_Template
4
+ {
5
+ public function getProduct()
6
+ {
7
+ if (!$this->_product) {
8
+ $this->_product = Mage::registry('product');
9
+ }
10
+ return $this->_product;
11
+ }
12
+
13
+ public function getAdditionalData(array $excludeAttr = array())
14
+ {
15
+ //echo 'Its work';
16
+ $data = $this->getAttributesArray();
17
+
18
+ $data2 = array();
19
+ foreach ($data as $_data) {
20
+ if ($_data['label'] != '' && $_data['value'] != '' && $_data['label'] != 'id') {
21
+ $value = $_data['value'];
22
+ $group = 0;
23
+ if ($tmp = $_data["id"]) {
24
+ $group = $tmp;
25
+ }
26
+
27
+ $data2[$group]['items'][$_data['label']] = array(
28
+ 'label' => $_data['label'],
29
+ 'value' => $value,
30
+ 'code' => $_data['label']
31
+ );
32
+
33
+ $data2[$group]['attrid'] = $_data["id"];
34
+
35
+ } else if (!empty($_data['code']) && $_data['code'] == 'header') {
36
+ $data2[$_data['id']]["title"] = $_data['value'];
37
+ }
38
+ }
39
+
40
+ return $data2;
41
+ }
42
+
43
+ public function formatValue($value)
44
+ {
45
+ if ($value == "Y") {
46
+ return '<img border="0" alt="" src="http://prf.icecat.biz/imgs/yes.gif"/>';
47
+ } else if ($value == "N") {
48
+ return '<img border="0" alt="" src="http://prf.icecat.biz/imgs/no.gif"/>';
49
+ }
50
+ return str_replace("\\n", "<br>", htmlspecialchars($value));
51
+ }
52
+
53
+ public function getAttributesArray()
54
+ {
55
+ $iceModel = Mage::getSingleton('icecatlive/import');
56
+ $descriptionsListArray = $iceModel->getProductDescriptionList();
57
+ $id = '';
58
+ $arr = array();
59
+ foreach ($descriptionsListArray as $key => $ma) {
60
+ $id = $key;
61
+ foreach ($ma as $key => $value) {
62
+ $arr[$key] = $value;
63
+ $arr[$key]["id"] = $id;
64
+ }
65
+ }
66
+
67
+ $data = array();
68
+ foreach ($arr as $key => $value) {
69
+ //$attributes = Mage::getModel('catalog/product')->getAttributesFromIcecat($this->getProduct()->getEntityId(), $value);
70
+ // @todo @someday @maybe make headers
71
+ $data[] = array(
72
+ 'label' => '',
73
+ 'value' => $key,
74
+ 'code' => 'header',
75
+ 'id' => $value["id"]
76
+ );
77
+ $attributes = $value;
78
+ foreach ($attributes as $attributeLabel => $attributeValue) {
79
+ $data[] = array(
80
+ 'label' => $attributeLabel,
81
+ 'value' => $this->formatValue($attributeValue),
82
+ 'code' => 'descript',
83
+ 'id' => $value["id"]
84
+ );
85
+ }
86
+ }
87
+ return $data;
88
+ }
89
+ }
app/code/local/Iceshop/Icecatlive/Block/Media.php ADDED
@@ -0,0 +1,41 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ class Iceshop_Icecatlive_Block_Media extends Mage_Catalog_Block_Product_View_Media
4
+ {
5
+ protected $_isGalleryDisabled;
6
+
7
+ public function getGalleryImages()
8
+ {
9
+ if ($this->_isGalleryDisabled) {
10
+ return array();
11
+ }
12
+ $iceCatModel = Mage::getSingleton('icecatlive/import');
13
+ $icePhotos = $iceCatModel->getGalleryPhotos();
14
+ $collection = $this->getProduct()->getMediaGalleryImages();
15
+ $items = $collection->getItems();
16
+ $Imagepriority = Mage::getStoreConfig('icecat_root/icecat/image_priority');
17
+ if (!empty($icePhotos) && $Imagepriority != 'Db') {
18
+ return Mage::getSingleton('Iceshop_Icecatlive_Model_Imagescollection', array(
19
+ 'product' => $this->getProduct()
20
+ ));
21
+ } else if (count($items) == 1) {
22
+ return array();
23
+ } else {
24
+ return $collection;
25
+ }
26
+ }
27
+
28
+
29
+ public function getGalleryUrl($image = null)
30
+ {
31
+ $iceCatModel = Mage::getSingleton('icecatlive/import');
32
+ $icePhotos = $iceCatModel->getGalleryPhotos();
33
+ $Imagepriority = Mage::getStoreConfig('icecat_root/icecat/image_priority');
34
+
35
+ if (!empty($icePhotos) && $Imagepriority != 'Db') {
36
+ return Mage::getBaseUrl(Mage_Core_Model_Store::URL_TYPE_MEDIA) . 'catalog/product/' . $image['file'];
37
+ } else {
38
+ return parent::getGalleryUrl($image);
39
+ }
40
+ }
41
+ }
app/code/local/Iceshop/Icecatlive/Block/Product/List/Toolbar.php ADDED
@@ -0,0 +1,84 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ class Iceshop_Icecatlive_Block_Product_List_Toolbar extends Mage_Catalog_Block_Product_List_Toolbar
4
+ {
5
+ public static $_productCollection = null;
6
+ public static $_totalRecords = null;
7
+
8
+ public function getCollection()
9
+ {
10
+ $ProductPriority = Mage::getStoreConfig('icecat_root/icecat/product_priority');
11
+ $_productCollection = parent::getCollection();
12
+
13
+ if (!$_productCollection->count() || $ProductPriority == 'Show') {
14
+ return $_productCollection;
15
+ } else {
16
+ foreach ($_productCollection as $_product) {
17
+ $icecat_prod = $this->CheckIcecatData($_product);
18
+ if ($icecat_prod === false) {
19
+ $_productCollection->removeItemByKey($_product->getId());
20
+ }
21
+ }
22
+
23
+ self::$_productCollection = $_productCollection;
24
+
25
+ return $_productCollection;
26
+ }
27
+ }
28
+
29
+ public function getTotalNum()
30
+ {
31
+ if (self::$_productCollection === null) {
32
+ return parent::getTotalNum();
33
+ }
34
+ self::$_totalRecords = count(self::$_productCollection->getItems());
35
+ return intval(self::$_totalRecords);
36
+ }
37
+
38
+ public function CheckIcecatData($_product)
39
+ {
40
+ $connection = Mage::getSingleton('core/resource')->getConnection('core_read');
41
+ $mpn = Mage::getModel('catalog/product')->load($_product->getId())->getData(Mage::getStoreConfig('icecat_root/icecat/sku_field'));
42
+ $ean = Mage::getModel('catalog/product')->load($_product->getId())->getData(Mage::getStoreConfig('icecat_root/icecat/ean_code'));
43
+ $tableName = Mage::getSingleton('core/resource')->getTableName('icecatlive/data_products');
44
+ if(!empty($mpn)){
45
+ $selectCondition = $connection->select()
46
+ ->from(array('connector' => $tableName), new Zend_Db_Expr('connector.prod_title'))
47
+ ->where('connector.prod_id = ? ', $mpn);
48
+ $icecatName = $connection->fetchOne($selectCondition);
49
+ }
50
+ if(empty($icecatName) && !empty($ean)){
51
+ $selectCondition = $connection->select()
52
+ ->from(array('connector' => $tableName), new Zend_Db_Expr('connector.prod_title'))
53
+ ->where('connector.prod_ean = ? ', $ean);
54
+ $icecatName = $connection->fetchOne($selectCondition);
55
+ }
56
+ if (!empty($icecatName)) {
57
+ return true;
58
+ } else {
59
+ $tableName = Mage::getSingleton('core/resource')->getTableName('icecatlive/data');
60
+ $mappingTable = Mage::getSingleton('core/resource')->getTableName('icecatlive/supplier_mapping');
61
+ $manufacturer = Mage::getModel('catalog/product')->load($_product->getId())->getData(Mage::getStoreConfig('icecat_root/icecat/manufacturer'));
62
+ if (isset($manufacturer) && !empty($manufacturer)) {
63
+ $selectCondition = $connection->select()
64
+ ->from(array('connector' => $tableName), new Zend_Db_Expr('connector.prod_img'))
65
+ ->joinInner(array('supplier' => $mappingTable), "connector.supplier_id = supplier.supplier_id AND supplier.supplier_symbol = {$connection->quote($manufacturer)}")
66
+ ->where('connector.prod_id = ?', $mpn);
67
+ $imageURL = $connection->fetchOne($selectCondition);
68
+ }
69
+ if (empty($imageURL) && !empty($ean)) {
70
+ $selectCondition = $connection->select()
71
+ ->from(array('connector' => $tableName), new Zend_Db_Expr('connector.prod_img'))
72
+ ->joinLeft(array('products' => $tableName . '_products'), "connector.prod_id = products.prod_id")
73
+ ->where('products.prod_ean = ?', trim($ean));
74
+ $imageURL = $connection->fetchOne($selectCondition);
75
+ }
76
+
77
+ $icecat_prod = !empty($imageURL) ? true : false;
78
+ return $icecat_prod;
79
+ }
80
+ }
81
+
82
+ }
83
+
84
+ ?>
app/code/local/{Bintime/Icecatimport → Iceshop/Icecatlive}/Block/Related.php RENAMED
@@ -32,28 +32,27 @@
32
  * @package Mage_Catalog
33
  * @author Magento Core Team <core@magentocommerce.com>
34
  */
35
- class Bintime_Icecatimport_Block_Related extends Mage_Catalog_Block_Product_List_Related
36
  {
37
- protected function _prepareData()
38
  {
39
- $product = Mage::registry('product');
40
- $helper = Mage::helper('icecatimport/getdata');
41
- $relatedProducts = $helper->getRelatedProducts();
42
- if(!$relatedProducts)
43
- {
44
- return parent::_prepareData();
45
- }
46
-
47
- $tmp = Mage::getSingleton('Bintime_Icecatimport_Model_Relatedcollection', $relatedProducts);
48
- $tmp = $tmp->getCollection();
49
- $this->_itemCollection = $tmp;
50
- $this->_addProductAttributesAndPrices($this->_itemCollection);
51
- Mage::getSingleton('catalog/product_visibility')->addVisibleInCatalogFilterToCollection($this->_itemCollection);
52
- $this->_itemCollection->load();
53
- foreach ($this->_itemCollection as $product) {
54
  $product->setDoNotUseCategoryId(true);
55
  }
56
- return $this;
57
  }
58
 
59
  }
32
  * @package Mage_Catalog
33
  * @author Magento Core Team <core@magentocommerce.com>
34
  */
35
+ class Iceshop_Icecatlive_Block_Related extends Mage_Catalog_Block_Product_List_Related
36
  {
37
+ protected function _prepareData()
38
  {
39
+ $product = Mage::registry('product');
40
+ $helper = Mage::helper('icecatlive/getdata');
41
+ $relatedProducts = $helper->getRelatedProducts();
42
+ if (!$relatedProducts) {
43
+ return parent::_prepareData();
44
+ }
45
+
46
+ $tmp = Mage::getSingleton('Iceshop_Icecatlive_Model_Relatedcollection', $relatedProducts);
47
+ $tmp = $tmp->getCollection();
48
+ $this->_itemCollection = $tmp;
49
+ $this->_addProductAttributesAndPrices($this->_itemCollection);
50
+ Mage::getSingleton('catalog/product_visibility')->addVisibleInCatalogFilterToCollection($this->_itemCollection);
51
+ $this->_itemCollection->load();
52
+ foreach ($this->_itemCollection as $product) {
 
53
  $product->setDoNotUseCategoryId(true);
54
  }
55
+ return $this;
56
  }
57
 
58
  }
app/code/local/{Bintime/Icecatimport → Iceshop/Icecatlive}/Block/Upsell.php RENAMED
@@ -1,24 +1,24 @@
1
  <?php
2
- class Bintime_Icecatimport_Block_Upsell extends Mage_Catalog_Block_Product_List_Upsell{
 
3
 
4
- protected function _prepareData()
5
  {
6
  $product = Mage::registry('product');
7
  /* @var $product Mage_Catalog_Model_Product */
8
  $this->_itemCollection = $product->getUpSellProductCollection()
9
  ->addAttributeToSort('position', 'asc')
10
- ->addStoreFilter()
11
- ;
12
  $skuField = Mage::getStoreConfig('icecat_root/icecat/sku_field');
13
  $this->_itemCollection->addAttributeToSelect($skuField);
14
-
15
  $manufacturerId = Mage::getStoreConfig('icecat_root/icecat/manufacturer');
16
  $this->_itemCollection->addAttributeToSelect($manufacturerId);
17
-
18
  Mage::getResourceSingleton('checkout/cart')->addExcludeProductFilter($this->_itemCollection,
19
  Mage::getSingleton('checkout/session')->getQuoteId()
20
  );
21
-
22
 
23
  $this->_addProductAttributesAndPrices($this->_itemCollection);
24
 
@@ -34,11 +34,11 @@ class Bintime_Icecatimport_Block_Upsell extends Mage_Catalog_Block_Product_List_
34
  * Updating collection with desired items
35
  */
36
  Mage::dispatchEvent('catalog_product_upsell', array(
37
- 'product' => $product,
38
- 'collection' => $this->_itemCollection,
39
- 'limit' => $this->getItemLimit()
40
  ));
41
-
42
  foreach ($this->_itemCollection as $product) {
43
  $product->setDoNotUseCategoryId(true);
44
  }
@@ -46,5 +46,5 @@ class Bintime_Icecatimport_Block_Upsell extends Mage_Catalog_Block_Product_List_
46
  return $this;
47
  }
48
 
49
-
50
  }
1
  <?php
2
+ class Iceshop_Icecatlive_Block_Upsell extends Mage_Catalog_Block_Product_List_Upsell
3
+ {
4
 
5
+ protected function _prepareData()
6
  {
7
  $product = Mage::registry('product');
8
  /* @var $product Mage_Catalog_Model_Product */
9
  $this->_itemCollection = $product->getUpSellProductCollection()
10
  ->addAttributeToSort('position', 'asc')
11
+ ->addStoreFilter();
 
12
  $skuField = Mage::getStoreConfig('icecat_root/icecat/sku_field');
13
  $this->_itemCollection->addAttributeToSelect($skuField);
14
+
15
  $manufacturerId = Mage::getStoreConfig('icecat_root/icecat/manufacturer');
16
  $this->_itemCollection->addAttributeToSelect($manufacturerId);
17
+
18
  Mage::getResourceSingleton('checkout/cart')->addExcludeProductFilter($this->_itemCollection,
19
  Mage::getSingleton('checkout/session')->getQuoteId()
20
  );
21
+
22
 
23
  $this->_addProductAttributesAndPrices($this->_itemCollection);
24
 
34
  * Updating collection with desired items
35
  */
36
  Mage::dispatchEvent('catalog_product_upsell', array(
37
+ 'product' => $product,
38
+ 'collection' => $this->_itemCollection,
39
+ 'limit' => $this->getItemLimit()
40
  ));
41
+
42
  foreach ($this->_itemCollection as $product) {
43
  $product->setDoNotUseCategoryId(true);
44
  }
46
  return $this;
47
  }
48
 
49
+
50
  }
app/code/local/Iceshop/Icecatlive/CatalogSearch/Block/Result.php ADDED
@@ -0,0 +1,34 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ class Iceshop_Icecatlive_CatalogSearch_Block_Result extends Mage_CatalogSearch_Block_Result
3
+ {
4
+
5
+ /**
6
+ * Retrieve search result count
7
+ *
8
+ * @return string
9
+ */
10
+ public function getResultCount()
11
+ {
12
+ $ProductPriority = Mage::getStoreConfig('icecat_root/icecat/product_priority');
13
+
14
+ if ($ProductPriority == 'Show') {
15
+ return parent::getResultCount();
16
+ }
17
+
18
+ $products = $this->_getProductCollection();
19
+ $toolbar = new Iceshop_Icecatlive_Block_Product_List_Toolbar();
20
+ foreach ($products as $_product) {
21
+ $icecat_prod = $toolbar->CheckIcecatData($_product);
22
+ if ($icecat_prod === false) {
23
+ $products->removeItemByKey($_product->getId());
24
+ }
25
+ }
26
+ $size = count($products->getItems());
27
+ $this->_getQuery()->setNumResults($size);
28
+ $this->setResultCount($size);
29
+ return $this->getData('result_count');
30
+ }
31
+
32
+ }
33
+
34
+ ?>
app/code/local/Iceshop/Icecatlive/Helper/Catalog/Image.php ADDED
@@ -0,0 +1,58 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * Overloaded catalog helper to substitute magento images
4
+ *
5
+ */
6
+ class Iceshop_Icecatlive_Helper_Catalog_Image extends Mage_Catalog_Helper_Image
7
+ {
8
+
9
+ /**
10
+ * Overriden method provides product with images from icecatlive data table
11
+ * @param $product Mage_Catalog_Model_Product
12
+ * @param $attributeName string
13
+ * @param $imageFile string
14
+ */
15
+ public function init(Mage_Catalog_Model_Product $product, $attributeName, $imageFile = null)
16
+ {
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
+ ) {
25
+ return parent::init($product, $attributeName, $imageFile);
26
+ }
27
+
28
+ if ($attributeName == 'image' && $imageFile == null) {
29
+ $imageFile = mage::getsingleton('icecatlive/import')->getLowPicUrl();
30
+
31
+ } else if ($attributeName == 'thumbnail' && $imageFile == null) {
32
+ $imageFile = Mage::helper('icecatlive/image')->getImage($product);
33
+
34
+ } else if ($attributeName == 'small_image' && $imageFile == null) {
35
+ $imageFile = Mage::helper('icecatlive/image')->getImage($product);
36
+ }
37
+
38
+ return parent::init($product, $attributeName, $imageFile);
39
+ }
40
+
41
+ /**
42
+ * Return icecat image URL if set
43
+ */
44
+
45
+ public function __toString()
46
+ {
47
+ $url = parent::__toString();
48
+
49
+ if ($this->getImageFile() && strpos($this->getImageFile(), 'icecat.biz') && strpos($url, 'placeholder')) {
50
+ $url = $this->getImageFile();
51
+ }
52
+
53
+ return $url;
54
+ }
55
+
56
+ }
57
+
58
+ ?>
app/code/local/Iceshop/Icecatlive/Helper/Data.php ADDED
@@ -0,0 +1,4 @@
 
 
 
 
1
+ <?php
2
+ class Iceshop_Icecatlive_Helper_Data extends Mage_Core_Helper_Abstract
3
+ {
4
+ }
app/code/local/Iceshop/Icecatlive/Helper/Getdata.php ADDED
@@ -0,0 +1,211 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ *
4
+ * Class achieves icecat description from Model by recieved SKU and manufacturer
5
+ *
6
+ */
7
+ class Iceshop_Icecatlive_Helper_Getdata extends Mage_Core_Helper_Abstract
8
+ {
9
+ private $iceCatModel;
10
+ private $error;
11
+ private $systemError;
12
+
13
+ /**
14
+ * Gets product Data and delegates it to Model
15
+ * @param Mage_Catalog_Model_Product $_product
16
+ * @return Iceshop_Icecatlive_Helper_Getdata
17
+ */
18
+
19
+ public function getEntityTypeId()
20
+ {
21
+ $connection = Mage::getSingleton('core/resource')->getConnection('core_read');
22
+ $query = $connection->select()
23
+ ->from(Mage::getSingleton('core/resource')
24
+ ->getTableName('eav_entity_type'), 'entity_type_id')
25
+ ->where('entity_type_code = ?', 'catalog_product')
26
+ ->limit(1);
27
+ $this->entityTypeId = $connection->fetchOne($query);
28
+ return $this->entityTypeId;
29
+ }
30
+
31
+ public function getProductDescription($_product)
32
+ {
33
+ try {
34
+ $entityId = $_product->getEntityId();
35
+ $entity_type_id = $this->getEntityTypeId();
36
+ $connection = Mage::getSingleton('core/resource')->getConnection('core_read');
37
+ $mpn = $_product->getData(Mage::getStoreConfig('icecat_root/icecat/sku_field'));
38
+ $ean_code = $_product->getData(Mage::getStoreConfig('icecat_root/icecat/ean_code'));
39
+ $manufacturerId = $_product->getData(Mage::getStoreConfig('icecat_root/icecat/manufacturer'));
40
+ $attributeInfo = Mage::getResourceModel('eav/entity_attribute_collection')
41
+ ->setCodeFilter(Mage::getStoreConfig('icecat_root/icecat/manufacturer'))
42
+ ->setEntityTypeFilter($entity_type_id)
43
+ ->getFirstItem();
44
+ if ($attributeInfo->getData('backend_type') == 'int' ||
45
+ ($attributeInfo->getData('frontend_input') == 'select' && $attributeInfo->getData('backend_type') == 'static')
46
+ ) {
47
+ $attribute = $attributeInfo->setEntity($_product->getResource());
48
+ $manufacturer = $attribute->getSource()->getOptionText($manufacturerId);
49
+ } else {
50
+ $manufacturer = $manufacturerId;
51
+ }
52
+
53
+ $locale = Mage::getStoreConfig('icecat_root/icecat/language');
54
+ if ($locale == '0') {
55
+ $systemLocale = explode("_", Mage::app()->getLocale()->getLocaleCode());
56
+ $locale = $systemLocale[0];
57
+ }
58
+ $userLogin = Mage::getStoreConfig('icecat_root/icecat/login');
59
+ $userPass = Mage::getStoreConfig('icecat_root/icecat/password');
60
+ $this->iceCatModel = Mage::getSingleton('icecatlive/import');
61
+ if (!$this->iceCatModel->getProductDescription($mpn, $manufacturer, $locale, $userLogin, $userPass, $entityId, $ean_code)) {
62
+ $this->error = $this->iceCatModel->getErrorMessage();
63
+ $this->systemError = $this->iceCatModel->getSystemError();
64
+ return $this;
65
+ }
66
+ } catch (Exception $e) {
67
+ Mage::log('Icecat getProductDescription error' . $e);
68
+ }
69
+ return $this;
70
+ }
71
+
72
+ /**
73
+ * returns true if error during data fetch occured else false
74
+ */
75
+ public function hasError()
76
+ {
77
+ if ($this->error || $this->systemError) {
78
+ return true;
79
+ }
80
+ return false;
81
+ }
82
+
83
+ /**
84
+ * return error message
85
+ */
86
+ public function getError()
87
+ {
88
+ }
89
+
90
+ /**
91
+ * return system error
92
+ */
93
+ public function hasSystemError()
94
+ {
95
+ if ($this->systemError) {
96
+ return $this->systemError;
97
+ }
98
+ return false;
99
+ }
100
+
101
+ public function getProductDescriptionList()
102
+ {
103
+ return $this->iceCatModel->getProductDescriptionList();
104
+ }
105
+
106
+ public function getShortProductDescription()
107
+ {
108
+ return $this->iceCatModel->getShortProductDescription();
109
+ }
110
+
111
+ public function getLowPicUrl()
112
+ {
113
+ return $this->iceCatModel->getLowPicUrl();
114
+ }
115
+
116
+ public function getThumbPicture()
117
+ {
118
+ return $this->iceCatModel->getThumbPicture();
119
+ }
120
+
121
+ public function getGalleryPhotos()
122
+ {
123
+ return $this->iceCatModel->getGalleryPhotos();
124
+ }
125
+
126
+ public function getProductName()
127
+ {
128
+ return $this->iceCatModel->getProductName();
129
+ }
130
+
131
+ public function getVendor()
132
+ {
133
+ return $this->iceCatModel->getVendor();
134
+ }
135
+
136
+ public function getFullProductDescription()
137
+ {
138
+ return $this->iceCatModel->getFullProductDescription();
139
+ }
140
+
141
+ public function getMPN()
142
+ {
143
+ return $this->iceCatModel->getMPN();
144
+ }
145
+
146
+ public function getEAN()
147
+ {
148
+ return $this->iceCatModel->getEAN();
149
+ }
150
+
151
+ /**
152
+ * Form related products list according to store products
153
+ */
154
+ public function getRelatedProducts()
155
+ {
156
+ if (!$this->iceCatModel) {
157
+ $this->iceCatModel = Mage::getSingleton('icecatlive/import');
158
+ }
159
+ $relatedProducts = $this->iceCatModel->getRelatedProducts();
160
+ if (empty($relatedProducts)) {
161
+ return array();
162
+ }
163
+ $sku = Mage::getStoreConfig('icecat_root/icecat/sku_field');
164
+ $collection = Mage::getModel('catalog/product')->getCollection();
165
+ $filterArray = array();
166
+ foreach ($relatedProducts as $mpn => $valueArray) {
167
+ array_push($filterArray, array('attribute' => $sku, 'eq' => $mpn));
168
+ }
169
+ $collection->addFieldToFilter($filterArray);
170
+ $collection->addAttributeToSelect($sku);
171
+ $collection->addAttributeToSelect('category_ids');
172
+ $relatedProductsList = array();
173
+ foreach ($collection as $product) {
174
+ $categoryIds = $product->getCategoryIds();
175
+ if (!empty($categoryIds)) {
176
+ if (is_array($categoryIds)) {
177
+ $catogoriesArray = $categoryIds;
178
+ }
179
+ if (is_string($categoryIds)) {
180
+ $catogoriesArray = explode(",", $product->getCategoryIds());
181
+ }
182
+ foreach ($catogoriesArray as $categoryId) {
183
+ if (!array_key_exists($product->getData($sku), $relatedProducts)) {
184
+ continue;
185
+ }
186
+ $relatedProductInfo = $relatedProducts[$product->getData($sku)];
187
+ $relatedProductInfo['mpn'] = $product->getData($sku);
188
+ $relatedProductInfo['url'] = preg_replace('/\/\d+\/$/', "/" . $categoryId . "/", $product->getProductUrl());;
189
+ if (!array_key_exists($categoryId, $relatedProductsList)) {
190
+ $relatedProductsList[$categoryId] = array();
191
+ }
192
+ array_push($relatedProductsList[$categoryId], $relatedProductInfo);
193
+ }
194
+ } else {
195
+ if (!array_key_exists($product->getData($sku), $relatedProducts)) {
196
+ continue;
197
+ }
198
+ $relatedProductInfo = $relatedProducts[$product->getData($sku)];
199
+ $relatedProductInfo['mpn'] = $product->getData($sku);
200
+ $relatedProductInfo['url'] = preg_replace('/category\/\d+\/$/', '', $product->getProductUrl());;
201
+ if (!array_key_exists('a', $relatedProductsList)) {
202
+ $relatedProductsList['a'] = array();
203
+ }
204
+ array_push($relatedProductsList['a'], $relatedProductInfo);
205
+ }
206
+ }
207
+ return $relatedProductsList;
208
+ }
209
+ }
210
+
211
+ ?>
app/code/local/Iceshop/Icecatlive/Helper/Image.php ADDED
@@ -0,0 +1,49 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * Class retrieves images from icecatlive data table
4
+ *
5
+ */
6
+ class Iceshop_Icecatlive_Helper_Image extends Mage_Core_Helper_Abstract
7
+ {
8
+ /**
9
+ * Fetch Image URL from DB
10
+ * @param Mage_Catalog_Model_Product $_product
11
+ * @return string image URL
12
+ */
13
+ public function getImage($_product)
14
+ {
15
+
16
+ $_product = $_product->load($_product->getId());
17
+ $sku = $_product->getData(Mage::getStoreConfig('icecat_root/icecat/sku_field'));
18
+ $manufacturerId = $_product->getData(Mage::getStoreConfig('icecat_root/icecat/manufacturer'));
19
+
20
+ $connection = Mage::getSingleton('core/resource')->getConnection('core_read');
21
+ $query = $connection->select()
22
+ ->from(Mage::getSingleton('core/resource')->getTableName('eav_entity_type'), 'entity_type_id')
23
+ ->where('entity_type_code = ?', 'catalog_product')
24
+ ->limit(1);
25
+ $entityTypeId = $connection->fetchOne($query);
26
+ $attributeInfo = Mage::getResourceModel('eav/entity_attribute_collection')
27
+ ->setCodeFilter(Mage::getStoreConfig('icecat_root/icecat/manufacturer'))
28
+ ->setEntityTypeFilter($_product->getResource()->getTypeId())
29
+ ->getFirstItem();
30
+ switch ($attributeInfo->getData('backend_type')) {
31
+ case 'int':
32
+ $attribute = $attributeInfo->setEntity($_product->getResource());
33
+ $manufacturer = $attribute->getSource()->getOptionText($manufacturerId);
34
+ break;
35
+ default:
36
+ $manufacturer = $manufacturerId;
37
+ break;
38
+ }
39
+ $this->observer = Mage::getSingleton('icecatlive/observer');
40
+
41
+ $url = $this->observer->getImageURL($sku, $manufacturer, $_product->getId());
42
+ return $url;
43
+ }
44
+
45
+ public function getGallery()
46
+ {
47
+ return Mage::getSingleton('icecatlive/import')->getGalleryPhotos();
48
+ }
49
+ }
app/code/local/Iceshop/Icecatlive/Helper/Output.php ADDED
@@ -0,0 +1,179 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ class Iceshop_Icecatlive_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
+
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
+ $dbDescriptionPriority = false;
42
+ $dbShortDescriptionPriority = false;
43
+ $current_page = Mage::app()->getFrontController()->getRequest()->getControllerName();
44
+ if ($productDescriptionPriority == 'Db' && $attributeName == 'description') {
45
+ $dbDescriptionPriority = true;
46
+ }
47
+ if ($productShortDescrPriority == 'Db' && $attributeName == 'short_description') {
48
+ $dbShortDescriptionPriority = true;
49
+ }
50
+
51
+ if ($current_page == 'product') {
52
+
53
+ $bin_prod = new Iceshop_Icecatlive_Model_Catalog_Product();
54
+ if ($attributeName == 'description' || $attributeName == 'short_description') {
55
+ $descr = $bin_prod->checkIcecatProdDescription($productId, $attributeName);
56
+ }
57
+ }
58
+ $prod_source = Iceshop_Icecatlive_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
+ ) {
68
+ if ($attributeName == 'short_description') {
69
+ $attributeHtml = $product->getData('short_description');
70
+ }
71
+
72
+ if ($attributeName == 'description' && $attributeHtml == 1) {
73
+ $attributeHtml = $product->getData('description');
74
+ }
75
+ return parent::productAttribute($product, $attributeHtml, $attributeName);
76
+ }
77
+
78
+ $this->iceCatModel = Mage::getSingleton('icecatlive/import');
79
+
80
+ if ($this->isFirstTime) {
81
+ $helper = Mage::helper('icecatlive/getdata');
82
+ $helper->getProductDescription($product);
83
+
84
+ if ($helper->hasError() && $attributeName != 'name') {
85
+ $this->error = true;
86
+ }
87
+ $this->isFirstTime = false;
88
+ }
89
+
90
+ if ($this->error) {
91
+
92
+ if ($attributeName != 'description' && $attributeName != 'short_description') {
93
+ return parent::productAttribute($product, $attributeHtml, $attributeName);
94
+ } else {
95
+ return '';
96
+ }
97
+
98
+ }
99
+
100
+ $id = $product->getData('entity_id');
101
+
102
+ if ($attributeName == 'name' && $productNamePriority != 'Db') {
103
+ //if we on product page then mage::registry('product') exist
104
+ if ($product->getId() == $this->iceCatModel->entityId && $name = $this->iceCatModel->getProductName()) {
105
+ return $name;
106
+ } else if (!empty($descr)) {
107
+ return $descr;
108
+ }
109
+ $manufacturerId = Mage::getStoreConfig('icecat_root/icecat/manufacturer');
110
+ $mpn = Mage::getStoreConfig('icecat_root/icecat/sku_field');
111
+ $ean = Mage::getStoreConfig('icecat_root/icecat/ean_code');
112
+ $collection = Mage::getResourceModel('catalog/product_collection');
113
+ $collection->addAttributeToSelect($manufacturerId)->addAttributeToSelect($mpn)->addAttributeToSelect($ean)
114
+ ->addAttributeToSelect('name')
115
+ ->addAttributeToFilter('entity_id', array('eq' => $id));
116
+ $product = $collection->getFirstItem();
117
+ return $product->getName();
118
+ }
119
+
120
+ if ($attributeName == 'short_description' && !$dbShortDescriptionPriority) {
121
+
122
+ $icecat_descr = $this->iceCatModel->getShortProductDescription();
123
+ if (!empty($descr)) {
124
+ return $descr;
125
+ } else if (!empty($icecat_descr)) {
126
+ return $icecat_descr;
127
+ } else {
128
+ $attributeHtml = $product->getData('short_description');
129
+ return parent::productAttribute($product, $attributeHtml, $attributeName);
130
+ }
131
+ }
132
+
133
+ if ($attributeName == 'description' && !$dbDescriptionPriority) {
134
+
135
+ $icecat_full_descr = $this->iceCatModel->getFullProductDescription();
136
+
137
+ if (!empty($icecat_full_descr)) {
138
+ return str_replace("\\n", "<br>", $icecat_full_descr);
139
+ } else {
140
+ $attributeHtml = $product->getData('description');
141
+ }
142
+ }
143
+ return parent::productAttribute($product, $attributeHtml, $attributeName);
144
+ }
145
+
146
+
147
+ public function getWarrantyInfo()
148
+ {
149
+ return $this->iceCatModel->getWarrantyInfo();
150
+ }
151
+
152
+ public function getShortSummaryDescription()
153
+ {
154
+ return $this->iceCatModel->getShortSummaryDescription();
155
+ }
156
+
157
+ public function getLongSummaryDescription()
158
+ {
159
+ return $this->iceCatModel->getLongSummaryDescription();
160
+ }
161
+
162
+ public function getManualPDF()
163
+ {
164
+ return $this->iceCatModel->getManualPDF();
165
+ }
166
+
167
+ public function getPDF()
168
+ {
169
+ return $this->iceCatModel->getPDF();
170
+ }
171
+
172
+ public function getIceCatMedia()
173
+ {
174
+ $media = (array)$this->iceCatModel->getIceCatMedia();
175
+ return (array_key_exists('@attributes', $media)) ? $media['@attributes'] : array();
176
+ }
177
+ }
178
+
179
+ ?>
app/code/local/Iceshop/Icecatlive/Model/Catalog/Category.php ADDED
@@ -0,0 +1,19 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * class overrides category getProductCollection function to provide products with needed attributes
4
+ *
5
+ */
6
+ class Iceshop_Icecatlive_Model_Catalog_Category extends Mage_Catalog_Model_Category
7
+ {
8
+ /**
9
+ * add product manufacturer attribute to category collection
10
+ */
11
+ public function getProductCollection()
12
+ {
13
+ $collection = parent::getProductCollection();
14
+ $collection->addAttributeToSelect(Mage::getStoreConfig('icecat_root/icecat/manufacturer'));
15
+ return $collection;
16
+ }
17
+ }
18
+
19
+ ?>
app/code/local/Iceshop/Icecatlive/Model/Catalog/Product.php ADDED
@@ -0,0 +1,237 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * Class overrides base Product Model to provide products icecat data
4
+ *
5
+ */
6
+ class Iceshop_Icecatlive_Model_Catalog_Product extends Mage_Catalog_Model_Product
7
+ {
8
+
9
+ public function getName()
10
+ {
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
+ $ean_code = $this->getData(Mage::getStoreConfig('icecat_root/icecat/ean_code'));
23
+
24
+
25
+ $attributeInfo = Mage::getResourceModel('eav/entity_attribute_collection')
26
+ ->setCodeFilter(Mage::getStoreConfig('icecat_root/icecat/manufacturer'))
27
+ ->setEntityTypeFilter($this->getResource()->getTypeId())
28
+ ->getFirstItem();
29
+ switch ($attributeInfo->getData('backend_type')) {
30
+ case 'int':
31
+ $attribute = $attributeInfo->setEntity($this->getResource());
32
+ $manufacturer = $attribute->getSource()->getOptionText($manufacturerId);
33
+ break;
34
+ default:
35
+ $manufacturer = $manufacturerId;
36
+ break;
37
+ }
38
+ if(!empty($mpn) && !empty($manufacturer)){
39
+ $tableName = Mage::getSingleton('core/resource')->getTableName('icecatlive/data_products');
40
+ $selectCondition = $connection->select()
41
+ ->from(array('connector' => $tableName), new Zend_Db_Expr('connector.prod_title'))
42
+ ->where('connector.prod_id = ? ', $mpn)->where('connector.supplier_symbol = ? ', $manufacturer);
43
+ $icecatName = $connection->fetchOne($selectCondition);
44
+ }
45
+ if(empty($icecatName) && !empty($ean_code)){
46
+ $tableName = Mage::getSingleton('core/resource')->getTableName('icecatlive/data_products');
47
+ $selectCondition = $connection->select()
48
+ ->from(array('connector' => $tableName), new Zend_Db_Expr('connector.prod_title'))
49
+ ->where('connector.prod_ean = ? ', $ean_code);
50
+ $icecatName = $connection->fetchOne($selectCondition);
51
+ }
52
+ } catch (Exception $e) {
53
+ Mage::log('Icecat getName error' . $e);
54
+ }
55
+
56
+ $product_name = !empty($icecatName) ? $icecatName : parent::getName();
57
+
58
+ return $product_name;
59
+ }
60
+
61
+
62
+ public function getImage()
63
+ {
64
+ if (!parent::getImage() || parent::getImage() == 'no_selection') {
65
+ return "true";
66
+ } else {
67
+ return parent::getImage();
68
+ }
69
+ }
70
+
71
+ public function getShortDescription()
72
+ {
73
+
74
+ if (!isset(self::$_product_source)) {
75
+ $this->checkIcecatProdDescription();
76
+ }
77
+
78
+ $source = self::$_product_source;
79
+
80
+ if ('Icecat' == Mage::getStoreConfig('icecat_root/icecat/descript_priority') and $source != 'DB') {
81
+ return true;
82
+ } else {
83
+ return parent::getShortDescription();
84
+ }
85
+ }
86
+
87
+ public function getDescription()
88
+ {
89
+
90
+ if (!isset(self::$_product_source)) {
91
+ $this->checkIcecatProdDescription();
92
+ }
93
+
94
+ $source = self::$_product_source;
95
+
96
+
97
+ if ('Icecat' == Mage::getStoreConfig('icecat_root/icecat/descript_priority') and $source != 'DB') {
98
+ return true;
99
+ } else {
100
+ return parent::getDescription();
101
+ }
102
+ }
103
+
104
+ public function checkIcecatProdDescription($productId = '', $attributeName = '')
105
+ {
106
+
107
+ $iceImport = new Iceshop_Icecatlive_Model_Import();
108
+
109
+ if (empty($productId)) {
110
+ $productId = Mage::registry('current_product')->getId();
111
+ }
112
+
113
+
114
+ $model = Mage::getModel('catalog/product');
115
+ $_product = $model->load($productId);
116
+
117
+ $mpn = $_product->getData(Mage::getStoreConfig('icecat_root/icecat/sku_field'));
118
+ $ean_code = $_product->getData(Mage::getStoreConfig('icecat_root/icecat/ean_code'));
119
+ $manufacturerId = $_product->getData(Mage::getStoreConfig('icecat_root/icecat/manufacturer'));
120
+ $attributeInfo = Mage::getResourceModel('eav/entity_attribute_collection')
121
+ ->setCodeFilter(Mage::getStoreConfig('icecat_root/icecat/manufacturer'))
122
+ ->setEntityTypeFilter($this->getResource()->getTypeId())
123
+ ->getFirstItem();
124
+
125
+ if ($attributeInfo->getData('backend_type') == 'int' ||
126
+ ($attributeInfo->getData('frontend_input') == 'select' && $attributeInfo->getData('backend_type') == 'static')
127
+ ) {
128
+ $attribute = $attributeInfo->setEntity($_product->getResource());
129
+ $manufacturer = $attribute->getSource()->getOptionText($manufacturerId);
130
+ } else {
131
+ $manufacturer = $manufacturerId;
132
+ }
133
+ $locale = Mage::getStoreConfig('icecat_root/icecat/language');
134
+ if ($locale == '0') {
135
+ $systemLocale = explode("_", Mage::app()->getLocale()->getLocaleCode());
136
+ $locale = $systemLocale[0];
137
+ }
138
+ $userLogin = Mage::getStoreConfig('icecat_root/icecat/login');
139
+ $userPass = Mage::getStoreConfig('icecat_root/icecat/password');
140
+ $entityId = $_product->getEntityId();
141
+
142
+ $descr[1] = false;
143
+ $descr[0] = $iceImport->getProductDescription($mpn, $manufacturer, $locale, $userLogin, $userPass, $entityId, $ean_code);
144
+
145
+ if (!empty($iceImport->simpleDoc)) {
146
+
147
+ $productTag = $iceImport->simpleDoc->Product;
148
+ $descr[1] = (string)$productTag->ProductDescription['ShortDesc'];
149
+ } else if (!empty($descr[0]) && $attributeName == 'short_description') {
150
+ $descr[1] = $iceImport->getShortProductDescription();
151
+ }
152
+ if ($descr[0] == false and $descr[1] == false) {
153
+ self::$_product_source = 'DB';
154
+ } else if ($attributeName == 'short_description') {
155
+ self::$_product_source = '';
156
+ return $descr[1];
157
+ } else if ($attributeName == 'name') {
158
+ self::$_product_source = '';
159
+ return $iceImport->getProductName();
160
+ } else {
161
+ self::$_product_source = '';
162
+ }
163
+ }
164
+
165
+
166
+ /**
167
+ * Entity code.
168
+ * Can be used as part of method name for entity processing
169
+ */
170
+ const ENTITY = 'catalog_product';
171
+
172
+ const CACHE_TAG = 'catalog_product';
173
+ protected $_cacheTag = 'catalog_product';
174
+ protected $_eventPrefix = 'catalog_product';
175
+ protected $_eventObject = 'product';
176
+ protected $_canAffectOptions = false;
177
+
178
+ /**
179
+ * Product type instance
180
+ *
181
+ * @var Mage_Catalog_Model_Product_Type_Abstract
182
+ */
183
+ protected $_typeInstance = null;
184
+
185
+ /**
186
+ * Product type instance as singleton
187
+ */
188
+ protected $_typeInstanceSingleton = null;
189
+
190
+ /**
191
+ * Product link instance
192
+ *
193
+ * @var Mage_Catalog_Model_Product_Link
194
+ */
195
+ protected $_linkInstance;
196
+
197
+ /**
198
+ * Product object customization (not stored in DB)
199
+ *
200
+ * @var array
201
+ */
202
+ protected $_customOptions = array();
203
+
204
+ /**
205
+ * Product Url Instance
206
+ *
207
+ * @var Mage_Catalog_Model_Product_Url
208
+ */
209
+ protected $_urlModel = null;
210
+ protected static $_url;
211
+ protected static $_urlRewrite;
212
+ protected $_errors = array();
213
+ protected $_optionInstance;
214
+ protected $_options = array();
215
+
216
+ /**
217
+ * Product reserved attribute codes
218
+ */
219
+ protected $_reservedAttributes;
220
+
221
+ /**
222
+ * Flag for available duplicate function
223
+ *
224
+ * @var boolean
225
+ */
226
+ protected $_isDuplicable = true;
227
+
228
+ /**
229
+ * Source of product data
230
+ *
231
+ * @var string
232
+ */
233
+ public static $_product_source = '';
234
+
235
+ }
236
+
237
+ ?>
app/code/local/Iceshop/Icecatlive/Model/Catalog/Search.php ADDED
@@ -0,0 +1,15 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * class overrides search getProductCollection function to provide products with needed attributes
4
+ *
5
+ */
6
+ class Iceshop_Icecatlive_Model_Catalog_Search extends Mage_CatalogSearch_Model_Mysql4_Fulltext_Collection
7
+ {
8
+ public function _beforeLoad()
9
+ {
10
+ $this->addAttributeToSelect(Mage::getStoreConfig('icecat_root/icecat/manufacturer'));
11
+ return parent::_beforeLoad();
12
+ }
13
+ }
14
+
15
+ ?>
app/code/local/Iceshop/Icecatlive/Model/Imagescollection.php ADDED
@@ -0,0 +1,47 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ class Iceshop_Icecatlive_Model_Imagescollection extends Varien_Data_Collection
4
+ {
5
+
6
+ protected $_data = array();
7
+
8
+ public function __construct()
9
+ {
10
+ parent::__construct();
11
+
12
+ // not extends Varien_Object
13
+ $args = func_get_args();
14
+ if (empty($args[0])) {
15
+ $args[0] = array();
16
+ }
17
+ $this->_data = $args[0];
18
+ if (isset($this->_data['product'])) {
19
+
20
+ $helper = new Iceshop_Icecatlive_Helper_Image();
21
+ if (isset($this->_data['is_media']) && $this->_data['is_media']) {
22
+ // add product main image also
23
+ // @todo @someday if needed add product image also
24
+ }
25
+ $gallery = $helper->getGallery();
26
+
27
+ foreach ($gallery as $item) {
28
+ $this->addItem($this->convertIcecatImageToVarienObject($item));
29
+ }
30
+
31
+ }
32
+ }
33
+
34
+ private function convertIcecatImageToVarienObject($image)
35
+ {
36
+
37
+ $data = array(
38
+ 'file' => $image['pic'],
39
+ );
40
+ $item = new Varien_Object();
41
+ $item->addData($data);
42
+ return $item;
43
+ }
44
+
45
+ }
46
+
47
+ ?>
app/code/local/Iceshop/Icecatlive/Model/Import.php ADDED
@@ -0,0 +1,616 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * Class performs Curl request to ICEcat and fetches xml data with product description
4
+ *
5
+ */
6
+ class Iceshop_Icecatlive_Model_Import extends Mage_Core_Model_Abstract
7
+ {
8
+
9
+ public $entityId;
10
+ private $productDescriptionList = array();
11
+ private $productDescription;
12
+ private $fullProductDescription;
13
+ private $lowPicUrl;
14
+ private $highPicUrl;
15
+ private $errorMessage;
16
+ private $galleryPhotos = array();
17
+ private $productName;
18
+ private $relatedProducts = array();
19
+ private $thumb;
20
+ private $errorSystemMessage; //depricated
21
+ private $_cacheKey = 'iceshop_icecatlive_';
22
+
23
+ private $_warrantyInfo = '';
24
+ private $_shortSummaryDesc = '';
25
+ private $_longSummaryDesc = '';
26
+
27
+ private $_manualPdfUrl = '';
28
+ private $_pdfUrl = '';
29
+ private $_multimedia = '';
30
+
31
+ protected function _construct()
32
+ {
33
+ $this->_init('icecatlive/import');
34
+ }
35
+
36
+ /**
37
+ * Perform Curl request with corresponding param check and error processing
38
+ * @param int $productId
39
+ * @param string $vendorName
40
+ * @param string $locale
41
+ * @param string $userName
42
+ * @param string $userPass
43
+ */
44
+ public function getProductDescription($productId, $vendorName, $locale, $userName, $userPass, $entityId, $ean_code)
45
+ {
46
+ $current_page = Mage::app()->getFrontController()->getRequest()->getControllerName();
47
+
48
+ if($current_page == 'product'){
49
+
50
+ $this->entityId = $entityId;
51
+ $error = '';
52
+ if (null === $this->simpleDoc) {
53
+
54
+ if (!$cacheDataXml = Mage::app()->getCache()->load($this->_cacheKey . $entityId . '_' . $locale)) {
55
+
56
+ $dataUrl = 'http://data.icecat.biz/xml_s3/xml_server3.cgi';
57
+ $successRespondByMPNVendorFlag = false;
58
+ if (empty($userName)) {
59
+ $this->errorMessage = "No ICEcat login provided";
60
+ return false;
61
+ }
62
+ if (empty($userPass)) {
63
+ $this->errorMessage = "No ICEcat password provided";
64
+ return false;
65
+ }
66
+ if (empty($locale)) {
67
+ $this->errorMessage = "Please specify product description locale";
68
+ return false;
69
+ }
70
+ if ((empty($productId) && empty($ean_code))
71
+ || (empty($vendorName) && empty($ean_code))
72
+ ) {
73
+ $this->errorMessage = 'Given product has invalid IceCat data';
74
+ return false;
75
+ }
76
+
77
+ if (!empty($productId) && !empty($vendorName)) {
78
+
79
+ $resultString = $this->_getIceCatData($userName, $userPass, $dataUrl, array(
80
+ "prod_id" => $productId,
81
+ "lang" => $locale,
82
+ "vendor" => $vendorName,
83
+ "output" => 'productxml'
84
+ ));
85
+
86
+ if ($this->parseXml($resultString)) {
87
+ if (!$this->checkIcecatResponse()) {
88
+ $successRespondByMPNVendorFlag = true;
89
+ }
90
+ }
91
+
92
+ }
93
+ // if get data by MPN & brand name wrong => trying by Ean code
94
+ if (!$successRespondByMPNVendorFlag) {
95
+ if (!empty($ean_code)) {
96
+ $resultString = $this->_getIceCatData($userName, $userPass, $dataUrl, array(
97
+ 'ean_upc' => trim($ean_code),
98
+ 'lang' => $locale,
99
+ 'output' => 'productxml'
100
+ ));
101
+ if (!$this->parseXml($resultString)) {
102
+ $error = true;
103
+ $this->simpleDoc = null;
104
+ }
105
+ if ($this->checkIcecatResponse()) {
106
+ $error = true;
107
+ $this->simpleDoc = null;
108
+ }
109
+ } else {
110
+ $error = true;
111
+ }
112
+ if ($error) {
113
+ $this->errorMessage = 'Given product has invalid IceCat data';
114
+ return false;
115
+ }
116
+ }
117
+
118
+ Mage::app()->getCache()->save($resultString, $this->_cacheKey . $entityId . '_' . $locale);
119
+ } else {
120
+ $resultString = $cacheDataXml;
121
+
122
+ if (!$this->parseXml($resultString)) {
123
+ return false;
124
+ }
125
+ if ($this->checkIcecatResponse()) {
126
+ return false;
127
+ }
128
+ }
129
+
130
+ $this->loadProductDescriptionList();
131
+ $this->loadOtherProductParams($productId);
132
+ $this->loadGalleryPhotos();
133
+ Varien_Profiler::start('Iceshop FILE RELATED');
134
+ $this->loadRelatedProducts();
135
+ Varien_Profiler::stop('Iceshop FILE RELATED');
136
+ }
137
+ return true;
138
+ }
139
+ }
140
+
141
+ private function _getIceCatData($userName, $userPass, $dataUrl, $productAttributes)
142
+ {
143
+ try {
144
+
145
+ $webClient = new Zend_Http_Client();
146
+ $webClient->setUri($dataUrl);
147
+ $webClient->setMethod(Zend_Http_Client::GET);
148
+ $webClient->setHeaders('Content-Type: text/xml; charset=UTF-8');
149
+ $webClient->setParameterGet($productAttributes);
150
+ $webClient->setAuth($userName, $userPass, Zend_Http_CLient::AUTH_BASIC);
151
+ $response = $webClient->request();
152
+ if ($response->isError()) {
153
+ $this->errorMessage = 'Response Status: ' . $response->getStatus() . " Response Message: " . $response->getMessage();
154
+ return false;
155
+ }
156
+ } catch (Exception $e) {
157
+ $this->errorMessage = "Warning: cannot connect to ICEcat. {$e->getMessage()}";
158
+ return false;
159
+ }
160
+ return $response->getBody();
161
+ }
162
+
163
+ public function getSystemError()
164
+ {
165
+ return $this->errorSystemMessage;
166
+ }
167
+
168
+ public function getProductName()
169
+ {
170
+ return $this->productName;
171
+ }
172
+
173
+ public function getGalleryPhotos()
174
+ {
175
+
176
+ return $this->galleryPhotos;
177
+ }
178
+
179
+ public function getThumbPicture()
180
+ {
181
+ return $this->thumb;
182
+ }
183
+
184
+ public function getImg($productId)
185
+ {
186
+
187
+ $model = Mage::getModel('catalog/product');
188
+ $_product = $model->load($productId);
189
+ $entity_id = $_product->getEntityId();
190
+ $ean_code = $_product->getData(Mage::getStoreConfig('icecat_root/icecat/ean_code'));
191
+ $vendorName = $_product->getData(Mage::getStoreConfig('icecat_root/icecat/manufacturer'));
192
+ $locale = Mage::getStoreConfig('icecat_root/icecat/language');
193
+ if ($locale == '0') {
194
+ $systemLocale = explode("_", Mage::app()->getLocale()->getLocaleCode());
195
+ $locale = $systemLocale[0];
196
+ }
197
+ $userLogin = Mage::getStoreConfig('icecat_root/icecat/login');
198
+ $userPass = Mage::getStoreConfig('icecat_root/icecat/password');
199
+ $mpn = $_product->getData(Mage::getStoreConfig('icecat_root/icecat/sku_field'));
200
+ $this->getProductDescription($mpn, $vendorName, $locale, $userLogin, $userPass, $entity_id, $ean_code);
201
+ if ($this->simpleDoc) {
202
+ return $this->highPicUrl;
203
+ }
204
+ }
205
+
206
+ /**
207
+ * load Gallery array from XML
208
+ */
209
+ private function loadGalleryPhotos()
210
+ {
211
+ $Imagepriority = Mage::getStoreConfig('icecat_root/icecat/image_priority');
212
+ if($Imagepriority != 'Db'){
213
+ $galleryPhotos = $this->simpleDoc->Product->ProductGallery->ProductPicture;
214
+ if (!count($galleryPhotos)) {
215
+ return false;
216
+ }
217
+ foreach ($galleryPhotos as $photo) {
218
+ if ($photo["Size"] > 0) {
219
+ $picUrl = (string)$photo["Pic"];
220
+ if (!empty($picUrl) && strpos($picUrl, 'feature_logo') <= 0) {
221
+ $picHeight = (int)$photo["PicHeight"];
222
+ $picWidth = (int)$photo["PicWidth"];
223
+ $product_id = $this->entityId;
224
+ $image_saved_file = $this->saveImg($product_id, $picUrl, 'file');
225
+
226
+ array_push($this->galleryPhotos, array(
227
+ 'height' => $picHeight,
228
+ 'width' => $picWidth,
229
+ 'pic' => $image_saved_file
230
+ ));
231
+ }
232
+ }
233
+ }
234
+ }
235
+ }
236
+
237
+ public function getErrorMessage()
238
+ {
239
+ return $this->errorMessage;
240
+ }
241
+
242
+ /**
243
+ * Checks response XML for error messages
244
+ */
245
+ private function checkIcecatResponse()
246
+ {
247
+ $errorMessage = $this->simpleDoc->Product['ErrorMessage'];
248
+ if ($errorMessage != '') {
249
+ if (preg_match('/^No xml data/', $errorMessage)) {
250
+ $this->errorSystemMessage = $errorMessage;
251
+ return true;
252
+ }
253
+ if (preg_match('/^The specified vendor does not exist$/', $errorMessage)) {
254
+ $this->errorSystemMessage = $errorMessage;
255
+ return true;
256
+ }
257
+ $this->errorMessage = "Ice Cat Error: " . $errorMessage;
258
+ return true;
259
+ }
260
+ return false;
261
+ }
262
+
263
+ public function getProductDescriptionList()
264
+ {
265
+ return $this->productDescriptionList;
266
+ }
267
+
268
+ public function getShortProductDescription()
269
+ {
270
+ return $this->productDescription;
271
+ }
272
+
273
+ public function getFullProductDescription()
274
+ {
275
+ return $this->fullProductDescription;
276
+ }
277
+
278
+ public function getLowPicUrl()
279
+ {
280
+ return $this->highPicUrl;
281
+ }
282
+
283
+ public function getRelatedProducts()
284
+ {
285
+ return $this->relatedProducts;
286
+ }
287
+
288
+ public function getVendor()
289
+ {
290
+ return $this->vendor;
291
+ }
292
+
293
+ public function getMPN()
294
+ {
295
+ return $this->productId;
296
+ }
297
+
298
+ public function getEAN()
299
+ {
300
+ return $this->EAN;
301
+ }
302
+
303
+ public function getWarrantyInfo()
304
+ {
305
+ return $this->_warrantyInfo;
306
+ }
307
+
308
+ public function getShortSummaryDescription()
309
+ {
310
+ return $this->_shortSummaryDesc;
311
+ }
312
+
313
+ public function getLongSummaryDescription()
314
+ {
315
+ return $this->_longSummaryDesc;
316
+ }
317
+
318
+ public function getManualPDF()
319
+ {
320
+ return $this->_manualPdfUrl;
321
+ }
322
+
323
+ public function getPDF()
324
+ {
325
+ return $this->_pdfUrl;
326
+ }
327
+
328
+ public function getIceCatMedia()
329
+ {
330
+ return $this->_multimedia;
331
+ }
332
+
333
+ /**
334
+ * Form related products Array
335
+ */
336
+ private function loadRelatedProducts()
337
+ {
338
+ $relatedProductsArray = $this->simpleDoc->Product->ProductRelated;
339
+ if (count($relatedProductsArray)) {
340
+ foreach ($relatedProductsArray as $product) {
341
+ $productArray = array();
342
+ $productNS = $product->Product;
343
+ $productArray['name'] = (string)$productNS['Name'];
344
+ $productArray['thumb'] = (string)$productNS['ThumbPic'];
345
+ $mpn = (string)$productNS['Prod_id'];
346
+ $productSupplier = $productNS->Supplier;
347
+ $productSupplierId = (int)$productSupplier['ID'];
348
+ $productArray['supplier_thumb'] = 'http://images2.icecat.biz/thumbs/SUP' . $productSupplierId . '.jpg';
349
+ $productArray['supplier_name'] = (string)$productSupplier['Name'];
350
+ $this->relatedProducts[$mpn] = $productArray;
351
+ }
352
+ }
353
+ }
354
+
355
+ /**
356
+ * Form product feature Arrray
357
+ */
358
+ private function loadProductDescriptionList()
359
+ {
360
+ $descriptionArray = array();
361
+ $specGroups = $this->simpleDoc->Product->CategoryFeatureGroup;
362
+ $specFeatures = $this->simpleDoc->Product->ProductFeature;
363
+ foreach ($specFeatures as $feature) {
364
+ $id = (int)$feature['CategoryFeatureGroup_ID'];
365
+ $featureText = (string)$feature["Presentation_Value"];
366
+ $featureValue = (string)$feature["Value"];
367
+ $featureName = (string)$feature->Feature->Name["Value"];
368
+ if ($featureValue == 'Y' || $featureValue == 'N') {
369
+ $featureText = $featureValue;
370
+ }
371
+ foreach ($specGroups as $group) {
372
+ $groupId = (int)$group["ID"];
373
+ if ($groupId == $id) {
374
+ $groupName = (string)$group->FeatureGroup->Name["Value"];
375
+ $rating = (int)$group['No'];
376
+ $descriptionArray[$rating][$groupName][$featureName] = $featureText;
377
+ break;
378
+ }
379
+ }
380
+ }
381
+ krsort($descriptionArray);
382
+ $this->productDescriptionList = $descriptionArray;
383
+ }
384
+
385
+ /**
386
+ * Form Array of non feature-value product params
387
+ */
388
+ private function loadOtherProductParams($productId)
389
+ {
390
+ $productTag = $this->simpleDoc->Product;
391
+ $this->productDescription = (string)$productTag->ProductDescription['ShortDesc'];
392
+ $this->fullProductDescription = (string)$productTag->ProductDescription['LongDesc'];
393
+ $this->_warrantyInfo = (string)$productTag->ProductDescription['WarrantyInfo'];
394
+ $this->_shortSummaryDesc = (string)$productTag->SummaryDescription->ShortSummaryDescription;
395
+ $this->_longSummaryDesc = (string)$productTag->SummaryDescription->LongSummaryDescription;
396
+ $this->_manualPdfUrl = (string)$productTag->ProductDescription['ManualPDFURL'];
397
+ $this->_pdfUrl = (string)$productTag->ProductDescription['PDFURL'];
398
+ $this->_multimedia = $productTag->ProductMultimediaObject->MultimediaObject;
399
+
400
+ $Imagepriority = Mage::getStoreConfig('icecat_root/icecat/image_priority');
401
+ if ($Imagepriority != 'Db') {
402
+ if (!empty($productTag["HighPic"])) {
403
+ $this->highPicUrl = $this->saveImg($this->entityId, (string)$productTag["HighPic"], 'image');
404
+ } else if (!empty($productTag["LowPic"])) {
405
+ $this->lowPicUrl = $this->saveImg($this->entityId, (string)$productTag["LowPic"], 'small');
406
+ } else {
407
+ $this->thumb = $this->saveImg($this->entityId, (string)$productTag["ThumbPic"], 'thumb');
408
+ }
409
+ }
410
+ $this->productName = (string)$productTag["Title"];
411
+ $this->productId = (string)$productTag['Prod_id'];
412
+ $this->vendor = (string)$productTag->Supplier['Name'];
413
+ $prodEAN = $productTag->EANCode;
414
+ $EANstr = '';
415
+ $EANarr = null;
416
+ $j = 0; //counter
417
+ foreach ($prodEAN as $ellEAN) {
418
+ $EANarr[] = $ellEAN['EAN'];
419
+ $j++;
420
+ }
421
+ $i = 0;
422
+ $str = '';
423
+ for ($i = 0; $i < $j; $i++) {
424
+ $g = $i % 2;
425
+ if ($g == '0') {
426
+ if ($j == 1) {
427
+ $str .= $EANarr[$i] . '<br>';
428
+ } else {
429
+ $str .= $EANarr[$i] . ', ';
430
+ }
431
+ } else {
432
+ if ($i != $j - 1) {
433
+ $str .= $EANarr[$i] . ', <br>';
434
+ } else {
435
+ $str .= $EANarr[$i] . ' <br>';
436
+ }
437
+ }
438
+ }
439
+ $this->EAN = $str;
440
+ }
441
+
442
+ /**
443
+ * parse response XML: to SimpleXml
444
+ * @param string $stringXml
445
+ */
446
+ private function parseXml($stringXml)
447
+ {
448
+ $current_page = Mage::app()->getFrontController()->getRequest()->getControllerName();
449
+
450
+ if($current_page == 'product'){
451
+ libxml_use_internal_errors(true);
452
+ $this->simpleDoc = simplexml_load_string($stringXml);
453
+ if ($this->simpleDoc) {
454
+ return true;
455
+ }
456
+ $this->simpleDoc = simplexml_load_string(utf8_encode($stringXml));
457
+ if ($this->simpleDoc) {
458
+ return true;
459
+ }
460
+ }
461
+ return false;
462
+ }
463
+
464
+ /**
465
+ * save icecat img
466
+ * @param int $productId
467
+ * @param string $img_url
468
+ * @param string $img_type
469
+ */
470
+ public function saveImg($productId, $img_url, $imgtype = '')
471
+ {
472
+ $pathinfo = pathinfo($img_url);
473
+ $img_type = $pathinfo["extension"];
474
+
475
+ if (strpos($img_url, 'high') > 0) {
476
+ $img_name = str_replace("http://images.icecat.biz/img/norm/high/", "", $img_url);
477
+ $img_name = md5($img_name);
478
+ } else if (strpos($img_url, 'low') > 0) {
479
+ $img_name = str_replace("http://images.icecat.biz/img/norm/low/", "", $img_url);
480
+ $img_name = md5($img_name);
481
+ } else {
482
+ $img_name = md5($img_url);
483
+ }
484
+
485
+ $img = $img_name . "." . $img_type;
486
+ $baseDir = Mage::getSingleton('catalog/product_media_config')->getBaseMediaPath() . '/';
487
+ $local_img = strstr($img_url, Mage::getStoreConfig('web/unsecure/base_url'));
488
+
489
+ if (!file_exists($baseDir . $img) && !$local_img) {
490
+ $client = new Zend_Http_Client($img_url);
491
+ $content = $client->request();
492
+ if ($content->isError()) {
493
+ return $img_url;
494
+ }
495
+ $file = file_put_contents($baseDir . $img, $content->getBody());
496
+ if ($file) {
497
+ $this->addProductImageQuery($productId, $img, $imgtype);
498
+ return $img;
499
+ } else {
500
+ return $img_url;
501
+ }
502
+ } else if ($local_img) {
503
+ return $img_url;
504
+ } else {
505
+
506
+ $db = Mage::getSingleton('core/resource')->getConnection('core_write');
507
+ $tablePrefix = (array)Mage::getConfig()->getTablePrefix();
508
+ if (!empty($tablePrefix[0])) {
509
+ $tablePrefix = $tablePrefix[0];
510
+ } else {
511
+ $tablePrefix = '';
512
+ }
513
+ $attr_query = "SELECT @product_entity_type_id := `entity_type_id` FROM `" . $tablePrefix . "eav_entity_type` WHERE
514
+ entity_type_code = 'catalog_product';
515
+ SELECT @attribute_set_id := `entity_type_id` FROM `" . $tablePrefix . "eav_entity_type` WHERE
516
+ entity_type_code = 'catalog_product';
517
+ SELECT @gallery := `attribute_id` FROM `" . $tablePrefix . "eav_attribute` WHERE
518
+ `attribute_code` = 'media_gallery' AND entity_type_id = @product_entity_type_id;
519
+ SELECT @base := `attribute_id` FROM `" . $tablePrefix . "eav_attribute` WHERE `attribute_code` = 'image' AND entity_type_id = @product_entity_type_id;
520
+ SELECT @small := `attribute_id` FROM `" . $tablePrefix . "eav_attribute` WHERE
521
+ `attribute_code` = 'small_image' AND entity_type_id = @product_entity_type_id;
522
+ SELECT @thumb := `attribute_id` FROM `" . $tablePrefix . "eav_attribute` WHERE
523
+ `attribute_code` = 'thumbnail' AND entity_type_id = @product_entity_type_id;";
524
+
525
+ $attr_set = Mage::getModel('catalog/product')->getResource()->getEntityType()->getDefaultAttributeSetId();
526
+
527
+ $db->query($attr_query, array(':attribute_set' => $attr_set));
528
+
529
+ $img_check = $db->fetchAll("SELECT COUNT(*) FROM `" . $tablePrefix . "catalog_product_entity_varchar`
530
+ WHERE attribute_id IN (@base ,@small,@thumb)
531
+ AND entity_id =:entity_id AND value =:img ", array(
532
+ ':entity_id' => $productId,
533
+ ':img' => $img));
534
+
535
+ $gal_check = $db->fetchAll("SELECT COUNT(*) FROM `" . $tablePrefix . "catalog_product_entity_media_gallery`
536
+ WHERE attribute_id = @gallery AND entity_id =:entity_id AND value =:img ", array(
537
+ ':entity_id' => $productId,
538
+ ':img' => $img));
539
+ if ((isset($img_check[0]["COUNT(*)"]) && isset($gal_check[0]["COUNT(*)"]))
540
+ && ($img_check[0]["COUNT(*)"] == 0 && $gal_check[0]["COUNT(*)"] == 0)
541
+ ) {
542
+ $this->addProductImageQuery($productId, $img, $imgtype);
543
+ }
544
+ return $img;
545
+ }
546
+ }
547
+
548
+ public function addProductImageQuery($productId, $img, $type = '')
549
+ {
550
+ $db = Mage::getSingleton('core/resource')->getConnection('core_write');
551
+ $tablePrefix = (array)Mage::getConfig()->getTablePrefix();
552
+ if (!empty($tablePrefix[0])) {
553
+ $tablePrefix = $tablePrefix[0];
554
+ } else {
555
+ $tablePrefix = '';
556
+ }
557
+
558
+ $attr_query = "SELECT @product_entity_type_id := `entity_type_id` FROM `" . $tablePrefix . "eav_entity_type` WHERE
559
+ entity_type_code = 'catalog_product';
560
+ SELECT @attribute_set_id := `entity_type_id` FROM `" . $tablePrefix . "eav_entity_type` WHERE
561
+ entity_type_code = 'catalog_product';
562
+ SELECT @gallery := `attribute_id` FROM `" . $tablePrefix . "eav_attribute` WHERE
563
+ `attribute_code` = 'media_gallery' AND entity_type_id = @product_entity_type_id;
564
+ SELECT @base := `attribute_id` FROM `" . $tablePrefix . "eav_attribute` WHERE `attribute_code` = 'image' AND entity_type_id = @product_entity_type_id;
565
+ SELECT @small := `attribute_id` FROM `" . $tablePrefix . "eav_attribute` WHERE
566
+ `attribute_code` = 'small_image' AND entity_type_id = @product_entity_type_id;
567
+ SELECT @thumb := `attribute_id` FROM `" . $tablePrefix . "eav_attribute` WHERE
568
+ `attribute_code` = 'thumbnail' AND entity_type_id = @product_entity_type_id;";
569
+
570
+ $db->query($attr_query, array(':attribute_set' => Mage::getModel('catalog/product')->getResource()->getEntityType()->getDefaultAttributeSetId()));
571
+
572
+ $DefaultStoreId = 0;
573
+
574
+ if (empty($type) || $type == 'image') {
575
+
576
+ $db->query(" INSERT INTO `" . $tablePrefix . "catalog_product_entity_varchar`
577
+ (entity_type_id,attribute_id,store_id,entity_id,value)
578
+ VALUES(@product_entity_type_id,@base,:store_id,:entity_id,:img )
579
+ ON DUPLICATE KEY UPDATE value = :img", array(
580
+ ':store_id' => $DefaultStoreId,
581
+ ':entity_id' => $productId,
582
+ ':img' => $img));
583
+
584
+ $db->query(" INSERT INTO `" . $tablePrefix . "catalog_product_entity_varchar`
585
+ (entity_type_id,attribute_id,store_id,entity_id,value)
586
+ VALUES(@product_entity_type_id,@small,:store_id,:entity_id,:img )
587
+ ON DUPLICATE KEY UPDATE value = :img", array(
588
+ ':store_id' => $DefaultStoreId,
589
+ ':entity_id' => $productId,
590
+ ':img' => $img));
591
+
592
+ $db->query(" INSERT INTO `" . $tablePrefix . "catalog_product_entity_varchar`
593
+ (entity_type_id,attribute_id,store_id,entity_id,value)
594
+ VALUES(@product_entity_type_id,@thumb,:store_id,:entity_id,:img )
595
+ ON DUPLICATE KEY UPDATE value = :img", array(
596
+ ':store_id' => $DefaultStoreId,
597
+ ':entity_id' => $productId,
598
+ ':img' => $img));
599
+ }
600
+
601
+
602
+ $db->query(" INSERT INTO `" . $tablePrefix . "catalog_product_entity_media_gallery` (attribute_id,entity_id,value)
603
+ VALUES(@gallery,:entity_id,:img )", array(
604
+ ':entity_id' => $productId,
605
+ ':img' => $img));
606
+ $db->query(" INSERT INTO `" . $tablePrefix . "catalog_product_entity_media_gallery_value`
607
+ (value_id,store_id,label,position,disabled)
608
+ VALUES(LAST_INSERT_ID(),:store_id,'',1,0 )", array(
609
+ ':store_id' => $DefaultStoreId));
610
+
611
+
612
+ }
613
+
614
+ }
615
+
616
+ ?>
app/code/local/Iceshop/Icecatlive/Model/Observer.php ADDED
@@ -0,0 +1,493 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * Class provides category page with images, cron processing
4
+ *
5
+ *
6
+ */
7
+ class Iceshop_Icecatlive_Model_Observer
8
+ {
9
+ /**
10
+ * Our process ID.
11
+ */
12
+ private $process_id = 'iceshop_icecat';
13
+ private $indexProcess;
14
+
15
+
16
+ private $errorMessage;
17
+ private $connection;
18
+ private $freeExportURLs = 'http://data.icecat.biz/export/freeurls/export_urls_rich.txt.gz';
19
+ private $fullExportURLs = 'http://data.icecat.biz/export/export_urls_rich.txt.gz';
20
+ private $productinfoUrL = 'http://data.icecat.biz/prodid/prodid_d.txt.gz';
21
+ protected $_supplierMappingUrl = 'http://data.icecat.biz/export/freeurls/supplier_mapping.xml';
22
+ protected $_connectorDir = '/iceshop/icecatlive/';
23
+ protected $_productFile;
24
+ protected $_supplierFile;
25
+
26
+ protected function _construct()
27
+ {
28
+ $this->_init('icecatlive/observer');
29
+ }
30
+
31
+ /**
32
+ * root method for uploading images to DB
33
+ */
34
+ public function load()
35
+ {
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
+ $importlogFile = Mage::getBaseDir('var') . $this->_connectorDir . 'import.log';
53
+ $importlogHandler = fopen($importlogFile, "w");
54
+
55
+ fwrite($importlogHandler, "Downloading product data file (export_urls_rich.txt.gz)\n");
56
+ $this->downloadFile($this->_productFile, $loadUrl);
57
+
58
+ fwrite($importlogHandler, "Downloading supplier mapping file (supplier_mapping.xml)\n");
59
+ $this->downloadFile($this->_supplierFile, $this->_supplierMappingUrl);
60
+ $this->XMLfile = Mage::getBaseDir('var') . $this->_connectorDir . basename($loadUrl, ".gz");
61
+
62
+ fwrite($importlogHandler, "Unzipping files\n");
63
+ $this->unzipFile();
64
+
65
+ fwrite($importlogHandler, "Importing supplier mapping (supplier_mapping.xml) to database\n");
66
+ $this->_loadSupplierListToDb();
67
+
68
+ fwrite($importlogHandler, "Importing products data (export_urls_rich.txt) to database\n");
69
+ $this->loadFileToDb();
70
+
71
+ //Start load product data file
72
+ $loadUrl = $this->productinfoUrL;
73
+ $this->_productFile = $this->_prepareFile(basename($loadUrl));
74
+
75
+ fwrite($importlogHandler, "Downloading additional product data file (prodid_d.txt.gz)\n");
76
+ $this->downloadFile($this->_productFile, $loadUrl);
77
+
78
+ fwrite($importlogHandler, "Unzipping additional product data file\n");
79
+ $this->unzipFile();
80
+
81
+ fwrite($importlogHandler, "Importing additional product data (prodid_d.txt.gz) to database\n");
82
+ $this->loadInfoFileToDb();
83
+ fwrite($importlogHandler, "Import process complete.\n");
84
+
85
+ $this->indexProcess->unlock();
86
+ fclose ($importlogHandler);
87
+ } catch (Exception $e) {
88
+ echo $e->getMessage();
89
+ Mage::log($e->getMessage());
90
+ }
91
+ }
92
+
93
+ /**
94
+ * parse given XML to SIMPLE XML
95
+ * @param string $stringXml
96
+ */
97
+ protected function _parseXml($stringXml)
98
+ {
99
+ libxml_use_internal_errors(true);
100
+ $simpleDoc = simplexml_load_string($stringXml);
101
+ if ($simpleDoc) {
102
+ return $simpleDoc;
103
+ }
104
+ $simpleDoc = simplexml_load_string(utf8_encode($stringXml));
105
+ if ($simpleDoc) {
106
+ return $simpleDoc;
107
+ }
108
+ return false;
109
+ }
110
+
111
+ /**
112
+ * Upload supplier mapping list to Database
113
+ */
114
+ protected function _loadSupplierListToDb()
115
+ {
116
+ $connection = $this->getDbConnection();
117
+ $mappingTable = Mage::getSingleton('core/resource')->getTableName('icecatlive/supplier_mapping');
118
+ try {
119
+ $connection->beginTransaction();
120
+ $xmlString = file_get_contents($this->_supplierFile);
121
+ $xmlDoc = $this->_parseXml($xmlString);
122
+ if ($xmlDoc) {
123
+ $connection->query("DROP TABLE IF EXISTS `" . $mappingTable . "_temp`");
124
+ $connection->query("
125
+ CREATE TABLE `" . $mappingTable . "_temp` (
126
+ `supplier_id` int(11) NOT NULL,
127
+ `supplier_symbol` varchar(255) DEFAULT NULL,
128
+ KEY `supplier_id` (`supplier_id`)
129
+ ) ENGINE=InnoDB DEFAULT CHARSET=utf8
130
+ ");
131
+ $sql = '';
132
+ $counter = 1;
133
+ $max_counter = 1000;
134
+ $supplierList = $xmlDoc->SupplierMappings->SupplierMapping;
135
+ foreach ($supplierList as $supplier) {
136
+ $supplierSymbolList = $supplier->Symbol;
137
+ $supplierId = $supplier['supplier_id'];
138
+ $supplierName = addslashes((string)$supplier['name']);
139
+ if ($counter == 1) {
140
+ $sql = " INSERT INTO " . $mappingTable . "_temp ( supplier_id, supplier_symbol ) VALUES('" . $supplierId . "', '" . $supplierName . "') ";
141
+ } else if ($counter % $max_counter == 0) {
142
+ $connection->query($sql);
143
+ $sql = " INSERT INTO " . $mappingTable . "_temp ( supplier_id, supplier_symbol ) VALUES('" . $supplierId . "', '" . $supplierName . "') ";
144
+ } else {
145
+ $sql .= " , ('" . $supplierId . "', '" . $supplierName . "') ";
146
+ }
147
+ foreach ($supplierSymbolList as $symbol) {
148
+ $symbolName = addslashes((string)$symbol);
149
+ if ($counter == 1) {
150
+ $sql = " INSERT INTO " . $mappingTable . "_temp ( supplier_id, supplier_symbol ) VALUES('" . $supplierId . "', '" . $symbolName . "') ";
151
+ } else if ($counter % $max_counter == 0) {
152
+ $connection->query($sql);
153
+ $sql = " INSERT INTO " . $mappingTable . "_temp ( supplier_id, supplier_symbol ) VALUES('" . $supplierId . "', '" . $symbolName . "') ";
154
+ } else {
155
+ $sql .= " , ('" . $supplierId . "', '" . $symbolName . "') ";
156
+ }
157
+ $counter++;
158
+ }
159
+ $counter++;
160
+ }
161
+ $connection->query($sql);
162
+ $connection->query("DROP TABLE IF EXISTS `" . $mappingTable . "_old`");
163
+ $connection->query("rename table `" . $mappingTable . "` to `" . $mappingTable . "_old`, `" . $mappingTable . "_temp` to " . $mappingTable);
164
+ $connection->query("DROP TABLE IF EXISTS `" . $mappingTable . "_old`");
165
+ $connection->commit();
166
+ } else {
167
+ throw new Exception('Unable to process supplier file');
168
+ }
169
+ } catch (Exception $e) {
170
+ $connection->rollBack();
171
+ throw new Exception("Icecat Import Terminated: {$e->getMessage()}");
172
+ }
173
+ }
174
+
175
+ /**
176
+ * retrieve URL of data file that corresponds ICEcat account
177
+ */
178
+ private function getLoadURL()
179
+ {
180
+ $subscripionLevel = Mage::getStoreConfig('icecat_root/icecat/icecat_type');
181
+
182
+ if ($subscripionLevel === 'full') {
183
+ return $this->fullExportURLs;
184
+ } else {
185
+ return $this->freeExportURLs;
186
+ }
187
+ }
188
+
189
+ /**
190
+ * return error messages
191
+ */
192
+ public function getErrorMessage()
193
+ {
194
+ return $this->errorMessage;
195
+ }
196
+
197
+ /**
198
+ * getImage URL from DB
199
+ * @param string $productSku
200
+ * @param string $productManufacturer
201
+ */
202
+ public function getImageURL($productSku, $productManufacturer, $productId = '')
203
+ {
204
+
205
+ $connection = $this->getDbConnection();
206
+ try {
207
+
208
+ $dataTable = Mage::getSingleton('core/resource')->getTableName('icecatlive/data');
209
+ $data_productsTable = Mage::getSingleton('core/resource')->getTableName('icecatlive/data_products');
210
+ $mappingTable = Mage::getSingleton('core/resource')->getTableName('icecatlive/supplier_mapping');
211
+ $model = Mage::getModel('catalog/product');
212
+ $_product = $model->load($productId);
213
+ $ean_code = $_product->getData(Mage::getStoreConfig('icecat_root/icecat/ean_code'));
214
+ $imageURL = '';
215
+
216
+ if (isset($productManufacturer) && !empty($productManufacturer)) {
217
+ $selectCondition = $connection->select()
218
+ ->from(array('connector' => $dataTable), new Zend_Db_Expr('connector.prod_img'))
219
+ ->joinInner(array('supplier' => $mappingTable), "connector.supplier_id = supplier.supplier_id AND supplier.supplier_symbol = {$this->connection->quote($productManufacturer)}")
220
+ ->where('connector.prod_id = ?', $productSku);
221
+ $imageURL = $connection->fetchOne($selectCondition);
222
+ }
223
+ if (empty($imageURL) && !empty($ean_code)) {
224
+ $selectCondition = $connection->select()
225
+ ->from(array('connector' => $dataTable), new Zend_Db_Expr('connector.prod_img'))
226
+ ->joinLeft(array('products' => $data_productsTable), "connector.prod_id = products.prod_id")
227
+ ->where('products.prod_ean = ?', trim($ean_code));
228
+ $imageURL = $connection->fetchOne($selectCondition);
229
+ }
230
+
231
+ if (!empty($imageURL)) {
232
+ $iceCatModel = Mage::getSingleton('icecatlive/import');
233
+
234
+ if (isset($productId) && !empty($productId)) {
235
+ $imageURL = $iceCatModel->saveImg($productId, $imageURL, 'image');
236
+ }
237
+ }
238
+
239
+ if (empty($imageURL)) {
240
+ $this->errorMessage = "Given product id is not present in database";
241
+ return $imageURL;
242
+ }
243
+ return $imageURL;
244
+ } catch (Exception $e) {
245
+ $this->errorMessage = "DB ERROR: {$e->getMessage()}";
246
+ return false;
247
+ }
248
+ }
249
+
250
+ /**
251
+ * Singletong for DB connection
252
+ */
253
+ private function getDbConnection()
254
+ {
255
+ if ($this->connection) {
256
+ return $this->connection;
257
+ }
258
+ $this->connection = Mage::getSingleton('core/resource')->getConnection('core_read');
259
+
260
+ return $this->connection;
261
+ }
262
+
263
+ /**
264
+ * Upload Data file to DP
265
+ */
266
+ private function loadFileToDb()
267
+ {
268
+ $connection = $this->getDbConnection();
269
+ $dataTable = Mage::getSingleton('core/resource')->getTableName('icecatlive/data');
270
+
271
+ $max_counter = 1000;
272
+ try {
273
+ $connection->beginTransaction();
274
+ $fileHandler = fopen($this->XMLfile, "r");
275
+ if ($fileHandler) {
276
+ $connection->query("DROP TABLE IF EXISTS `" . $dataTable . "_temp`");
277
+ $connection->query("
278
+ CREATE TABLE `" . $dataTable . "_temp` (
279
+ `prod_id` varchar(255) NOT NULL,
280
+ `supplier_id` int(11) DEFAULT NULL,
281
+ `prod_name` varchar(255) DEFAULT NULL,
282
+ `prod_img` varchar(255) DEFAULT NULL,
283
+ KEY `PRODUCT_MPN` (`prod_id`),
284
+ KEY `supplier_id` (`supplier_id`)
285
+ ) ENGINE=InnoDB DEFAULT CHARSET=utf8
286
+ ");
287
+
288
+ $counter = 0;
289
+ $sql = "";
290
+ while (!feof($fileHandler)) {
291
+ $row = fgets($fileHandler);
292
+ $oneLine = explode("\t", $row);
293
+
294
+ if ($oneLine[0] != 'product_id' && $oneLine[0] != '') {
295
+
296
+ try {
297
+
298
+ $prod_id = (!empty($oneLine[1])) ? addslashes($oneLine[1]) : '';
299
+ if(!empty($oneLine[5])){
300
+ $prod_img = addslashes($oneLine[5]);
301
+ }elseif(!empty($oneLine[6])){
302
+ $prod_img = addslashes($oneLine[6]);
303
+ }elseif(!empty($oneLine[7])){
304
+ $prod_img = addslashes($oneLine[7]);
305
+ }else{
306
+ $prod_img = '';
307
+ }
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 " . $dataTable . "_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
+ $connection->query($sql);
315
+ $sql = " INSERT INTO " . $dataTable . "_temp ( prod_id, supplier_id, prod_name, prod_img ) VALUES('" . $prod_id . "', '" . $supplier_id . "', '" . $prod_name . "', '" . $prod_img . "') ";
316
+ } else {
317
+ $sql .= " , ('" . $prod_id . "', '" . $supplier_id . "', '" . $prod_name . "', '" . $prod_img . "') ";
318
+ }
319
+
320
+ } catch (Exception $e) {
321
+ Mage::log("connector issue: {$e->getMessage()}");
322
+ }
323
+ }
324
+ $counter++;
325
+ }
326
+ $connection->query($sql);
327
+ $connection->query("DROP TABLE IF EXISTS `" . $dataTable . "_old`");
328
+ $connection->query("RENAME TABLE `" . $dataTable . "` TO `" . $dataTable . "_old`, `" . $dataTable . "_temp` TO " . $dataTable);
329
+ $connection->query("DROP TABLE IF EXISTS `" . $dataTable . "_old`");
330
+ $connection->commit();
331
+ fclose($fileHandler);
332
+ }
333
+ } catch (Exception $e) {
334
+ $connection->rollBack();
335
+ throw new Exception("Icecat Import Terminated: {$e->getMessage()}");
336
+ }
337
+ }
338
+
339
+ /**
340
+ * Upload Data file to DP
341
+ */
342
+ private function loadInfoFileToDb()
343
+ {
344
+ $connection = $this->getDbConnection();
345
+ $data_productsTable = Mage::getSingleton('core/resource')->getTableName('icecatlive/data_products');
346
+ $max_counter = 1000;
347
+ try {
348
+ $connection->beginTransaction();
349
+ $fileHandler = fopen($this->XMLfile, "r");
350
+ if ($fileHandler) {
351
+
352
+ $connection->query("DROP TABLE IF EXISTS `" . $data_productsTable . "`");
353
+ $connection->query("
354
+ CREATE TABLE `" . $data_productsTable . "` (
355
+ `prod_id` varchar(255) NOT NULL,
356
+ `supplier_symbol` varchar(255) DEFAULT NULL,
357
+ `prod_title` varchar(255) DEFAULT NULL,
358
+ `prod_ean` varchar(255) NOT NULL,
359
+ KEY `prod_id` (`prod_id`),
360
+ KEY `PRODUCT_EAN` (`prod_ean`),
361
+ INDEX `mpn_brand` (`prod_id`, `supplier_symbol`)
362
+ ) ENGINE=InnoDB DEFAULT CHARSET=utf8
363
+ ");
364
+
365
+ $counter = 1;
366
+ $sql = "";
367
+ while (!feof($fileHandler)) {
368
+ $row = fgets($fileHandler);
369
+ $oneLine = explode("\t", $row);
370
+
371
+ if ($oneLine[0] != 'Part number') {
372
+ try {
373
+ $oneLine3 = trim($oneLine[3]);
374
+ $oneLine15 = trim($oneLine[15]);
375
+ $oneLine24 = trim($oneLine[24]);
376
+ if (!empty($oneLine15)) {
377
+ $eans = explode(';', $oneLine15);
378
+ }
379
+ $prod_id = (!empty($oneLine[0])) ? addslashes(str_replace("\t", '', $oneLine[0])) : '';
380
+ $brand = (!empty($oneLine3)) ? addslashes(str_replace("\t", '', $oneLine3)) : '';
381
+ $title = (!empty($oneLine24)) ? addslashes(str_replace("\t", '', $oneLine24)) : '';
382
+ if (is_array($eans) && !empty($eans)){
383
+ foreach($eans as $prod_ean){
384
+ if ($counter == 1) {
385
+ $sql .= " INSERT INTO " . $data_productsTable . " ( prod_id, supplier_symbol, prod_title, prod_ean ) VALUES('" . $prod_id . "', '" . $brand . "', '" . $title. "', '" . $prod_ean . "') ";
386
+ } else if ($counter % $max_counter == 0) {
387
+ $connection->query($sql);
388
+ $sql = " INSERT INTO " . $data_productsTable . " ( prod_id, supplier_symbol, prod_title, prod_ean ) VALUES('" . $prod_id . "', '" . $brand . "', '" . $title . "', '" . $prod_ean . "') ";
389
+ } else {
390
+ $sql .= " , ('" . $prod_id . "', '" . $brand . "', '" . $title . "', '" . $prod_ean . "') ";
391
+ }
392
+ $counter++;
393
+ }
394
+ }else{
395
+ $prod_ean = !empty($eans) ? $eans : '';
396
+ if ($counter == 1) {
397
+ $sql .= " INSERT INTO " . $data_productsTable . " ( prod_id, supplier_symbol, prod_title, prod_ean ) VALUES('" . $prod_id . "', '" . $brand . "', '" . $title. "', '" . $prod_ean . "') ";
398
+ } else if ($counter % $max_counter == 0) {
399
+ $connection->query($sql);
400
+ $sql = " INSERT INTO " . $data_productsTable . " ( prod_id, supplier_symbol, prod_title, prod_ean ) VALUES('" . $prod_id . "', '" . $brand . "', '" . $title . "', '" . $prod_ean . "') ";
401
+ } else {
402
+ $sql .= " , ('" . $prod_id . "', '" . $brand . "', '" . $title . "', '" . $prod_ean . "') ";
403
+ }
404
+ $counter++;
405
+ }
406
+ } catch (Exception $e) {
407
+ Mage::log("connector issue: {$e->getMessage()}");
408
+ }
409
+ }
410
+ }
411
+ $connection->query($sql);
412
+ $connection->commit();
413
+ fclose($fileHandler);
414
+ }
415
+ } catch (Exception $e) {
416
+ $connection->rollBack();
417
+ throw new Exception("Icecat Import Terminated: {$e->getMessage()}");
418
+ }
419
+ }
420
+
421
+ /**
422
+ * unzip Uploaded file
423
+ */
424
+ private function unzipFile()
425
+ {
426
+ $gz = gzopen($this->_productFile, 'rb');
427
+ if (file_exists($this->XMLfile)) {
428
+ unlink($this->XMLfile);
429
+ }
430
+ $fileToWrite = @fopen($this->XMLfile, 'w+');
431
+ if (!$fileToWrite) {
432
+ $this->errorMessage = 'Unable to open output txt file. Please remove all *.txt files from ' .
433
+ Mage::getBaseDir('var') . $this->_connectorDir . 'folder';
434
+ return false;
435
+ }
436
+ while (!gzeof($gz)) {
437
+ $buffer = gzgets($gz, 100000);
438
+ fputs($fileToWrite, $buffer);
439
+ }
440
+ gzclose($gz);
441
+ fclose($fileToWrite);
442
+ }
443
+
444
+ /**
445
+ * Process downloading files
446
+ * @param string $destinationFile
447
+ * @param string $loadUrl
448
+ */
449
+ private function downloadFile($destinationFile, $loadUrl)
450
+ {
451
+ $userName = Mage::getStoreConfig('icecat_root/icecat/login');
452
+ $userPass = Mage::getStoreConfig('icecat_root/icecat/password');
453
+ $fileToWrite = @fopen($destinationFile, 'w+');
454
+
455
+ try {
456
+ $webClient = new Zend_Http_Client();
457
+ $webClient->setUri($loadUrl);
458
+ $webClient->setConfig(array('maxredirects' => 0, 'timeout' => 60));
459
+ $webClient->setMethod(Zend_Http_Client::GET);
460
+ $webClient->setHeaders('Content-Type: text/xml; charset=UTF-8');
461
+ $webClient->setAuth($userName, $userPass, Zend_Http_CLient::AUTH_BASIC);
462
+ $response = $webClient->request('GET');
463
+ if ($response->isError()) {
464
+ throw new Exception("\nERROR Occured.\nResponse Status: " . $response->getStatus() . "\nResponse Message: " . $response->getMessage() ."\nResponse Body: " . $response->getBody() .
465
+ "\nPlease, make sure that you added correct icecat username and password to Icecat Live! configuration and you have your webshop's correct IP in Allowed IP addresses field in your icecat account.");
466
+ }
467
+ } catch (Exception $e) {
468
+ throw new Exception("Warning: cannot connect to ICEcat. {$e->getMessage()}");
469
+ }
470
+ $resultString = $response->getBody();
471
+ fwrite($fileToWrite, $resultString);
472
+ fclose($fileToWrite);
473
+ }
474
+
475
+ /**
476
+ * Prepares file and folder for futur download
477
+ * @param string $fileName
478
+ */
479
+ protected function _prepareFile($fileName)
480
+ {
481
+ $varDir = Mage::getBaseDir('var') . $this->_connectorDir;
482
+ $filePath = $varDir . $fileName;
483
+ if (!is_dir($varDir)) {
484
+ mkdir($varDir, 0777, true);
485
+ }
486
+ if (file_exists($filePath)) {
487
+ unlink($filePath);
488
+ }
489
+ return $filePath;
490
+ }
491
+ }
492
+
493
+ ?>
app/code/local/Iceshop/Icecatlive/Model/Relatedcollection.php ADDED
@@ -0,0 +1,69 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ class Iceshop_Icecatlive_Model_Relatedcollection extends Varien_Data_Collection
3
+ {
4
+
5
+ protected $_data = array();
6
+ protected $_collection;
7
+
8
+ public function __construct()
9
+ {
10
+ parent::__construct();
11
+
12
+ // not extends Varien_Object
13
+ $args = func_get_args();
14
+ if (empty($args[0])) {
15
+ $args[0] = array();
16
+ }
17
+ $this->_data = $args[0];
18
+ }
19
+
20
+ public function getCollection()
21
+ {
22
+ $sku = Mage::getStoreConfig('icecat_root/icecat/sku_field');
23
+ $model = Mage::getModel('catalog/product');
24
+ $collection = $model->getCollection();
25
+
26
+ $filterArray = array();
27
+ $rel = array();
28
+ foreach ($this->_data as $res) {
29
+ foreach ($res as $r) {
30
+ $rel[] = $r;
31
+ }
32
+ }
33
+ foreach ($rel as $item) {
34
+ array_push($filterArray, array('attribute' => $sku, 'eq' => $item['mpn']));
35
+ }
36
+ $collection->addFieldToFilter($filterArray);
37
+
38
+ $collection->joinField('is_in_stock',
39
+ 'cataloginventory/stock_item',
40
+ 'is_in_stock',
41
+ 'product_id=entity_id',
42
+ 'is_in_stock=1',
43
+ '{{table}}.stock_id=1',
44
+ 'left');
45
+
46
+ $myCollection = clone $collection;
47
+ $relCnt = count($rel);
48
+ foreach ($myCollection as &$col) {
49
+ $model->load($col->getId());
50
+ $price = $model->getPrice();
51
+ $mpn = $col->getData($sku);
52
+ $specialPrice = $model->getSpecialPrice();
53
+
54
+ for ($i = 0; $i < $relCnt; $i++) {
55
+ if ($rel[$i]['mpn'] == $mpn) {
56
+ $col->setData('name', $rel[$i]['name']);
57
+ $col->setData('thumbnail', $rel[$i]['thumb']);
58
+ $col->setData('status', Mage_Catalog_Model_Product_Status::STATUS_ENABLED);
59
+ $col->setData('price', $price);
60
+ $col->setData('special_price', $specialPrice);
61
+ }
62
+ }
63
+ }
64
+ return $myCollection;
65
+
66
+ }
67
+ }
68
+
69
+ ?>
app/code/local/Iceshop/Icecatlive/Model/System/Config/Attributes.php ADDED
@@ -0,0 +1,21 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * Class Provides product Attributes for BO menu
4
+ *
5
+ */
6
+ class Iceshop_Icecatlive_Model_System_Config_Attributes
7
+ {
8
+ public function toOptionArray()
9
+ {
10
+ $attributesArray = Mage::getResourceModel('eav/entity_attribute_collection')
11
+ ->setAttributeSetFilter(Mage::getResourceSingleton('catalog/product')->getEntityType()->getDefaultAttributeSetId());
12
+ $outputAttributeArray = array();
13
+ foreach ($attributesArray as $attribute) {
14
+ $outputAttributeArray[$attribute['attribute_code']] = $attribute['attribute_code'];
15
+ }
16
+ ksort($outputAttributeArray);
17
+ return $outputAttributeArray;
18
+ }
19
+ }
20
+
21
+ ?>
app/code/local/Iceshop/Icecatlive/Model/System/Config/Descriptionpriority.php ADDED
@@ -0,0 +1,14 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ class Iceshop_Icecatlive_Model_System_Config_Descriptionpriority
3
+ {
4
+ public function toOptionArray()
5
+ {
6
+ return array(
7
+ 'Icecat' => 'From Icecat',
8
+ 'Db' => 'From Database'
9
+ );
10
+
11
+ }
12
+ }
13
+
14
+ ?>
app/code/local/Iceshop/Icecatlive/Model/System/Config/Imagepriority.php ADDED
@@ -0,0 +1,14 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ class Iceshop_Icecatlive_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
+
14
+ ?>
app/code/local/Iceshop/Icecatlive/Model/System/Config/Importdata.php ADDED
@@ -0,0 +1,13 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ class Iceshop_Icecatlive_Model_System_Config_Importdata
3
+ {
4
+ public function toOptionArray()
5
+ {
6
+ return array(
7
+ 'label' => 'Import'
8
+ );
9
+
10
+ }
11
+ }
12
+
13
+ ?>
app/code/local/Iceshop/Icecatlive/Model/System/Config/LanguageList.xml ADDED
@@ -0,0 +1,399 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?xml version="1.0"?>
2
+ <!DOCTYPE ICECAT-interface SYSTEM "http://data.icecat.biz/dtd/ICECAT-interface_response.dtd">
3
+ <!-- source: ICEcat.biz 2009 -->
4
+ <ICECAT-interface>
5
+ <Response ID="50564949" Status="1" Date="Thu Oct 22 04:26:04 2009" Request_ID="1256178364">
6
+ <LanguageList>
7
+ <Language Code="portuguese" ID="11" ShortCode="PT" Sid="6184">
8
+ <Name ID="40191" Value="Portuguese-Portuguese" langid="1"/>
9
+ <Name ID="40192" Value="Portuguese-Portuguese" langid="2"/>
10
+ <Name ID="40193" Value="Portuguese-Portuguese" langid="3"/>
11
+ <Name ID="40194" Value="Portuguese-Portuguese" langid="4"/>
12
+ <Name ID="40195" Value="Portuguese-Portuguese" langid="5"/>
13
+ <Name ID="40196" Value="Portuguese-Portuguese" langid="6"/>
14
+ <Name ID="198032" Value="Португальский-португальский" langid="8"/>
15
+ <Name ID="50889" Value="" langid="12"/>
16
+ <Name ID="205069" Value="Португальcька-Португалія" langid="25"/>
17
+ </Language>
18
+ <Language Code="bulgarian" ID="21" ShortCode="BG" Sid="9218">
19
+ <Name ID="147616" Value="Bulgarian" langid="1"/>
20
+ <Name ID="198042" Value="Болгарский" langid="8"/>
21
+ <Name ID="205079" Value="Болгарська" langid="25"/>
22
+ </Language>
23
+ <Language Code="danish" ID="7" ShortCode="DK" Sid="6058">
24
+ <Name ID="39312" Value="Danish" langid="1"/>
25
+ <Name ID="39313" Value="Danish" langid="2"/>
26
+ <Name ID="39314" Value="Danish" langid="3"/>
27
+ <Name ID="39315" Value="Danish" langid="4"/>
28
+ <Name ID="39316" Value="Danish" langid="5"/>
29
+ <Name ID="39317" Value="Danish" langid="6"/>
30
+ <Name ID="39318" Value="Danish" langid="7"/>
31
+ <Name ID="198028" Value="Датский" langid="8"/>
32
+ <Name ID="40294" Value="Danish" langid="9"/>
33
+ <Name ID="40295" Value="Danish" langid="10"/>
34
+ <Name ID="40296" Value="Danish" langid="11"/>
35
+ <Name ID="40297" Value="Danish" langid="12"/>
36
+ <Name ID="40298" Value="Danish" langid="13"/>
37
+ <Name ID="40299" Value="Danish" langid="14"/>
38
+ <Name ID="40300" Value="Danish" langid="15"/>
39
+ <Name ID="40301" Value="Danish" langid="16"/>
40
+ <Name ID="40302" Value="Danish" langid="17"/>
41
+ <Name ID="205065" Value="Датська" langid="25"/>
42
+ </Language>
43
+ <Language Code="japanese" ID="26" ShortCode="JA" Sid="9635">
44
+ <Name ID="224188" Value="Japanese" langid="1"/>
45
+ <Name ID="224189" Value="Japanese" langid="2"/>
46
+ <Name ID="224190" Value="Japanese" langid="3"/>
47
+ <Name ID="224191" Value="Japanese" langid="4"/>
48
+ <Name ID="224192" Value="Japanese" langid="5"/>
49
+ <Name ID="224193" Value="Japanese" langid="6"/>
50
+ <Name ID="224194" Value="Японский" langid="8"/>
51
+ <Name ID="224195" Value="Японська" langid="25"/>
52
+ <Name ID="224196" Value="Japanese" langid="26"/>
53
+ </Language>
54
+ <Language Code="finnish" ID="17" ShortCode="FI" Sid="6190">
55
+ <Name ID="40227" Value="Finnish" langid="1"/>
56
+ <Name ID="40228" Value="Finnish" langid="2"/>
57
+ <Name ID="40229" Value="Finnish" langid="3"/>
58
+ <Name ID="40230" Value="Finnish" langid="4"/>
59
+ <Name ID="40231" Value="Finnish" langid="5"/>
60
+ <Name ID="40232" Value="Finnish" langid="6"/>
61
+ <Name ID="198038" Value="Финский" langid="8"/>
62
+ <Name ID="50895" Value="" langid="12"/>
63
+ <Name ID="205075" Value="Фінська" langid="25"/>
64
+ </Language>
65
+ <Language Code="dutch" ID="2" ShortCode="NL" Sid="3">
66
+ <Name ID="3" Value="Dutch" langid="1"/>
67
+ <Name ID="4" Value="Dutch" langid="2"/>
68
+ <Name ID="6074" Value="Dutch" langid="3"/>
69
+ <Name ID="14099" Value="Dutch" langid="4"/>
70
+ <Name ID="18231" Value="Dutch" langid="5"/>
71
+ <Name ID="22363" Value="Dutch" langid="6"/>
72
+ <Name ID="34054" Value="Hollandsk" langid="7"/>
73
+ <Name ID="198023" Value="Голландский" langid="8"/>
74
+ <Name ID="40244" Value="Dutch" langid="9"/>
75
+ <Name ID="40245" Value="Dutch" langid="10"/>
76
+ <Name ID="40246" Value="Dutch" langid="11"/>
77
+ <Name ID="40247" Value="Dutch" langid="12"/>
78
+ <Name ID="40248" Value="Dutch" langid="13"/>
79
+ <Name ID="40249" Value="Dutch" langid="14"/>
80
+ <Name ID="40250" Value="Dutch" langid="15"/>
81
+ <Name ID="40251" Value="Dutch" langid="16"/>
82
+ <Name ID="40252" Value="Dutch" langid="17"/>
83
+ <Name ID="205060" Value="Голландська" langid="25"/>
84
+ </Language>
85
+ <Language Code="georgian" ID="22" ShortCode="KA" Sid="9271">
86
+ <Name ID="154954" Value="Georgian" langid="1"/>
87
+ <Name ID="198043" Value="Грузинский" langid="8"/>
88
+ <Name ID="205080" Value="Грузинська" langid="25"/>
89
+ </Language>
90
+ <Language Code="english" ID="1" ShortCode="EN" Sid="2">
91
+ <Name ID="1" Value="English" langid="1"/>
92
+ <Name ID="2" Value="English" langid="2"/>
93
+ <Name ID="6073" Value="English" langid="3"/>
94
+ <Name ID="14098" Value="English" langid="4"/>
95
+ <Name ID="18230" Value="English" langid="5"/>
96
+ <Name ID="22362" Value="English" langid="6"/>
97
+ <Name ID="34053" Value="Engelsk" langid="7"/>
98
+ <Name ID="198022" Value="Английский" langid="8"/>
99
+ <Name ID="40234" Value="English" langid="9"/>
100
+ <Name ID="40235" Value="English" langid="10"/>
101
+ <Name ID="40236" Value="English" langid="11"/>
102
+ <Name ID="40237" Value="English" langid="12"/>
103
+ <Name ID="40238" Value="English" langid="13"/>
104
+ <Name ID="40239" Value="English" langid="14"/>
105
+ <Name ID="40240" Value="English" langid="15"/>
106
+ <Name ID="40241" Value="English" langid="16"/>
107
+ <Name ID="40242" Value="English" langid="17"/>
108
+ <Name ID="205059" Value="Англійська" langid="25"/>
109
+ </Language>
110
+ <Language Code="greek" ID="18" ShortCode="EL" Sid="8587">
111
+ <Name ID="113508" Value="Greek" langid="1"/>
112
+ <Name ID="113509" Value="Greek" langid="2"/>
113
+ <Name ID="113510" Value="Greek" langid="3"/>
114
+ <Name ID="113511" Value="Greek" langid="4"/>
115
+ <Name ID="113512" Value="Greek" langid="5"/>
116
+ <Name ID="113513" Value="Greek" langid="6"/>
117
+ <Name ID="198039" Value="Греческий" langid="8"/>
118
+ <Name ID="205076" Value="Грецька" langid="25"/>
119
+ </Language>
120
+ <Language Code="romanian" ID="23" ShortCode="RO" Sid="9390">
121
+ <Name ID="169100" Value="Romanian" langid="1"/>
122
+ <Name ID="169101" Value="Romanian" langid="2"/>
123
+ <Name ID="169102" Value="Romanian" langid="3"/>
124
+ <Name ID="169103" Value="Romanian" langid="4"/>
125
+ <Name ID="169104" Value="Romanian" langid="5"/>
126
+ <Name ID="169105" Value="Romanian" langid="6"/>
127
+ <Name ID="198044" Value="Румынский" langid="8"/>
128
+ <Name ID="205081" Value="Румунська" langid="25"/>
129
+ </Language>
130
+ <Language Code="hungarian" ID="16" ShortCode="HU" Sid="6189">
131
+ <Name ID="40221" Value="Hungarian" langid="1"/>
132
+ <Name ID="40222" Value="Hungarian" langid="2"/>
133
+ <Name ID="40223" Value="Hungarian" langid="3"/>
134
+ <Name ID="40224" Value="Hungarian" langid="4"/>
135
+ <Name ID="40225" Value="Hungarian" langid="5"/>
136
+ <Name ID="40226" Value="Hungarian" langid="6"/>
137
+ <Name ID="198037" Value="Венгерский" langid="8"/>
138
+ <Name ID="50894" Value="" langid="12"/>
139
+ <Name ID="205074" Value="Угорська" langid="25"/>
140
+ </Language>
141
+ <Language Code="swedish" ID="13" ShortCode="SE" Sid="6186">
142
+ <Name ID="40203" Value="Swedish" langid="1"/>
143
+ <Name ID="40204" Value="Swedish" langid="2"/>
144
+ <Name ID="40205" Value="Swedish" langid="3"/>
145
+ <Name ID="40206" Value="Swedish" langid="4"/>
146
+ <Name ID="40207" Value="Swedish" langid="5"/>
147
+ <Name ID="40208" Value="Swedish" langid="6"/>
148
+ <Name ID="198034" Value="Шведский" langid="8"/>
149
+ <Name ID="50891" Value="" langid="12"/>
150
+ <Name ID="205071" Value="Швецька" langid="25"/>
151
+ </Language>
152
+ <Language Code="croatian" ID="29" ShortCode="HR" Sid="10132">
153
+ <Name ID="270273" Value="Croatian" langid="1"/>
154
+ <Name ID="270274" Value="Croatian" langid="2"/>
155
+ <Name ID="270275" Value="Croatian" langid="3"/>
156
+ <Name ID="270276" Value="Croatian" langid="4"/>
157
+ <Name ID="270277" Value="Croatian" langid="5"/>
158
+ <Name ID="270278" Value="Croatian" langid="6"/>
159
+ <Name ID="270280" Value="Hrvatski" langid="29"/>
160
+ </Language>
161
+ <Language Code="catalan" ID="27" ShortCode="CA" Sid="9662">
162
+ <Name ID="231955" Value="Catalan" langid="1"/>
163
+ <Name ID="231956" Value="Catalan" langid="2"/>
164
+ <Name ID="231957" Value="Catalan" langid="3"/>
165
+ <Name ID="231958" Value="Catalan" langid="4"/>
166
+ <Name ID="231959" Value="Catalan" langid="5"/>
167
+ <Name ID="231960" Value="Catalan" langid="6"/>
168
+ <Name ID="231962" Value="Каталанский" langid="8"/>
169
+ <Name ID="231963" Value="Каталанська" langid="25"/>
170
+ <Name ID="231961" Value="Català" langid="27"/>
171
+ </Language>
172
+ <Language Code="ukrainian" ID="25" ShortCode="UK" Sid="9577">
173
+ <Name ID="198046" Value="Ukrainian" langid="1"/>
174
+ <Name ID="198047" Value="Ukrainian" langid="2"/>
175
+ <Name ID="198048" Value="Ukrainian" langid="3"/>
176
+ <Name ID="198049" Value="Ukrainian" langid="4"/>
177
+ <Name ID="198050" Value="Ukrainian" langid="5"/>
178
+ <Name ID="198051" Value="Ukrainian" langid="6"/>
179
+ <Name ID="198052" Value="Украинский" langid="8"/>
180
+ <Name ID="198053" Value="Українська" langid="25"/>
181
+ </Language>
182
+ <Language Code="spanish" ID="6" ShortCode="ES" Sid="4797">
183
+ <Name ID="14094" Value="Spanish" langid="1"/>
184
+ <Name ID="14095" Value="Spanish" langid="2"/>
185
+ <Name ID="14096" Value="Spanish" langid="3"/>
186
+ <Name ID="18228" Value="Spanish" langid="4"/>
187
+ <Name ID="106485" Value="Processo di simulazione dell'alba (intensità 0)" langid="5"/>
188
+ <Name ID="26492" Value="Spanish" langid="6"/>
189
+ <Name ID="38094" Value="Spansk" langid="7"/>
190
+ <Name ID="198027" Value="Испанский" langid="8"/>
191
+ <Name ID="40284" Value="Spanish" langid="9"/>
192
+ <Name ID="40285" Value="Spanish" langid="10"/>
193
+ <Name ID="40286" Value="Spanish" langid="11"/>
194
+ <Name ID="40287" Value="Spanish" langid="12"/>
195
+ <Name ID="40288" Value="Spanish" langid="13"/>
196
+ <Name ID="40289" Value="Spanish" langid="14"/>
197
+ <Name ID="40290" Value="Spanish" langid="15"/>
198
+ <Name ID="40291" Value="Spanish" langid="16"/>
199
+ <Name ID="40292" Value="Spanish" langid="17"/>
200
+ <Name ID="205064" Value="Іспанська" langid="25"/>
201
+ </Language>
202
+ <Language Code="argentinian-spanish" ID="28" ShortCode="AR" Sid="9835">
203
+ <Name ID="244259" Value="Argentinian-Spanish" langid="1"/>
204
+ <Name ID="244260" Value="Argentinian-Spanish" langid="2"/>
205
+ <Name ID="244261" Value="Argentinian-Spanish" langid="3"/>
206
+ <Name ID="244262" Value="Argentinian-Spanish" langid="4"/>
207
+ <Name ID="244263" Value="Argentinian-Spanish" langid="5"/>
208
+ <Name ID="244264" Value="Argentinian-Spanish" langid="6"/>
209
+ <Name ID="244265" Value="Argentinian-Spanish" langid="7"/>
210
+ <Name ID="244266" Value="Argentinian-Spanish" langid="8"/>
211
+ <Name ID="244267" Value="Argentinian-Spanish" langid="9"/>
212
+ <Name ID="244268" Value="Argentinian-Spanish" langid="10"/>
213
+ <Name ID="244269" Value="Argentinian-Spanish" langid="11"/>
214
+ <Name ID="244270" Value="Argentinian-Spanish" langid="12"/>
215
+ <Name ID="244271" Value="Argentinian-Spanish" langid="13"/>
216
+ <Name ID="244272" Value="Argentinian-Spanish" langid="14"/>
217
+ <Name ID="244273" Value="Argentinian-Spanish" langid="15"/>
218
+ <Name ID="244274" Value="Argentinian-Spanish" langid="16"/>
219
+ <Name ID="244275" Value="Argentinian-Spanish" langid="17"/>
220
+ <Name ID="244276" Value="Argentinian-Spanish" langid="18"/>
221
+ <Name ID="244277" Value="Argentinian-Spanish" langid="19"/>
222
+ <Name ID="244278" Value="Argentinian-Spanish" langid="20"/>
223
+ <Name ID="244279" Value="Argentinian-Spanish" langid="21"/>
224
+ <Name ID="244280" Value="Argentinian-Spanish" langid="22"/>
225
+ <Name ID="244281" Value="Argentinian-Spanish" langid="23"/>
226
+ <Name ID="244282" Value="Argentinian-Spanish" langid="24"/>
227
+ <Name ID="244283" Value="Argentinian-Spanish" langid="25"/>
228
+ <Name ID="244284" Value="Argentinian-Spanish" langid="26"/>
229
+ <Name ID="244285" Value="Argentinian-Spanish" langid="27"/>
230
+ <Name ID="244286" Value="Argentinian-Spanish" langid="28"/>
231
+ </Language>
232
+ <Language Code="french" ID="3" ShortCode="FR" Sid="3036">
233
+ <Name ID="6071" Value="French" langid="1"/>
234
+ <Name ID="6072" Value="French" langid="2"/>
235
+ <Name ID="8815" Value="French" langid="3"/>
236
+ <Name ID="16579" Value="French" langid="4"/>
237
+ <Name ID="103145" Value="Rapporto di compressione" langid="5"/>
238
+ <Name ID="24843" Value="French" langid="6"/>
239
+ <Name ID="36551" Value="Fransk" langid="7"/>
240
+ <Name ID="198024" Value="Французский" langid="8"/>
241
+ <Name ID="40254" Value="French" langid="9"/>
242
+ <Name ID="40255" Value="French" langid="10"/>
243
+ <Name ID="40256" Value="French" langid="11"/>
244
+ <Name ID="40257" Value="French" langid="12"/>
245
+ <Name ID="40258" Value="French" langid="13"/>
246
+ <Name ID="40259" Value="French" langid="14"/>
247
+ <Name ID="40260" Value="French" langid="15"/>
248
+ <Name ID="40261" Value="French" langid="16"/>
249
+ <Name ID="40262" Value="French" langid="17"/>
250
+ <Name ID="205061" Value="Французька" langid="25"/>
251
+ </Language>
252
+ <Language Code="us english" ID="9" ShortCode="US" Sid="6182">
253
+ <Name ID="40179" Value="US English" langid="1"/>
254
+ <Name ID="40180" Value="US English" langid="2"/>
255
+ <Name ID="40181" Value="US English" langid="3"/>
256
+ <Name ID="40182" Value="US English" langid="4"/>
257
+ <Name ID="40183" Value="US English" langid="5"/>
258
+ <Name ID="40184" Value="US English" langid="6"/>
259
+ <Name ID="198030" Value="Американский английский" langid="8"/>
260
+ <Name ID="50887" Value="" langid="12"/>
261
+ <Name ID="205067" Value="Англійська США" langid="25"/>
262
+ </Language>
263
+ <Language Code="chinese" ID="12" ShortCode="ZH" Sid="6185">
264
+ <Name ID="40197" Value="Chinese" langid="1"/>
265
+ <Name ID="40198" Value="Chinese" langid="2"/>
266
+ <Name ID="40199" Value="Chinese" langid="3"/>
267
+ <Name ID="40200" Value="Chinese" langid="4"/>
268
+ <Name ID="40201" Value="Chinese" langid="5"/>
269
+ <Name ID="40202" Value="Chinese" langid="6"/>
270
+ <Name ID="198033" Value="Китайский" langid="8"/>
271
+ <Name ID="50890" Value="" langid="12"/>
272
+ <Name ID="205070" Value="Китайська" langid="25"/>
273
+ </Language>
274
+ <Language Code="turkish" ID="20" ShortCode="TR" Sid="8665">
275
+ <Name ID="118819" Value="Turkish" langid="1"/>
276
+ <Name ID="118820" Value="Turkish" langid="2"/>
277
+ <Name ID="118821" Value="Turkish" langid="3"/>
278
+ <Name ID="118822" Value="Turkish" langid="4"/>
279
+ <Name ID="118823" Value="Turkish" langid="5"/>
280
+ <Name ID="118824" Value="Turkish" langid="6"/>
281
+ <Name ID="198041" Value="Турецкий" langid="8"/>
282
+ <Name ID="205078" Value="Турецька" langid="25"/>
283
+ </Language>
284
+ <Language Code="polish" ID="14" ShortCode="PL" Sid="6187">
285
+ <Name ID="40209" Value="Polish" langid="1"/>
286
+ <Name ID="40210" Value="Polish" langid="2"/>
287
+ <Name ID="40211" Value="Polish" langid="3"/>
288
+ <Name ID="40212" Value="Polish" langid="4"/>
289
+ <Name ID="40213" Value="Polish" langid="5"/>
290
+ <Name ID="40214" Value="Polish" langid="6"/>
291
+ <Name ID="198035" Value="Польский" langid="8"/>
292
+ <Name ID="50892" Value="" langid="12"/>
293
+ <Name ID="205072" Value="Польська" langid="25"/>
294
+ </Language>
295
+ <Language Code="czech" ID="15" ShortCode="CZ" Sid="6188">
296
+ <Name ID="40215" Value="Czech" langid="1"/>
297
+ <Name ID="40216" Value="Czech" langid="2"/>
298
+ <Name ID="40217" Value="Czech" langid="3"/>
299
+ <Name ID="40218" Value="Czech" langid="4"/>
300
+ <Name ID="40219" Value="Czech" langid="5"/>
301
+ <Name ID="40220" Value="Czech" langid="6"/>
302
+ <Name ID="198036" Value="Чешский" langid="8"/>
303
+ <Name ID="50893" Value="" langid="12"/>
304
+ <Name ID="205073" Value="Чеська" langid="25"/>
305
+ </Language>
306
+ <Language Code="russian" ID="8" ShortCode="RU" Sid="6181">
307
+ <Name ID="40173" Value="Russian" langid="1"/>
308
+ <Name ID="40174" Value="Russian" langid="2"/>
309
+ <Name ID="40175" Value="Russian" langid="3"/>
310
+ <Name ID="40176" Value="Russian" langid="4"/>
311
+ <Name ID="40177" Value="Russian" langid="5"/>
312
+ <Name ID="40178" Value="Russian" langid="6"/>
313
+ <Name ID="40303" Value="Russian" langid="7"/>
314
+ <Name ID="198029" Value="Русский" langid="8"/>
315
+ <Name ID="40305" Value="Russian" langid="9"/>
316
+ <Name ID="40306" Value="Russian" langid="10"/>
317
+ <Name ID="40307" Value="Russian" langid="11"/>
318
+ <Name ID="40308" Value="Russian" langid="12"/>
319
+ <Name ID="40309" Value="Russian" langid="13"/>
320
+ <Name ID="40310" Value="Russian" langid="14"/>
321
+ <Name ID="40311" Value="Russian" langid="15"/>
322
+ <Name ID="40312" Value="Russian" langid="16"/>
323
+ <Name ID="40313" Value="Russian" langid="17"/>
324
+ <Name ID="205066" Value="Російська" langid="25"/>
325
+ </Language>
326
+ <Language Code="german" ID="4" ShortCode="DE" Sid="4795">
327
+ <Name ID="14088" Value="German" langid="1"/>
328
+ <Name ID="14089" Value="German" langid="2"/>
329
+ <Name ID="14090" Value="German" langid="3"/>
330
+ <Name ID="18226" Value="German" langid="4"/>
331
+ <Name ID="104573" Value="Luce per una lettura agevole" langid="5"/>
332
+ <Name ID="26490" Value="German" langid="6"/>
333
+ <Name ID="38092" Value="Tysk" langid="7"/>
334
+ <Name ID="198025" Value="Немецкий" langid="8"/>
335
+ <Name ID="40264" Value="German" langid="9"/>
336
+ <Name ID="40265" Value="German" langid="10"/>
337
+ <Name ID="40266" Value="German" langid="11"/>
338
+ <Name ID="40267" Value="German" langid="12"/>
339
+ <Name ID="40268" Value="German" langid="13"/>
340
+ <Name ID="40269" Value="German" langid="14"/>
341
+ <Name ID="40270" Value="German" langid="15"/>
342
+ <Name ID="40271" Value="German" langid="16"/>
343
+ <Name ID="40272" Value="German" langid="17"/>
344
+ <Name ID="205062" Value="Німецька" langid="25"/>
345
+ </Language>
346
+ <Language Code="serbian" ID="24" ShortCode="SR" Sid="9443">
347
+ <Name ID="170887" Value="Serbian" langid="1"/>
348
+ <Name ID="170888" Value="Serbian" langid="2"/>
349
+ <Name ID="170889" Value="Serbian" langid="3"/>
350
+ <Name ID="170890" Value="Serbian" langid="4"/>
351
+ <Name ID="170891" Value="Serbian" langid="5"/>
352
+ <Name ID="170892" Value="Serbian" langid="6"/>
353
+ <Name ID="198045" Value="Сербский" langid="8"/>
354
+ <Name ID="205082" Value="Сербська" langid="25"/>
355
+ </Language>
356
+ <Language Code="norwegian" ID="19" ShortCode="NO" Sid="8664">
357
+ <Name ID="118813" Value="Norwegian" langid="1"/>
358
+ <Name ID="118814" Value="Norwegian" langid="2"/>
359
+ <Name ID="118815" Value="Norwegian" langid="3"/>
360
+ <Name ID="118816" Value="Norwegian" langid="4"/>
361
+ <Name ID="118817" Value="Norwegian" langid="5"/>
362
+ <Name ID="118818" Value="Norwegian" langid="6"/>
363
+ <Name ID="198040" Value="Норвежский" langid="8"/>
364
+ <Name ID="205077" Value="Норвезька" langid="25"/>
365
+ </Language>
366
+ <Language Code="brazilian-portuguese" ID="10" ShortCode="BR" Sid="6183">
367
+ <Name ID="40185" Value="Brazilian-Portuguese" langid="1"/>
368
+ <Name ID="40186" Value="Brazilian-Portuguese" langid="2"/>
369
+ <Name ID="40187" Value="Brazilian-Portuguese" langid="3"/>
370
+ <Name ID="40188" Value="Brazilian-Portuguese" langid="4"/>
371
+ <Name ID="40189" Value="Brazilian-Portuguese" langid="5"/>
372
+ <Name ID="40190" Value="Brazilian-Portuguese" langid="6"/>
373
+ <Name ID="198031" Value="Бразильский-португальский" langid="8"/>
374
+ <Name ID="50888" Value="" langid="12"/>
375
+ <Name ID="205068" Value="Португальська-Бразилія" langid="25"/>
376
+ </Language>
377
+ <Language Code="italian" ID="5" ShortCode="IT" Sid="4796">
378
+ <Name ID="14091" Value="Italian" langid="1"/>
379
+ <Name ID="14092" Value="Italian" langid="2"/>
380
+ <Name ID="14093" Value="Italian" langid="3"/>
381
+ <Name ID="18227" Value="Italian" langid="4"/>
382
+ <Name ID="104579" Value="Funzione di on/off luce" langid="5"/>
383
+ <Name ID="26491" Value="Italian" langid="6"/>
384
+ <Name ID="38093" Value="Italiensk" langid="7"/>
385
+ <Name ID="198026" Value="Итальянский" langid="8"/>
386
+ <Name ID="40274" Value="Italian" langid="9"/>
387
+ <Name ID="40275" Value="Italian" langid="10"/>
388
+ <Name ID="40276" Value="Italian" langid="11"/>
389
+ <Name ID="40277" Value="Italian" langid="12"/>
390
+ <Name ID="40278" Value="Italian" langid="13"/>
391
+ <Name ID="40279" Value="Italian" langid="14"/>
392
+ <Name ID="40280" Value="Italian" langid="15"/>
393
+ <Name ID="40281" Value="Italian" langid="16"/>
394
+ <Name ID="40282" Value="Italian" langid="17"/>
395
+ <Name ID="205063" Value="Італійська" langid="25"/>
396
+ </Language>
397
+ </LanguageList>
398
+ </Response>
399
+ </ICECAT-interface>
app/code/local/Iceshop/Icecatlive/Model/System/Config/Locales.php ADDED
@@ -0,0 +1,50 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * Class Provides locales list for Magento BO
4
+ *
5
+ */
6
+ class Iceshop_Icecatlive_Model_System_Config_Locales
7
+ {
8
+ private $domDoc;
9
+
10
+ public function toOptionArray()
11
+ {
12
+ $pathToFile = Mage::getRoot() . '/code/local/Iceshop/Icecatlive/Model/System/Config/';
13
+ $fileContent = file_get_contents($pathToFile . 'LanguageList.xml');
14
+ if (!$this->parseXml(utf8_encode($fileContent))) {
15
+ return false;
16
+ }
17
+
18
+ $values = $this->parseLocaleValues();
19
+ return $values;
20
+ }
21
+
22
+ private function parseLocaleValues()
23
+ {
24
+ $languageArray = $this->domDoc->getElementsByTagName('Language');
25
+ $resultArray = array();
26
+ foreach ($languageArray as $language) {
27
+ $languageShortCode = strtolower($language->getAttribute('ShortCode'));
28
+ $languageCode = ucfirst($language->getAttribute('Code'));
29
+ $resultArray[$languageShortCode] = $languageCode;
30
+ }
31
+ ksort($resultArray);
32
+ array_unshift($resultArray, 'Use Store Locale');
33
+ return $resultArray;
34
+ }
35
+
36
+ private function parseXml($stringXml)
37
+ {
38
+
39
+ $this->domDoc = new DOMDocument();
40
+ $result = $this->domDoc->loadXML($stringXml);
41
+ return true;
42
+ if (!$this->domDoc->validate()) {
43
+ echo "Document is not Valid<br>";
44
+ return false;
45
+ }
46
+ return true;
47
+ }
48
+ }
49
+
50
+ ?>
app/code/local/Iceshop/Icecatlive/Model/System/Config/Namepriority.php ADDED
@@ -0,0 +1,14 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ class Iceshop_Icecatlive_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
+
14
+ ?>
app/code/local/Iceshop/Icecatlive/Model/System/Config/Productpriority.php ADDED
@@ -0,0 +1,14 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ class Iceshop_Icecatlive_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
+
14
+ ?>
app/code/local/Iceshop/Icecatlive/Model/System/Config/Shortdescrpriority.php ADDED
@@ -0,0 +1,14 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ class Iceshop_Icecatlive_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
+
14
+ ?>
app/code/local/Iceshop/Icecatlive/Model/System/Config/Subscription.php ADDED
@@ -0,0 +1,18 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * Class provides data for Magento BO
4
+ *
5
+ */
6
+ class Iceshop_Icecatlive_Model_System_Config_Subscription
7
+ {
8
+ public function toOptionArray()
9
+ {
10
+ $paramsArray = array(
11
+ 'free' => 'OpenIcecat XML',
12
+ 'full' => 'FullIcecat XML'
13
+ );
14
+ return $paramsArray;
15
+ }
16
+ }
17
+
18
+ ?>
app/code/local/Iceshop/Icecatlive/controllers/Adminhtml/ImportdataController.php ADDED
@@ -0,0 +1,16 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ class Iceshop_Icecatlive_Adminhtml_ImportdataController extends Mage_Adminhtml_Controller_Action
3
+ {
4
+ /**
5
+ * Return some checking result
6
+ *
7
+ * @return void
8
+ */
9
+ public function checkAction()
10
+ {
11
+ session_write_close();
12
+ $result = Mage::getModel('icecatlive/observer')->load();
13
+ sleep(6);
14
+ Mage::app()->getResponse()->setBody($result);
15
+ }
16
+ }
app/code/local/Iceshop/Icecatlive/controllers/Adminhtml/ImportprogressController.php ADDED
@@ -0,0 +1,19 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ class Iceshop_Icecatlive_Adminhtml_ImportprogressController extends Mage_Adminhtml_Controller_Action
3
+ {
4
+ /**
5
+ * Return some checking result
6
+ *
7
+ * @return void
8
+ */
9
+ public function checkAction()
10
+ {
11
+ $importlogFile = Mage::getBaseDir('var') . '/iceshop/icecatlive/import.log';
12
+ $importlogContent = file_get_contents($importlogFile);
13
+ $importlogArray = explode("\n", $importlogContent);
14
+ array_pop($importlogArray);
15
+ $importlogJson = json_encode($importlogArray);
16
+ Mage::app()->getResponse()->setHeader('Content-type', 'application/json');
17
+ Mage::app()->getResponse()->setBody($importlogJson);
18
+ }
19
+ }
app/code/local/Iceshop/Icecatlive/controllers/ImageController.php ADDED
@@ -0,0 +1,18 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * Class provides controller for import image debug
4
+ *
5
+ */
6
+ class Iceshop_Icecatlive_ImageController extends Mage_Adminhtml_Controller_Action
7
+ {
8
+
9
+ /**
10
+ * Action calls load method which uploads data to iceshop connector data table
11
+ */
12
+ public function viewAction()
13
+ {
14
+ $result = Mage::getModel('icecatlive/observer')->load();
15
+ }
16
+ }
17
+
18
+ ?>
app/code/local/Iceshop/Icecatlive/etc/config.xml ADDED
@@ -0,0 +1,185 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?xml version="1.0"?>
2
+ <config>
3
+ <modules>
4
+ <Iceshop_Icecatlive>
5
+ <version>1.6.0</version>
6
+ </Iceshop_Icecatlive>
7
+ </modules>
8
+ <global>
9
+ <helpers>
10
+ <icecatlive>
11
+ <class>Iceshop_Icecatlive_Helper</class>
12
+ </icecatlive>
13
+ <catalog>
14
+ <rewrite>
15
+ <image>Iceshop_Icecatlive_Helper_Catalog_Image</image>
16
+ <output>Iceshop_Icecatlive_Helper_Output</output>
17
+ </rewrite>
18
+ </catalog>
19
+ </helpers>
20
+ <blocks>
21
+ <Iceshop_Icecatlive>
22
+ <class>Iceshop_Icecatlive_Block</class>
23
+ </Iceshop_Icecatlive>
24
+ <catalog>
25
+ <rewrite>
26
+ <product_view_attributes>Iceshop_Icecatlive_Block_Attributes</product_view_attributes>
27
+ <product_view_media>Iceshop_Icecatlive_Block_Media</product_view_media>
28
+ <product_list_related>Iceshop_Icecatlive_Block_Related</product_list_related>
29
+ <product_list_upsell>Iceshop_Icecatlive_Block_Upsell</product_list_upsell>
30
+ <product_list_toolbar>Iceshop_Icecatlive_Block_Product_List_Toolbar</product_list_toolbar>
31
+ </rewrite>
32
+ </catalog>
33
+ <catalogsearch>
34
+ <rewrite>
35
+ <result>Iceshop_Icecatlive_CatalogSearch_Block_Result</result>
36
+ </rewrite>
37
+ </catalogsearch>
38
+ </blocks>
39
+ <models>
40
+ <icecatlive>
41
+ <class>Iceshop_Icecatlive_Model</class>
42
+ <resourceModel>icecatlive_resource_eav_mysql4</resourceModel>
43
+ </icecatlive>
44
+ <icecatlive_resource_eav_mysql4>
45
+ <entities>
46
+ <data>
47
+ <table>iceshop_icecatlive_connector_data</table>
48
+ </data>
49
+ <data_products>
50
+ <table>iceshop_icecatlive_connector_data_products</table>
51
+ </data_products>
52
+ <supplier_mapping>
53
+ <table>iceshop_icecatlive_supplier_mapping</table>
54
+ </supplier_mapping>
55
+ </entities>
56
+ </icecatlive_resource_eav_mysql4>
57
+ <catalog>
58
+ <rewrite>
59
+ <product>Iceshop_Icecatlive_Model_Catalog_Product</product>
60
+ <category>Iceshop_Icecatlive_Model_Catalog_Category</category>
61
+ </rewrite>
62
+ </catalog>
63
+ <catalogsearch_mysql4>
64
+ <rewrite>
65
+ <fulltext_collection>Iceshop_Icecatlive_Model_Catalog_Search</fulltext_collection>
66
+ </rewrite>
67
+ </catalogsearch_mysql4>
68
+ </models>
69
+ <!--
70
+ <routers>
71
+ <catalog>
72
+ <rewrite>
73
+ <product>
74
+ <to>Iceshop_Icecatlive/product</to>
75
+ <override_actions>false</override_actions>
76
+ <actions>
77
+ <view><to>Iceshop_Icecatlive/product/view</to></view>
78
+ </actions>
79
+ </product>
80
+ </rewrite>
81
+ </catalog>
82
+ </routers>
83
+ -->
84
+ <resources>
85
+ <icecatlive_setup>
86
+ <setup>
87
+ <module>Iceshop_Icecatlive</module>
88
+ </setup>
89
+ <connection>
90
+ <use>core_setup</use>
91
+ </connection>
92
+ </icecatlive_setup>
93
+ </resources>
94
+ </global>
95
+ <admin>
96
+ <routers>
97
+ <adminhtml>
98
+ <args>
99
+ <modules>
100
+ <icecatlive after="Mage_Adminhtml">Iceshop_Icecatlive</icecatlive>
101
+ </modules>
102
+ </args>
103
+ </adminhtml>
104
+ </routers>
105
+ </admin>
106
+ <frontend>
107
+ <routers>
108
+ <icecatlive>
109
+ <use>standard</use>
110
+ <args>
111
+ <module>Iceshop_Icecatlive</module>
112
+ <frontName>icecatlive</frontName>
113
+ </args>
114
+ </icecatlive>
115
+ </routers>
116
+ <layout>
117
+ <updates>
118
+ <icecatlive>
119
+ <file>iceshop/icecatlive/groupattributes.xml</file>
120
+ </icecatlive>
121
+ </updates>
122
+ </layout>
123
+ <translate>
124
+ <modules>
125
+ <icecatlive>
126
+ <files>
127
+ <default>Iceshop_Icecatlive.csv</default>
128
+ </files>
129
+ </icecatlive>
130
+ </modules>
131
+ </translate>
132
+ </frontend>
133
+ <adminhtml>
134
+ <acl>
135
+ <resources>
136
+ <admin>
137
+ <children>
138
+ <system>
139
+ <children>
140
+ <config>
141
+ <children>
142
+ <icecat_root translate="title" module="customer">
143
+ <title>Ice Cat Module powered by Iceshop company</title>
144
+ <sort_order>200</sort_order>
145
+ </icecat_root>
146
+ </children>
147
+ </config>
148
+ </children>
149
+ </system>
150
+ </children>
151
+ </admin>
152
+ </resources>
153
+ </acl>
154
+ <events></events>
155
+ <layout>
156
+ <updates>
157
+ <icecatlive>
158
+ <file>icecatlive.xml</file>
159
+ </icecatlive>
160
+ </updates>
161
+ </layout>
162
+ <translate>
163
+ <modules>
164
+ <mage_adminhtml>
165
+ <files>
166
+ <icecatlive>Iceshop_Icecatlive.csv</icecatlive>
167
+ </files>
168
+ </mage_adminhtml>
169
+ </modules>
170
+ </translate>
171
+ </adminhtml>
172
+
173
+ <crontab>
174
+ <jobs>
175
+ <icecatlive>
176
+ <schedule>
177
+ <cron_expr>0 0 * * 0</cron_expr>
178
+ </schedule>
179
+ <run>
180
+ <model>icecatlive/observer::load</model>
181
+ </run>
182
+ </icecatlive>
183
+ </jobs>
184
+ </crontab>
185
+ </config>
app/code/local/Iceshop/Icecatlive/etc/system.xml ADDED
@@ -0,0 +1,142 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?xml version="1.0" encoding="UTF-8"?>
2
+ <config>
3
+ <sections>
4
+ <icecat_root translate="label" module="catalog">
5
+ <class>separator-top</class>
6
+ <label>Icecat Live!</label>
7
+ <tab>catalog</tab>
8
+ <frontend_type>text</frontend_type>
9
+ <sort_order>200</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
+ <icecat translate="label">
15
+ <label>Icecat Live! 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
+ <login translate="label">
23
+ <label>Icecat User name</label>
24
+ <frontend_type>text</frontend_type>
25
+ <sort_order>10</sort_order>
26
+ <show_in_default>1</show_in_default>
27
+ <show_in_website>1</show_in_website>
28
+ <show_in_store>1</show_in_store>
29
+ </login>
30
+ <password translate="label">
31
+ <label>Icecat Password</label>
32
+ <frontend_type>text</frontend_type>
33
+ <sort_order>20</sort_order>
34
+ <show_in_default>1</show_in_default>
35
+ <show_in_website>1</show_in_website>
36
+ <show_in_store>1</show_in_store>
37
+ </password>
38
+ <icecat_type translate="label">
39
+ <label>Subscription level</label>
40
+ <frontend_type>select</frontend_type>
41
+ <source_model>icecatlive/system_config_subscription</source_model>
42
+ <sort_order>25</sort_order>
43
+ <show_in_default>1</show_in_default>
44
+ <show_in_website>1</show_in_website>
45
+ <show_in_store>1</show_in_store>
46
+ </icecat_type>
47
+ <language translate="label">
48
+ <label>Language</label>
49
+ <frontend_type>select</frontend_type>
50
+ <source_model>icecatlive/system_config_locales</source_model>
51
+ <sort_order>30</sort_order>
52
+ <show_in_default>1</show_in_default>
53
+ <show_in_website>1</show_in_website>
54
+ <show_in_store>1</show_in_store>
55
+ </language>
56
+ <sku_field translate="label">
57
+ <label>MPN</label>
58
+ <frontend_type>select</frontend_type>
59
+ <source_model>icecatlive/system_config_attributes</source_model>
60
+ <sort_order>40</sort_order>
61
+ <show_in_default>1</show_in_default>
62
+ <show_in_website>1</show_in_website>
63
+ <show_in_store>1</show_in_store>
64
+ </sku_field>
65
+ <manufacturer translate="label">
66
+ <label>Manufacturer Name</label>
67
+ <frontend_type>select</frontend_type>
68
+ <source_model>icecatlive/system_config_attributes</source_model>
69
+ <sort_order>50</sort_order>
70
+ <show_in_default>1</show_in_default>
71
+ <show_in_website>1</show_in_website>
72
+ <show_in_store>1</show_in_store>
73
+ </manufacturer>
74
+ <ean_code translate="label">
75
+ <label>Ean Code</label>
76
+ <frontend_type>select</frontend_type>
77
+ <source_model>icecatlive/system_config_attributes</source_model>
78
+ <sort_order>60</sort_order>
79
+ <show_in_default>1</show_in_default>
80
+ <show_in_website>1</show_in_website>
81
+ <show_in_store>1</show_in_store>
82
+ </ean_code>
83
+ <descript_priority translate="label">
84
+ <label>Use Description from</label>
85
+ <frontend_type>select</frontend_type>
86
+ <source_model>icecatlive/system_config_descriptionpriority</source_model>
87
+ <sort_order>70</sort_order>
88
+ <show_in_default>1</show_in_default>
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>icecatlive/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>icecatlive/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>icecatlive/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
+ <product_priority translate="label">
120
+ <label>Show/Hide products not presented at icecat</label>
121
+ <frontend_type>select</frontend_type>
122
+ <source_model>icecatlive/system_config_productpriority</source_model>
123
+ <sort_order>70</sort_order>
124
+ <show_in_default>1</show_in_default>
125
+ <show_in_website>1</show_in_website>
126
+ <show_in_store>1</show_in_store>
127
+ </product_priority>
128
+ <import_data translate="label">
129
+ <label>Import data</label>
130
+ <frontend_type>submit</frontend_type>
131
+ <frontend_model>Iceshop_Icecatlive/adminhtml_system_config_form_button</frontend_model>
132
+ <sort_order>75</sort_order>
133
+ <show_in_default>1</show_in_default>
134
+ <show_in_website>1</show_in_website>
135
+ <show_in_store>1</show_in_store>
136
+ </import_data>
137
+ </fields>
138
+ </icecat>
139
+ </groups>
140
+ </icecat_root>
141
+ </sections>
142
+ </config>
app/code/local/Iceshop/Icecatlive/sql/icecatlive_setup/mysql4-install-1.6.0.php ADDED
@@ -0,0 +1,44 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ include_once 'uninstall-old-version.php';
3
+ $unistaller_old_version = new Uninstall_Bintime_Icecatlive();
4
+ $unistaller_old_version->uninstall();
5
+ $installer = $this;
6
+ /* @var $installer Mage_Catalog_Model_Resource_Eav_Mysql4_Setup */
7
+
8
+ $installer->startSetup();
9
+ $installer->run("
10
+ DROP TABLE IF EXISTS `bintime_connector_data`;
11
+ DROP TABLE IF EXISTS `bintime_connector_data_old`;
12
+ DROP TABLE IF EXISTS `bintime_connector_data_products`;
13
+ DROP TABLE IF EXISTS `bintime_supplier_mapping`;
14
+ DROP TABLE IF EXISTS `bintime_supplier_mapping_old`;
15
+ DROP TABLE IF EXISTS {$this->getTable('icecatlive/data')};
16
+ CREATE TABLE {$this->getTable('icecatlive/data')} (
17
+ `prod_id` varchar(255) NOT NULL,
18
+ `supplier_id` int(11) DEFAULT NULL,
19
+ `prod_name` varchar(255) DEFAULT NULL,
20
+ `prod_img` varchar(255) DEFAULT NULL,
21
+ KEY `PRODUCT_MPN` (`prod_id`),
22
+ KEY `supplier_id` (`supplier_id`)
23
+ ) ENGINE=InnoDB DEFAULT CHARSET=utf8 COMMENT='Iceshop Connector product image table';
24
+
25
+ DROP TABLE IF EXISTS {$this->getTable('icecatlive/supplier_mapping')};
26
+ CREATE TABLE {$this->getTable('icecatlive/supplier_mapping')} (
27
+ `supplier_id` int(11) NOT NULL,
28
+ `supplier_symbol` VARCHAR(255),
29
+ KEY `supplier_id` (`supplier_id`)
30
+ ) ENGINE=InnoDB DEFAULT CHARSET=utf8 COMMENT='Iceshop Connector supplier mapping table';
31
+
32
+ DROP TABLE IF EXISTS {$this->getTable('icecatlive/data_products')};
33
+ CREATE TABLE {$this->getTable('icecatlive/data_products')} (
34
+ `prod_id` VARCHAR(255) NOT NULL,
35
+ `supplier_symbol` varchar(255) DEFAULT NULL,
36
+ `prod_title` VARCHAR(255) NULL DEFAULT NULL,
37
+ `prod_ean` VARCHAR(255) NOT NULL,
38
+ KEY `prod_id` (`prod_id`),
39
+ KEY `PRODUCT_EAN` (`prod_ean`),
40
+ INDEX `mpn_brand` (`prod_id`, `supplier_symbol`)
41
+ ) ENGINE=InnoDB DEFAULT CHARSET=utf8 COMMENT='Iceshop Connector product ean table';
42
+ ");
43
+
44
+ $installer->endSetup();
app/code/local/Iceshop/Icecatlive/sql/icecatlive_setup/mysql4-upgrade-0.1.0-1.6.0.php ADDED
@@ -0,0 +1,45 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ include_once 'uninstall-old-version.php';
3
+ $unistaller_old_version = new Uninstall_Bintime_Icecatlive();
4
+ $unistaller_old_version->uninstall();
5
+ $installer = $this;
6
+ /* @var $installer Mage_Catalog_Model_Resource_Eav_Mysql4_Setup */
7
+
8
+ $installer->startSetup();
9
+
10
+ $installer->run("
11
+ DROP TABLE IF EXISTS `bintime_connector_data`;
12
+ DROP TABLE IF EXISTS `bintime_connector_data_old`;
13
+ DROP TABLE IF EXISTS `bintime_connector_data_products`;
14
+ DROP TABLE IF EXISTS `bintime_supplier_mapping`;
15
+ DROP TABLE IF EXISTS `bintime_supplier_mapping_old`;
16
+ DROP TABLE IF EXISTS {$this->getTable('icecatlive/data')};
17
+ CREATE TABLE {$this->getTable('icecatlive/data')} (
18
+ `prod_id` varchar(255) NOT NULL,
19
+ `supplier_id` int(11) DEFAULT NULL,
20
+ `prod_name` varchar(255) DEFAULT NULL,
21
+ `prod_img` varchar(255) DEFAULT NULL,
22
+ KEY `PRODUCT_MPN` (`prod_id`),
23
+ KEY `supplier_id` (`supplier_id`)
24
+ ) ENGINE=InnoDB DEFAULT CHARSET=utf8 COMMENT='Iceshop Connector product image table';
25
+
26
+ DROP TABLE IF EXISTS {$this->getTable('icecatlive/supplier_mapping')};
27
+ CREATE TABLE {$this->getTable('icecatlive/supplier_mapping')} (
28
+ `supplier_id` int(11) NOT NULL,
29
+ `supplier_symbol` VARCHAR(255),
30
+ KEY `supplier_id` (`supplier_id`)
31
+ ) ENGINE=InnoDB DEFAULT CHARSET=utf8 COMMENT='Iceshop Connector supplier mapping table';
32
+
33
+ DROP TABLE IF EXISTS {$this->getTable('icecatlive/data_products')};
34
+ CREATE TABLE {$this->getTable('icecatlive/data_products')} (
35
+ `prod_id` VARCHAR(255) NOT NULL,
36
+ `supplier_symbol` varchar(255) DEFAULT NULL,
37
+ `prod_title` VARCHAR(255) NULL DEFAULT NULL,
38
+ `prod_ean` VARCHAR(255) NOT NULL,
39
+ KEY `prod_id` (`prod_id`),
40
+ KEY `PRODUCT_EAN` (`prod_ean`),
41
+ INDEX `mpn_brand` (`prod_id`, `supplier_symbol`)
42
+ ) ENGINE=InnoDB DEFAULT CHARSET=utf8 COMMENT='Iceshop Connector product ean table';
43
+ ");
44
+
45
+ $installer->endSetup();
app/code/local/Iceshop/Icecatlive/sql/icecatlive_setup/mysql4-upgrade-0.1.1-1.6.0.php ADDED
@@ -0,0 +1,45 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ include_once 'uninstall-old-version.php';
3
+ $unistaller_old_version = new Uninstall_Bintime_Icecatlive();
4
+ $unistaller_old_version->uninstall();
5
+ $installer = $this;
6
+ /* @var $installer Mage_Catalog_Model_Resource_Eav_Mysql4_Setup */
7
+
8
+ $installer->startSetup();
9
+
10
+ $installer->run("
11
+ DROP TABLE IF EXISTS `bintime_connector_data`;
12
+ DROP TABLE IF EXISTS `bintime_connector_data_old`;
13
+ DROP TABLE IF EXISTS `bintime_connector_data_products`;
14
+ DROP TABLE IF EXISTS `bintime_supplier_mapping`;
15
+ DROP TABLE IF EXISTS `bintime_supplier_mapping_old`;
16
+ DROP TABLE IF EXISTS {$this->getTable('icecatlive/data')};
17
+ CREATE TABLE {$this->getTable('icecatlive/data')} (
18
+ `prod_id` varchar(255) NOT NULL,
19
+ `supplier_id` int(11) DEFAULT NULL,
20
+ `prod_name` varchar(255) DEFAULT NULL,
21
+ `prod_img` varchar(255) DEFAULT NULL,
22
+ KEY `PRODUCT_MPN` (`prod_id`),
23
+ KEY `supplier_id` (`supplier_id`)
24
+ ) ENGINE=InnoDB DEFAULT CHARSET=utf8 COMMENT='Iceshop Connector product image table';
25
+
26
+ DROP TABLE IF EXISTS {$this->getTable('icecatlive/supplier_mapping')};
27
+ CREATE TABLE {$this->getTable('icecatlive/supplier_mapping')} (
28
+ `supplier_id` int(11) NOT NULL,
29
+ `supplier_symbol` VARCHAR(255),
30
+ KEY `supplier_id` (`supplier_id`)
31
+ ) ENGINE=InnoDB DEFAULT CHARSET=utf8 COMMENT='Iceshop Connector supplier mapping table';
32
+
33
+ DROP TABLE IF EXISTS {$this->getTable('icecatlive/data_products')};
34
+ CREATE TABLE {$this->getTable('icecatlive/data_products')} (
35
+ `prod_id` VARCHAR(255) NOT NULL,
36
+ `supplier_symbol` varchar(255) DEFAULT NULL,
37
+ `prod_title` VARCHAR(255) NULL DEFAULT NULL,
38
+ `prod_ean` VARCHAR(255) NOT NULL,
39
+ KEY `prod_id` (`prod_id`),
40
+ KEY `PRODUCT_EAN` (`prod_ean`),
41
+ INDEX `mpn_brand` (`prod_id`, `supplier_symbol`)
42
+ ) ENGINE=InnoDB DEFAULT CHARSET=utf8 COMMENT='Iceshop Connector product ean table';
43
+ ");
44
+
45
+ $installer->endSetup();
app/code/local/Iceshop/Icecatlive/sql/icecatlive_setup/mysql4-upgrade-1.5.0-1.6.0.php ADDED
@@ -0,0 +1,45 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ include_once 'uninstall-old-version.php';
3
+ $unistaller_old_version = new Uninstall_Bintime_Icecatlive();
4
+ $unistaller_old_version->uninstall();
5
+ $installer = $this;
6
+ /* @var $installer Mage_Catalog_Model_Resource_Eav_Mysql4_Setup */
7
+
8
+ $installer->startSetup();
9
+
10
+ $installer->run("
11
+ DROP TABLE IF EXISTS `bintime_connector_data`;
12
+ DROP TABLE IF EXISTS `bintime_connector_data_old`;
13
+ DROP TABLE IF EXISTS `bintime_connector_data_products`;
14
+ DROP TABLE IF EXISTS `bintime_connector_data_products`;
15
+ DROP TABLE IF EXISTS `bintime_supplier_mapping_old`;
16
+ DROP TABLE IF EXISTS {$this->getTable('icecatlive/data')};
17
+ CREATE TABLE {$this->getTable('icecatlive/data')} (
18
+ `prod_id` varchar(255) NOT NULL,
19
+ `supplier_id` int(11) DEFAULT NULL,
20
+ `prod_name` varchar(255) DEFAULT NULL,
21
+ `prod_img` varchar(255) DEFAULT NULL,
22
+ KEY `PRODUCT_MPN` (`prod_id`),
23
+ KEY `supplier_id` (`supplier_id`)
24
+ ) ENGINE=InnoDB DEFAULT CHARSET=utf8 COMMENT='Iceshop Connector product image table';
25
+
26
+ DROP TABLE IF EXISTS {$this->getTable('icecatlive/supplier_mapping')};
27
+ CREATE TABLE {$this->getTable('icecatlive/supplier_mapping')} (
28
+ `supplier_id` int(11) NOT NULL,
29
+ `supplier_symbol` VARCHAR(255),
30
+ KEY `supplier_id` (`supplier_id`)
31
+ ) ENGINE=InnoDB DEFAULT CHARSET=utf8 COMMENT='Iceshop Connector supplier mapping table';
32
+
33
+ DROP TABLE IF EXISTS {$this->getTable('icecatlive/data_products')};
34
+ CREATE TABLE {$this->getTable('icecatlive/data_products')} (
35
+ `prod_id` VARCHAR(255) NOT NULL,
36
+ `supplier_symbol` varchar(255) DEFAULT NULL,
37
+ `prod_title` VARCHAR(255) NULL DEFAULT NULL,
38
+ `prod_ean` VARCHAR(255) NOT NULL,
39
+ KEY `prod_id` (`prod_id`),
40
+ KEY `PRODUCT_EAN` (`prod_ean`),
41
+ INDEX `mpn_brand` (`prod_id`, `supplier_symbol`)
42
+ ) ENGINE=InnoDB DEFAULT CHARSET=utf8 COMMENT='Iceshop Connector product ean table';
43
+ ");
44
+
45
+ $installer->endSetup();
app/code/local/Iceshop/Icecatlive/sql/icecatlive_setup/uninstall-old-version.php ADDED
@@ -0,0 +1,54 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ class Uninstall_Bintime_Icecatlive
3
+ {
4
+ /**
5
+ * Delete Icecatlive extension with old namespace
6
+ */
7
+ public function uninstall()
8
+ {
9
+ $code_dir = Mage::getBaseDir('app') . '/code/local/Bintime/Icecatimport';
10
+ $design_layout = Mage::getBaseDir('app') . '/design/frontend/base/default/layout/IcecatGroupAttributes.xml';
11
+ $template_dir = Mage::getBaseDir('app') . '/design/frontend/base/default/template/icecatlive';
12
+ $etc_bintime_xml = Mage::getBaseDir('app') . '/etc/modules/Bintime_Icecatimport.xml';
13
+ $package_bintime_xml = Mage::getBaseDir('var') . '/package/IcecatLive-1.5.0.xml';
14
+
15
+ $this->remove_dir($code_dir);
16
+ $this->remove_dir($template_dir);
17
+ $this->remove_file($design_layout);
18
+ $this->remove_file($etc_bintime_xml);
19
+ $this->remove_file($package_bintime_xml);
20
+ }
21
+
22
+ public function remove_dir($path)
23
+ {
24
+ if (file_exists($path) && is_dir($path)) {
25
+ $dirHandle = opendir($path);
26
+ while (false !== ($file = readdir($dirHandle))) {
27
+ if ($file != '.' && $file != '..') {
28
+ $tmpPath = $path . '/' . $file;
29
+ chmod($tmpPath, 0777);
30
+
31
+ if (is_dir($tmpPath)) {
32
+ $this->remove_dir($tmpPath);
33
+ } else {
34
+ if (file_exists($tmpPath)) {
35
+ unlink($tmpPath);
36
+ }
37
+ }
38
+ }
39
+ }
40
+ closedir($dirHandle);
41
+
42
+ if (file_exists($path)) {
43
+ rmdir($path);
44
+ }
45
+ }
46
+ }
47
+
48
+ public function remove_file($path)
49
+ {
50
+ if (file_exists($path)) {
51
+ unlink($path);
52
+ }
53
+ }
54
+ }
app/design/adminhtml/default/default/template/iceshop/icecatlive/ajaxstatusimport.phtml ADDED
@@ -0,0 +1,84 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <script type="text/javascript">
2
+ function importStatusMonitor(){
3
+ new Ajax.Request('<?php echo Mage::helper('adminhtml')->getUrl('adminhtml/adminhtml_importprogress/check'); ?>', {
4
+ method: 'get',
5
+ onSuccess: function(transport){
6
+ var response = "";
7
+ var step = transport.responseJSON.size();
8
+ transport.responseJSON.forEach(function(element, index, array){
9
+ index = index+1;
10
+ response += "<p>"+index+". "+element+"</p>";
11
+ });
12
+ if($('loading_mask_loader').select('#icecatlive-response').size() == 0){
13
+ $('loading_mask_loader').insert({bottom: '<div id="icecatlive-response" style="text-align: left">'+response+'</div>'});
14
+ }else{
15
+ $('icecatlive-response').replace('<div id="icecatlive-response" style="text-align: left">'+response+'</div>');
16
+ }
17
+ if($('loading_mask_loader').select('#icecatlive-curstep-response').size() == 0){
18
+ $('icecatlive-response').insert({before: '<p id="icecatlive-curstep-response">Current step: '+step+'/9</div>'});
19
+ }else{
20
+ $('icecatlive-curstep-response').replace('<p id="icecatlive-curstep-response">Current step: '+step+'/9</div>');
21
+ }
22
+ if(step == 9){
23
+ $$('#loading_mask_loader > img')[0].setStyle({
24
+ 'display': 'none'
25
+ });
26
+ var str = $('loading_mask_loader').innerHTML;
27
+ str = str.replace('<br>Please wait...', '');
28
+ $('loading_mask_loader').innerHTML = str;
29
+ $('icecatlive-response').replace('<div id="icecatlive-response" style="text-align: left">'+response+'</div><br><button id="icecatlive_button_finish" onclick="javascript:hide_progress_popup(); return false;" title="Finish import" type="button" class="scalable " style=""><span><span><span>Finish import</span></span></span></button>');
30
+ clearInterval(timerId);
31
+ }
32
+
33
+ }
34
+ });
35
+ }
36
+ function check() {
37
+ $('loading_mask_loader').setStyle({
38
+ width: '430px',
39
+ marginLeft: '-235px',
40
+ top: '25%'
41
+ });
42
+ $('loading-mask').setStyle({
43
+ opacity: '0.90'
44
+ });
45
+ $$('#loading_mask_loader > img')[0].setStyle({
46
+ 'display': 'inline'
47
+ });
48
+ timerId = setInterval("importStatusMonitor()", 5000);
49
+ new Ajax.Request('<?php echo $this->getAjaxCheckUrl() ?>', {
50
+ method: 'get',
51
+ onSuccess: function(transport){
52
+ if (transport.responseText){
53
+ alert(transport.responseText);
54
+ clearInterval(timerId);
55
+ $('loading-mask').setStyle({
56
+ 'display': 'none'
57
+ });
58
+ }
59
+ },
60
+ onComplete: function(transport){
61
+ clearInterval(timerId);
62
+ $('loading_mask').setStyle({
63
+ 'display': 'block'
64
+ });
65
+ }
66
+ });
67
+ }
68
+ function hide_progress_popup(){
69
+ $('loading-mask').setStyle({
70
+ display: 'none'
71
+ });
72
+ $('icecatlive-curstep-response').remove();
73
+ $('icecatlive-response').remove();
74
+ $('icecatlive_button_finish').remove();
75
+ }
76
+ $('config_edit_form').on('change', '.input-text, .select', function(event) {
77
+ if(!$('icecatlive-saveconfig')){
78
+ $('icecatlive_button').writeAttribute('disabled', 'disabled');
79
+ $('icecatlive_button').addClassName('disabled');
80
+ $('icecatlive_button').insert({before: '<p id="icecatlive-saveconfig">Please save configuration, and after start import</p>'});
81
+ }
82
+ });
83
+ </script>
84
+ <?php echo $this->getButtonHtml(); ?>
app/design/frontend/base/default/layout/IcecatGroupAttributes.xml DELETED
@@ -1,17 +0,0 @@
1
- <layout version="0.1.0">
2
-
3
- <catalog_product_view>
4
-
5
- <reference name="content">
6
- <block name="product.info" >
7
-
8
- <block type="Bintime_Icecatimport/Attributes" name="product.attributes" as="additional" template="icecatlive/attributesasgroup/groupview.phtml">
9
- <action method="addToParentGroup"><group>detailed_info</group></action>
10
- </block>
11
-
12
- </block>
13
- </reference>
14
-
15
- </catalog_product_view>
16
-
17
- </layout>
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
app/design/frontend/default/default/layout/iceshop/icecatlive/groupattributes.xml ADDED
@@ -0,0 +1,25 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <layout version="0.1.0">
2
+ <catalog_product_view>
3
+ <reference name="product.info.tabs">
4
+ <block type="Iceshop_Icecatlive/Attributes" name="product.attributes" as="additional">
5
+ <action method="setTemplate">
6
+ <template>iceshop/icecatlive/groupattributes.phtml</template>
7
+ </action>
8
+ </block>
9
+ </reference>
10
+ <reference name="product.info.tabs">
11
+ <block type="Iceshop_Icecatlive/Attributes" name="product.attributes" as="additional_tabbed">
12
+ <action method="setTemplate" ifconfig="easy_tabs/general/enabled">
13
+ <template>iceshop/icecatlive/groupattributes.phtml</template>
14
+ </action>
15
+ </block>
16
+ </reference>
17
+ <reference name="content">
18
+ <block name="product.info" >
19
+ <block type="Iceshop_Icecatlive/Attributes" name="product.attributes" as="additional" template="iceshop/icecatlive/groupattributes.phtml">
20
+ <action method="addToParentGroup"><group>detailed_info</group></action>
21
+ </block>
22
+ </block>
23
+ </reference>
24
+ </catalog_product_view>
25
+ </layout>
app/design/frontend/{base/default/template/icecatlive/attributesasgroup/groupview.phtml → default/default/template/iceshop/icecatlive/groupattributes.phtml} RENAMED
@@ -1,6 +1,6 @@
1
  <?php
2
  $_helper = $this->helper('catalog/output');
3
- $_product = $this->getProduct()
4
  ?>
5
  <?php if($_additionalgroup = $this->getAdditionalData()): ?>
6
  <div class="box-collateral box-additional">
1
  <?php
2
  $_helper = $this->helper('catalog/output');
3
+ $_product = $this->getProduct();
4
  ?>
5
  <?php if($_additionalgroup = $this->getAdditionalData()): ?>
6
  <div class="box-collateral box-additional">
app/etc/modules/{Bintime_Icecatimport.xml → Iceshop_Icecatlive.xml} RENAMED
@@ -1,9 +1,12 @@
1
  <?xml version="1.0" encoding="UTF-8"?>
2
  <config>
3
  <modules>
4
- <Bintime_Icecatimport>
5
  <active>true</active>
6
  <codePool>local</codePool>
7
- </Bintime_Icecatimport>
 
 
 
8
  </modules>
9
  </config>
1
  <?xml version="1.0" encoding="UTF-8"?>
2
  <config>
3
  <modules>
4
+ <Iceshop_Icecatlive>
5
  <active>true</active>
6
  <codePool>local</codePool>
7
+ <depends>
8
+ <Mage_Catalog />
9
+ </depends>
10
+ </Iceshop_Icecatlive>
11
  </modules>
12
  </config>
package.xml CHANGED
@@ -1,38 +1,24 @@
1
  <?xml version="1.0"?>
2
  <package>
3
  <name>IcecatLive</name>
4
- <version>1.5.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&amp;#xD;&#xD;
12
- - Added support of Multilanguage stores&amp;#xD;&#xD;
13
- - Added new setting Description Priority&amp;#xD;&#xD;
14
- - Added new setting Short Description Priority&amp;#xD;&#xD;
15
- - Added new setting Product Name Priority&amp;#xD;&#xD;
16
- - Added new setting Product Images Priority&amp;#xD;&#xD;
17
- - Added new setting Product Priority - display or hide products not from icecat &amp;#xD;&#xD;
18
- - Added display additional attributes by groups on product's page &amp;#xD;&#xD;
19
- - Added loading products description from DB when icecat info is missing and config setting product descr source is set to icecat &amp;#xD; &#xD;
20
- - Added saving icecat images to server and display from there &amp;#xD; &#xD;
21
- - Added saving product title to db from file and display it on list page &amp;#xD; &#xD;
22
- - Added cron process lock - only one icecat cron process can be running at a time &amp;#xD; &#xD;
23
- - LOAD LOCAL replaced with insert queries &amp;#xD;&#xD;
24
- - Removed logo images from product images gallery &amp;#xD;&#xD;
25
- - Fixed problems with Icecat names&amp;#xD;&#xD;
26
- - Fixed problems with images on product listing/shopping cart.&amp;#xD;&#xD;
27
- - Fixed problems with correct displaying attributes on product detail page&amp;#xD;&#xD;
28
- - Fixed problems with description on product detail page &amp;#xD;&#xD;
29
- - Fixed product info in breadcrumbs &amp;#xD;&#xD;
30
- - Fixed problems with loading icecat data for each product on product listing page &amp;#xD;
31
- - Fixed problems with product images and gallery&amp;#xD;</notes>
32
  <authors><author><name>IceShop</name><user>IceShop</user><email>support@iceshop.nl</email></author></authors>
33
- <date>2013-07-18</date>
34
- <time>16:03:03</time>
35
- <contents><target name="magedesign"><dir name="frontend"><dir name="base"><dir name="default"><dir name="layout"><file name="IcecatGroupAttributes.xml" hash="61719bd9a27b0ef670e22919b755f65d"/></dir><dir name="template"><dir name="icecatlive"><dir name="attributesasgroup"><file name="groupview.phtml" hash="6c37ec003f0dded289adc8b778918cc3"/></dir></dir></dir></dir></dir></dir></target><target name="magelocal"><dir name="Bintime"><dir name="Icecatimport"><dir name="CatalogSearch"><dir name="Block"><file name="Result.php" hash="ae81e0a964e8990e5b65fb1d08f1edf9"/></dir></dir><dir name="Block"><dir name="Product"><dir name="List"><file name="Toolbar.php" hash="ae82e0a964e8990e5b35fb1d08f1edf9"/></dir></dir><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="Productpriority.php" hash="8c24c2dffd826e7b8259557d61f33ea7"/><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>
36
  <compatible/>
37
  <dependencies><required><php><min>5.2.0</min><max>6.0.0</max></php></required></dependencies>
38
  </package>
1
  <?xml version="1.0"?>
2
  <package>
3
  <name>IcecatLive</name>
4
+ <version>1.6.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>- Changed namespaces, renamed Bintime to Iceshop&#xD;
12
+ - Fixed cache mechanizm &#xD;
13
+ - Fixed mapping via EAN&#xD;
14
+ - Fixed images display with CloudZoom&#xD;
15
+ - Fixed mapping with Brand (if the attribute type Pulldown)&#xD;
16
+ - Added import button to module settings, and possibility to run import via admin part&#xD;
17
+ - Added log file, administrator of the shop can see what is going on with import.</notes>
 
 
 
 
 
 
 
 
 
 
 
 
 
 
18
  <authors><author><name>IceShop</name><user>IceShop</user><email>support@iceshop.nl</email></author></authors>
19
+ <date>2013-11-07</date>
20
+ <time>19:09:10</time>
21
+ <contents><target name="magelocal"><dir name="Iceshop"><dir name="Icecatlive"><dir name="Block"><dir name="Adminhtml"><dir name="System"><dir name="Config"><dir name="Form"><file name="Button.php" hash="060e727229ea7fe0116d894375e46ccc"/></dir></dir></dir></dir><file name="Attributes.php" hash="c6415d3dd62928e8363ac562d1509eda"/><file name="Media.php" hash="eac711e0b5a0cb5eee87b035dc6b6584"/><dir name="Product"><dir name="List"><file name="Toolbar.php" hash="827cc9425dcf53f0eab287c584342a2f"/></dir></dir><file name="Related.php" hash="305e30364ffec05257ecb7956470f2ce"/><file name="Upsell.php" hash="8370215562ea0684f44ec25a6bbf7634"/></dir><dir name="CatalogSearch"><dir name="Block"><file name="Result.php" hash="e9eabb74fe9c4ad4cb8e138899af2fd4"/></dir></dir><dir name="Helper"><dir name="Catalog"><file name="Image.php" hash="c12cb636446736b4eb8c9c5010089cd9"/></dir><file name="Data.php" hash="2debdcd5ae800419c9b658ef01a75fa8"/><file name="Getdata.php" hash="6ddbbb71f5063ffb5bef171fe04fa163"/><file name="Image.php" hash="192111886575c50ab56c69e1fb1e99b0"/><file name="Output.php" hash="d47c10493a2daa756c4287d31913bdf2"/></dir><dir name="Model"><dir name="Catalog"><file name="Category.php" hash="6d7a1b0bff06cc7f3d4b12c281313e16"/><file name="Product.php" hash="2e5a8a4e979cd47e9f864c8a9a168652"/><file name="Search.php" hash="d5dc1e71739dc3d818b1ba18a1c4cbd8"/></dir><file name="Imagescollection.php" hash="1276b565a520302e1ab328bbc4f45fa4"/><file name="Import.php" hash="dd5a72c9645e581c52bbb77e6037dead"/><file name="Observer.php" hash="912cb2184418740f6f1f49e84151cf8c"/><file name="Relatedcollection.php" hash="9c5998f5be9bfaefaa4445fd28243611"/><dir name="System"><dir name="Config"><file name="Attributes.php" hash="24ec7ed5c52243d17f9569b02d89d0be"/><file name="Descriptionpriority.php" hash="0be58ba20705c1366973e2ce0c4ed697"/><file name="Imagepriority.php" hash="6a0ca72cb1609cfc3de185b265f5314e"/><file name="Importdata.php" hash="25196649542ccc4df2da39f6cc1ec043"/><file name="LanguageList.xml" hash="2db6d2299b1f23fb01cb0a0a44cc2bdd"/><file name="Locales.php" hash="2ddd740afacf4940aae1c39e91360aef"/><file name="Namepriority.php" hash="c1ee76d38fb206e624b0cff4bf237cf8"/><file name="Productpriority.php" hash="5044f2ab2a240841ea2854f452cc590a"/><file name="Shortdescrpriority.php" hash="df10c1a81411671500633ee776f0ca8f"/><file name="Subscription.php" hash="e919a1840cb7aa93a695b85d164efea0"/></dir></dir></dir><dir name="controllers"><dir name="Adminhtml"><file name="ImportdataController.php" hash="c4874ee811ce4d3d446835ddc6cb2f94"/><file name="ImportprogressController.php" hash="a9212979beb0aa57447d7d70f3297a28"/></dir><file name="ImageController.php" hash="16c6234143705c6a97b492e5a87256bd"/></dir><dir name="etc"><file name="config.xml" hash="7afdccc2672d80938dc38d7048d2fe39"/><file name="system.xml" hash="154160edd2fdab042e66f6b21f1d1ce0"/></dir><dir name="sql"><dir name="icecatlive_setup"><file name="mysql4-install-1.6.0.php" hash="72b3756955758e2bdf2fad03145a203f"/><file name="mysql4-upgrade-0.1.0-1.6.0.php" hash="4ae2830d9e1a2d452ec8c131ca6e4d8f"/><file name="mysql4-upgrade-0.1.1-1.6.0.php" hash="22949a2edd4e47b3308a579819f0ce54"/><file name="mysql4-upgrade-1.5.0-1.6.0.php" hash="a09bf3687fd9eea2fd8a5bd01e1325d6"/><file name="uninstall-old-version.php" hash="92c247b6eebe23a2ccc3f0ec1627f15f"/></dir></dir></dir></dir></target><target name="magedesign"><dir name="frontend"><dir name="default"><dir name="default"><dir name="layout"><dir name="iceshop"><dir name="icecatlive"><file name="groupattributes.xml" hash="29fb1f5d19c04221f668485dccace23d"/></dir></dir></dir><dir name="template"><dir name="iceshop"><dir name="icecatlive"><file name="groupattributes.phtml" hash="15eca455effeba48b3453b39ee887245"/></dir></dir></dir></dir></dir></dir><dir name="adminhtml"><dir name="default"><dir name="default"><dir name="template"><dir name="iceshop"><dir name="icecatlive"><file name="ajaxstatusimport.phtml" hash="b902e3ce605ff29b024ad43ee8f3990e"/></dir></dir></dir></dir></dir></dir></target><target name="mageetc"><dir name="modules"><file name="Iceshop_Icecatlive.xml" hash="b097c8e9a31651d1ab43ff1db9f30d56"/></dir></target></contents>
22
  <compatible/>
23
  <dependencies><required><php><min>5.2.0</min><max>6.0.0</max></php></required></dependencies>
24
  </package>