IcecatLive - Version 1.0.0

Version Notes

- Optimized synchronize.
- Fixed product listing.
- Fixed caching already downloaded products info.

Download this release

Release Info

Developer IceShop
Extension IcecatLive
Version 1.0.0
Comparing to
See all releases


Version 1.0.0

Files changed (26) hide show
  1. app/code/local/Bintime/Icecatimport/Block/Attributes.php +78 -0
  2. app/code/local/Bintime/Icecatimport/Block/Media.php +41 -0
  3. app/code/local/Bintime/Icecatimport/Block/Related.php +59 -0
  4. app/code/local/Bintime/Icecatimport/Block/Upsell.php +50 -0
  5. app/code/local/Bintime/Icecatimport/Helper/Catalog/Image.php +50 -0
  6. app/code/local/Bintime/Icecatimport/Helper/Getdata.php +224 -0
  7. app/code/local/Bintime/Icecatimport/Helper/Image.php +50 -0
  8. app/code/local/Bintime/Icecatimport/Helper/Output.php +79 -0
  9. app/code/local/Bintime/Icecatimport/Model/Catalog/Category.php +19 -0
  10. app/code/local/Bintime/Icecatimport/Model/Catalog/Product.php +164 -0
  11. app/code/local/Bintime/Icecatimport/Model/Catalog/Search.php +15 -0
  12. app/code/local/Bintime/Icecatimport/Model/Imagescollection.php +45 -0
  13. app/code/local/Bintime/Icecatimport/Model/Import.php +317 -0
  14. app/code/local/Bintime/Icecatimport/Model/Observer.php +319 -0
  15. app/code/local/Bintime/Icecatimport/Model/Relatedcollection.php +71 -0
  16. app/code/local/Bintime/Icecatimport/Model/System/Config/Attributes.php +21 -0
  17. app/code/local/Bintime/Icecatimport/Model/System/Config/LanguageList.xml +399 -0
  18. app/code/local/Bintime/Icecatimport/Model/System/Config/Locales.php +45 -0
  19. app/code/local/Bintime/Icecatimport/Model/System/Config/Subscription.php +18 -0
  20. app/code/local/Bintime/Icecatimport/controllers/ImageController.php +16 -0
  21. app/code/local/Bintime/Icecatimport/etc/config.xml +147 -0
  22. app/code/local/Bintime/Icecatimport/etc/system.xml +79 -0
  23. app/code/local/Bintime/Icecatimport/sql/icecatimport_setup/mysql4-install-0.1.0.php +23 -0
  24. app/code/local/Bintime/Icecatimport/sql/icecatimport_setup/mysql4-upgrade-0.1.0-0.1.1.php +12 -0
  25. app/etc/modules/Bintime_Icecatimport.xml +9 -0
  26. package.xml +20 -0
app/code/local/Bintime/Icecatimport/Block/Attributes.php ADDED
@@ -0,0 +1,78 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ class Bintime_Icecatimport_Block_Attributes extends Mage_Catalog_Block_Product_View_Attributes
4
+ {
5
+ public function getAdditionalData(array $excludeAttr = array())
6
+ {
7
+ $data = $this->getAttributesArray();
8
+ $data2 = array();
9
+ foreach($data as $_data)
10
+ {
11
+ if( $_data['label'] != '' && $_data['value'] != '' && $_data['code'] == 'descript'){
12
+ $data2[] = array(
13
+ 'label'=>$_data['label'],
14
+ 'value'=>$_data['value'],
15
+ 'code'=>''
16
+ );}
17
+
18
+ if( $_data['label'] == '' && $_data['value'] != '' && $_data['code'] == 'header')
19
+ {
20
+ $data2[] = array(
21
+ 'label'=>$_data['label'],
22
+ 'value'=>$_data['value'],
23
+ 'code'=>''
24
+ );}
25
+ //
26
+ }
27
+ return $data2;
28
+ }
29
+
30
+ public function formatValue($value) {
31
+ if($value == "Y"){
32
+ return '<img border="0" alt="" src="http://prf.icecat.biz/imgs/yes.gif"/>';
33
+ }
34
+ else if ($value == "N"){
35
+ return '<img border="0" alt="" src="http://prf.icecat.biz/imgs/no.gif"/>';
36
+ }
37
+
38
+ return
39
+ str_replace("\\n", "<br>",
40
+ htmlspecialchars($value)
41
+ );
42
+ }
43
+
44
+ public function getAttributesArray() {
45
+ $iceModel = Mage::getSingleton('icecatimport/import');
46
+ $descriptionsListArray = $iceModel->getProductDescriptionList();
47
+ foreach($descriptionsListArray as $ma)
48
+ {
49
+ foreach($ma as $key=>$value)
50
+ {
51
+ $arr[$key] = $value;
52
+ }
53
+ }
54
+
55
+ $data = array();
56
+ foreach ($arr as $key => $value) {
57
+ //$attributes = Mage::getModel('catalog/product')->getAttributesFromIcecat($this->getProduct()->getEntityId(), $value);
58
+ // @todo @someday @maybe make headers
59
+ $data[] = array(
60
+ 'label'=>'',
61
+ 'value'=>'<h1>'.$key.'</h1>',
62
+ 'code'=>'header'
63
+ );
64
+ $attributes = $value;
65
+ foreach ($attributes as $attributeLabel => $attributeValue) {
66
+ $data[] = array(
67
+ 'label'=>$attributeLabel,
68
+ 'value'=>$this->formatValue($attributeValue),
69
+ 'code'=>'descript'
70
+ );
71
+ }
72
+ }
73
+ return $data;
74
+ }
75
+
76
+
77
+
78
+ }
app/code/local/Bintime/Icecatimport/Block/Media.php ADDED
@@ -0,0 +1,41 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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
+ $collection = $this->getProduct()->getMediaGalleryImages();
15
+ $items = $collection->getItems();
16
+ if(!empty($icePhotos)){
17
+ return Mage::getSingleton('Bintime_Icecatimport_Model_Imagescollection',array(
18
+ 'product' => $this->getProduct()
19
+ ));
20
+ }
21
+ else{
22
+ return $collection;
23
+ }
24
+ }
25
+
26
+
27
+
28
+ public function getGalleryUrl($image=null)
29
+ {
30
+ $iceCatModel = Mage::getSingleton('icecatimport/import');
31
+ $icePhotos = $iceCatModel->getGalleryPhotos();
32
+ $collection = $this->getProduct()->getMediaGalleryImages();
33
+ $items = $collection->getItems();
34
+ if(!empty($icePhotos))
35
+ return $image['file'];
36
+ else
37
+ return parent::getGalleryUrl($image);
38
+ }
39
+
40
+
41
+ }
app/code/local/Bintime/Icecatimport/Block/Related.php ADDED
@@ -0,0 +1,59 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * Magento
4
+ *
5
+ * NOTICE OF LICENSE
6
+ *
7
+ * This source file is subject to the Open Software License (OSL 3.0)
8
+ * that is bundled with this package in the file LICENSE.txt.
9
+ * It is also available through the world-wide-web at this URL:
10
+ * http://opensource.org/licenses/osl-3.0.php
11
+ * If you did not receive a copy of the license and are unable to
12
+ * obtain it through the world-wide-web, please send an email
13
+ * to license@magentocommerce.com so we can send you a copy immediately.
14
+ *
15
+ * DISCLAIMER
16
+ *
17
+ * Do not edit or add to this file if you wish to upgrade Magento to newer
18
+ * versions in the future. If you wish to customize Magento for your
19
+ * needs please refer to http://www.magentocommerce.com for more information.
20
+ *
21
+ * @category Mage
22
+ * @package Mage_Catalog
23
+ * @copyright Copyright (c) 2010 Magento Inc. (http://www.magentocommerce.com)
24
+ * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
25
+ */
26
+
27
+
28
+ /**
29
+ * Catalog product related items block
30
+ *
31
+ * @category Mage
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
+ }
app/code/local/Bintime/Icecatimport/Block/Upsell.php ADDED
@@ -0,0 +1,50 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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
+
25
+ // Mage::getSingleton('catalog/product_status')->addSaleableFilterToCollection($this->_itemCollection);
26
+ Mage::getSingleton('catalog/product_visibility')->addVisibleInCatalogFilterToCollection($this->_itemCollection);
27
+
28
+ if ($this->getItemLimit('upsell') > 0) {
29
+ $this->_itemCollection->setPageSize($this->getItemLimit('upsell'));
30
+ }
31
+
32
+ $this->_itemCollection->load();
33
+ /**
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
+ //TODO what this code do?
42
+ foreach ($this->_itemCollection as $product) {
43
+ $product->setDoNotUseCategoryId(true);
44
+ }
45
+
46
+ return $this;
47
+ }
48
+
49
+
50
+ }
app/code/local/Bintime/Icecatimport/Helper/Catalog/Image.php ADDED
@@ -0,0 +1,50 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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
+
19
+
20
+ if ($attributeName == 'image' && $imageFile == null ) {
21
+ $imageFile = mage::getsingleton('icecatimport/import')->getLowPicUrl();
22
+ }
23
+ if ($attributeName == 'thumbnail' && $imageFile == null ) {
24
+ $imageFile = $product->getData($attributeName);
25
+
26
+ }
27
+
28
+ if ($attributeName == 'small_image' && $imageFile == null) {
29
+ $imageFile = Mage::helper('icecatimport/image')->getImage($product);
30
+ }
31
+
32
+ return parent::init($product, $attributeName, $imageFile);
33
+ }
34
+
35
+ /**
36
+ * Return icecat image URL if set
37
+ */
38
+
39
+ public function __toString()
40
+ {
41
+ $url = parent::__toString();
42
+ if ( $this->getImageFile() && strpos( $this->getImageFile(), 'icecat.biz') && strpos($url, 'placeholder') ) {
43
+ $url = $this->getImageFile();
44
+ }
45
+
46
+ return $url;
47
+ }
48
+
49
+ }
50
+ ?>
app/code/local/Bintime/Icecatimport/Helper/Getdata.php ADDED
@@ -0,0 +1,224 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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()->from(Mage::getSingleton('core/resource')->getTableName('eav_entity_type'),'entity_type_id')->where('entity_type_code = ?', 'catalog_product')->limit(1);
23
+ $this->entityTypeId = $connection->fetchOne($query);
24
+ return $this->entityTypeId;
25
+ }
26
+
27
+ public function getProductDescription($_product) {
28
+ try {
29
+ $entityId = $_product->getEntityId();
30
+
31
+ $entity_type_id = $this->getEntityTypeId();
32
+ $connection = Mage::getSingleton('core/resource')->getConnection('core_read');
33
+
34
+
35
+ /* $mpnCode = Mage::getStoreConfig('icecat_root/icecat/sku_field');
36
+ $attributeInfo = Mage::getResourceModel('eav/entity_attribute_collection')
37
+ ->setCodeFilter($mpnCode)
38
+ ->setEntityTypeFilter($entity_type_id)
39
+ ->getFirstItem();
40
+
41
+ switch ($attributeInfo->getData('backend_type')) {
42
+ case 'static':
43
+ $query = $connection->select()->from('catalog_product_entity', $mpnCode)->where('entity_id = ?', $entityId);
44
+ break;
45
+
46
+ case 'int':
47
+ //echo "int";
48
+ break;
49
+
50
+ case 'varchar':
51
+ $query = $connection->select()->from('catalog_product_entity_varchar','value')->where('entity_id = ?', $entityId)->where('attribute_id = ?', $attributeInfo['attribute_id']);
52
+ break;
53
+
54
+ }
55
+ $mpn = $connection->fetchOne($query);
56
+ */
57
+
58
+ $mpn = $_product->getData(Mage::getStoreConfig('icecat_root/icecat/sku_field'));
59
+
60
+ $manufacturerId = $_product->getData(Mage::getStoreConfig('icecat_root/icecat/manufacturer'));
61
+
62
+ $attributeInfo = Mage::getResourceModel('eav/entity_attribute_collection')
63
+ ->setCodeFilter(Mage::getStoreConfig('icecat_root/icecat/manufacturer'))
64
+ ->setEntityTypeFilter($entity_type_id)
65
+ ->getFirstItem();
66
+
67
+ if ($attributeInfo->getData('backend_type') == 'int' ||
68
+ ($attributeInfo->getData('frontend_input') == 'select' && $attributeInfo->getData('backend_type') == 'static' )) {
69
+ $attribute = $attributeInfo->setEntity($_product->getResource());
70
+ $manufacturer = $attribute->getSource()->getOptionText($manufacturerId);
71
+ } else {
72
+ $manufacturer = $manufacturerId;
73
+ }
74
+
75
+ $locale = Mage::getStoreConfig('icecat_root/icecat/language');
76
+
77
+ if ($locale == '0'){
78
+ $systemLocale = explode("_", Mage::app()->getLocale()->getLocaleCode());
79
+ $locale = $systemLocale[0];
80
+ }
81
+ $userLogin = Mage::getStoreConfig('icecat_root/icecat/login');
82
+ $userPass = Mage::getStoreConfig('icecat_root/icecat/password');
83
+
84
+ $this->iceCatModel = Mage::getSingleton('icecatimport/import');
85
+
86
+ if (!$this->iceCatModel->getProductDescription($mpn, $manufacturer, $locale, $userLogin, $userPass, $entityId)){
87
+
88
+ $this->error = $this->iceCatModel->getErrorMessage();
89
+ $this->systemError = $this->iceCatModel->getSystemError();
90
+ //echo $this->systemError;
91
+ return $this;
92
+ }
93
+ } catch (Exception $e) {
94
+ Mage::log('Icecat getProductDescription error'.$e);
95
+ }
96
+ return $this;
97
+ }
98
+ /**
99
+ * returns true if error during data fetch occured else false
100
+ */
101
+ public function hasError(){
102
+ if ($this->error || $this->systemError){
103
+ return true;
104
+ }
105
+ return false;
106
+ }
107
+
108
+ /**
109
+ * return error message
110
+ */
111
+ public function getError(){
112
+ //show icecat error on product page return $this->error;
113
+ }
114
+
115
+ /**
116
+ * return system error
117
+ */
118
+ public function hasSystemError(){
119
+ if ($this->systemError){
120
+ return $this->systemError;
121
+ }
122
+ return false;
123
+ }
124
+
125
+ public function getProductDescriptionList(){
126
+ return $this->iceCatModel->getProductDescriptionList();
127
+ }
128
+
129
+ public function getShortProductDescription(){
130
+ return $this->iceCatModel->getShortProductDescription();
131
+ }
132
+
133
+ public function getLowPicUrl(){
134
+ return $this->iceCatModel->getLowPicUrl();
135
+ }
136
+ public function getThumbPicture(){
137
+ return $this->iceCatModel->getThumbPicture();
138
+ }
139
+
140
+ public function getGalleryPhotos(){
141
+ return $this->iceCatModel->getGalleryPhotos();
142
+ }
143
+
144
+ public function getProductName(){
145
+ return $this->iceCatModel->getProductName();
146
+ }
147
+ public function getVendor(){
148
+ return $this->iceCatModel->getVendor();
149
+ }
150
+
151
+ public function getFullProductDescription(){
152
+ return $this->iceCatModel->getFullProductDescription();
153
+ }
154
+
155
+ public function getMPN(){
156
+ return $this->iceCatModel->getMPN();
157
+ }
158
+ public function getEAN(){
159
+ return $this->iceCatModel->getEAN();
160
+ }
161
+
162
+ /**
163
+ * Form related products list according to store products
164
+ */
165
+ public function getRelatedProducts(){
166
+ $relatedProducts =$this->iceCatModel->getRelatedProducts();
167
+ if (empty($relatedProducts)){
168
+ return array();
169
+ }
170
+ $sku = Mage::getStoreConfig('icecat_root/icecat/sku_field');
171
+ $collection = Mage::getModel('catalog/product')->getCollection();
172
+ $filterArray = array();
173
+ foreach($relatedProducts as $mpn => $valueArray){
174
+ array_push($filterArray, array('attribute'=>$sku,'eq'=>$mpn));
175
+ }
176
+ $collection->addFieldToFilter($filterArray);
177
+
178
+ $collection->addAttributeToSelect($sku);
179
+ $collection->addAttributeToSelect('category_ids');
180
+ $relatedProductsList = array();
181
+ foreach ($collection as $product) {
182
+ $categoryIds = $product->getCategoryIds();
183
+
184
+ if(!empty($categoryIds)){
185
+ if (is_array($categoryIds)){
186
+ $catogoriesArray = $categoryIds;
187
+ }
188
+ if (is_string($categoryIds)){
189
+ $catogoriesArray = explode(",",$product->getCategoryIds());
190
+ }
191
+ foreach($catogoriesArray as $categoryId){
192
+ if (!array_key_exists($product->getData($sku), $relatedProducts)){
193
+ continue;
194
+ }
195
+ $relatedProductInfo = $relatedProducts[$product->getData($sku)];
196
+ $relatedProductInfo['mpn'] = $product->getData($sku);
197
+ $relatedProductInfo['url'] = preg_replace( '/\/\d+\/$/',"/".$categoryId."/",$product->getProductUrl());;
198
+ if (!array_key_exists($categoryId, $relatedProductsList)){
199
+ $relatedProductsList[$categoryId]= array();
200
+ }
201
+
202
+ array_push($relatedProductsList[$categoryId], $relatedProductInfo);
203
+ }
204
+ }
205
+ else {
206
+ if (!array_key_exists($product->getData($sku), $relatedProducts)){
207
+ continue;
208
+ }
209
+ $relatedProductInfo = $relatedProducts[$product->getData($sku)];
210
+ $relatedProductInfo['mpn'] = $product->getData($sku);
211
+ $relatedProductInfo['url'] = preg_replace( '/category\/\d+\/$/','',$product->getProductUrl());;
212
+ if (!array_key_exists('a', $relatedProductsList)){
213
+ $relatedProductsList['a']= array();
214
+ }
215
+
216
+ array_push($relatedProductsList['a'], $relatedProductInfo);
217
+ }
218
+ }
219
+ return $relatedProductsList;
220
+ }
221
+
222
+
223
+ }
224
+ ?>
app/code/local/Bintime/Icecatimport/Helper/Image.php ADDED
@@ -0,0 +1,50 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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
+
15
+ public function getImage($_product) {
16
+ $sku = $_product->getData(Mage::getStoreConfig('icecat_root/icecat/sku_field'));
17
+
18
+ $manufacturerId = $_product->getData(Mage::getStoreConfig('icecat_root/icecat/manufacturer'));
19
+
20
+ $connection = Mage::getSingleton('core/resource')->getConnection('core_read');
21
+ $query = $connection->select()->from(Mage::getSingleton('core/resource')->getTableName('eav_entity_type'),'entity_type_id')->where('entity_type_code = ?', 'catalog_product')->limit(1);
22
+ $entityTypeId = $connection->fetchOne($query);
23
+
24
+ $attributeInfo = Mage::getResourceModel('eav/entity_attribute_collection')
25
+ ->setCodeFilter(Mage::getStoreConfig('icecat_root/icecat/manufacturer'))
26
+ ->setEntityTypeFilter($_product->getResource()->getTypeId())
27
+ ->getFirstItem();
28
+
29
+ switch ($attributeInfo->getData('backend_type')) {
30
+ case 'int':
31
+ $attribute = $attributeInfo->setEntity($_product->getResource());
32
+ $manufacturer = $attribute->getSource()->getOptionText($manufacturerId);
33
+ break;
34
+
35
+ default:
36
+ $manufacturer = $manufacturerId;
37
+ break;
38
+ }
39
+
40
+ $this->observer = Mage::getSingleton('icecatimport/observer');
41
+ $url = $this->observer->getImageURL($sku, $manufacturer);
42
+ return $url;
43
+ }
44
+
45
+ public function getGallery() {
46
+ return Mage::getSingleton('icecatimport/import')->getGalleryPhotos();
47
+
48
+ }
49
+
50
+ }
app/code/local/Bintime/Icecatimport/Helper/Output.php ADDED
@@ -0,0 +1,79 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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
+ * @var isFirstTime spike for getProductDescription that is called many times from template
10
+ */
11
+ private $isFirstTime = true;
12
+
13
+ /**
14
+ * Prepare product attribute html output
15
+ *
16
+ * @param Mage_Catalog_Model_Product $product
17
+ * @param string $attributeHtml
18
+ * @param string $attributeName
19
+ * @return string
20
+ */
21
+
22
+ public function productAttribute($product, $attributeHtml, $attributeName)
23
+ {
24
+ if (!mage::registry('product')) {
25
+ return parent::productAttribute($product, $attributeHtml, $attributeName);
26
+ }
27
+
28
+ $this->iceCatModel = Mage::getSingleton('icecatimport/import');
29
+ if($this->isFirstTime){
30
+ $helper = Mage::helper('icecatimport/getdata');
31
+ $helper->getProductDescription($product);
32
+
33
+ if($helper->hasError())
34
+ {
35
+ $this->error = true;
36
+ }
37
+ $this->isFirstTime = false;
38
+
39
+ }
40
+
41
+ if($this->error)
42
+ {
43
+ return parent::productAttribute($product, $attributeHtml, $attributeName);
44
+ }
45
+ $id = $product->getData('entity_id');
46
+
47
+
48
+ if($attributeName == 'name')
49
+ {
50
+
51
+ //if we on product page then mage::registry('product' exist
52
+ if ($product->getId() == $this->iceCatModel->entityId && $name = $this->iceCatModel->getProductName()) {
53
+ return $name;
54
+ }
55
+
56
+ $manufacturerId = Mage::getStoreConfig('icecat_root/icecat/manufacturer');
57
+ $mpn = Mage::getStoreConfig('icecat_root/icecat/sku_field');
58
+ $collection = Mage::getResourceModel('catalog/product_collection');
59
+ $collection->addAttributeToSelect($manufacturerId)->addAttributeToSelect($mpn)
60
+ ->addAttributeToSelect('name')
61
+ ->addAttributeToFilter('entity_id', array('eq' => $id));
62
+ $product = $collection->getFirstItem() ;
63
+ return $product->getName();
64
+
65
+ }
66
+
67
+ if($attributeName == 'short_description')
68
+ {
69
+ return $this->iceCatModel->getShortProductDescription();
70
+ }
71
+ if($attributeName == 'description')
72
+ {
73
+ return str_replace("\\n", "<br>",$this->iceCatModel->getFullProductDescription());
74
+ }
75
+ else return parent::productAttribute($product, $attributeHtml, $attributeName);
76
+ }
77
+
78
+ }
79
+ ?>
app/code/local/Bintime/Icecatimport/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
+ * @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 ADDED
@@ -0,0 +1,164 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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
+ try {
13
+ $connection = Mage::getSingleton('core/resource')->getConnection('core_read');
14
+ $manufacturerId = $this->getData(Mage::getStoreConfig('icecat_root/icecat/manufacturer'));
15
+ $mpn = $this->getData(Mage::getStoreConfig('icecat_root/icecat/sku_field'));
16
+ $attributeInfo = Mage::getResourceModel('eav/entity_attribute_collection')
17
+ ->setCodeFilter(Mage::getStoreConfig('icecat_root/icecat/manufacturer'))
18
+ ->setEntityTypeFilter($this->getResource()->getTypeId())
19
+ ->getFirstItem();
20
+ switch ($attributeInfo->getData('backend_type')) {
21
+ case 'int':
22
+
23
+ $attribute = $attributeInfo->setEntity($this->getResource());
24
+ $manufacturer = $attribute->getSource()->getOptionText($manufacturerId);
25
+ break;
26
+
27
+ default:
28
+ $manufacturer = $manufacturerId;
29
+ break;
30
+ }
31
+
32
+ /*
33
+ $attributes = Mage::getResourceModel('eav/entity_attribute_collection')
34
+ ->setEntityTypeFilter($this->getResource()->getTypeId())
35
+ ->addFieldToFilter('attribute_code', 'manufacturer');
36
+
37
+ $attribute = $attributes->getFirstItem()->setEntity($this->getResource());
38
+ $manufacturer = $attribute->getSource()->getOptionText($manufacturerId);
39
+ */
40
+
41
+ $tableName = Mage::getSingleton('core/resource')->getTableName('icecatimport/data');
42
+ $mappingTable = Mage::getSingleton('core/resource')->getTableName('icecatimport/supplier_mapping');
43
+ $selectCondition = $connection->select()->
44
+ from(array('connector' => $tableName), new Zend_Db_Expr('connector.prod_name'))
45
+ ->joinInner(array('supplier' => $mappingTable), "connector.supplier_id = supplier.supplier_id AND supplier.supplier_symbol = {$connection->quote($manufacturer)}")
46
+ ->where('connector.prod_id = ? ', $mpn);
47
+
48
+ $icecatName = $connection->fetchOne($selectCondition);
49
+ } catch (Exception $e) {
50
+ Mage::log('Icecat getName error'.$e);
51
+ }
52
+
53
+ return $icecatName ? $icecatName : $this->getData('name');
54
+ }
55
+
56
+
57
+ public function getImage()
58
+ {
59
+ if(!parent::getImage()||parent::getImage() == 'no_selection')
60
+ {
61
+ return "true";
62
+ }
63
+ else
64
+ return parent::getImage();
65
+ }
66
+
67
+
68
+
69
+
70
+ /**
71
+ * Entity code.
72
+ * Can be used as part of method name for entity processing
73
+ */
74
+ const ENTITY = 'catalog_product';
75
+
76
+ const CACHE_TAG = 'catalog_product';
77
+ protected $_cacheTag = 'catalog_product';
78
+ protected $_eventPrefix = 'catalog_product';
79
+ protected $_eventObject = 'product';
80
+ protected $_canAffectOptions = false;
81
+
82
+ /**
83
+ * Product type instance
84
+ *
85
+ * @var Mage_Catalog_Model_Product_Type_Abstract
86
+ */
87
+ protected $_typeInstance = null;
88
+
89
+ /**
90
+ * Product type instance as singleton
91
+ */
92
+ protected $_typeInstanceSingleton = null;
93
+
94
+ /**
95
+ * Product link instance
96
+ *
97
+ * @var Mage_Catalog_Model_Product_Link
98
+ */
99
+ protected $_linkInstance;
100
+
101
+ /**
102
+ * Product object customization (not stored in DB)
103
+ *
104
+ * @var array
105
+ */
106
+ protected $_customOptions = array();
107
+
108
+ /**
109
+ * Product Url Instance
110
+ *
111
+ * @var Mage_Catalog_Model_Product_Url
112
+ */
113
+ protected $_urlModel = null;
114
+
115
+ protected static $_url;
116
+ protected static $_urlRewrite;
117
+
118
+ protected $_errors = array();
119
+
120
+ protected $_optionInstance;
121
+
122
+ protected $_options = array();
123
+
124
+ /**
125
+ * Product reserved attribute codes
126
+ */
127
+ protected $_reservedAttributes;
128
+
129
+ /**
130
+ * Flag for available duplicate function
131
+ *
132
+ * @var boolean
133
+ */
134
+ protected $_isDuplicable = true;
135
+
136
+
137
+
138
+ /**
139
+ * Initialize resources
140
+ */
141
+
142
+ /**
143
+ * Get product name
144
+ *
145
+ * @return string
146
+ */
147
+ /*
148
+ public function getName()
149
+ {
150
+ return $this->_getData('name');
151
+ //return parent::getName();
152
+ //return 'overriden name!!!';
153
+ }
154
+ */
155
+ /**
156
+ * Get collection instance
157
+ *
158
+ * @return object
159
+ */
160
+
161
+
162
+
163
+ }
164
+ ?>
app/code/local/Bintime/Icecatimport/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
+ * @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 ADDED
@@ -0,0 +1,45 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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 ADDED
@@ -0,0 +1,317 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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
+ protected function _construct()
24
+ {
25
+ $this->_init('icecatimport/import');
26
+ }
27
+
28
+ /**
29
+ * Perform Curl request with corresponding param check and error processing
30
+ * @param int $productId
31
+ * @param string $vendorName
32
+ * @param string $locale
33
+ * @param string $userName
34
+ * @param string $userPass
35
+ */
36
+ public function getProductDescription($productId, $vendorName, $locale, $userName, $userPass, $entityId){
37
+
38
+ $this->entityId = $entityId;
39
+ if (null === $this->simpleDoc) {
40
+ if (!$cacheDataXml = Mage::app()->getCache()->load($this->_cacheKey . $entityId)) {
41
+ $dataUrl = 'http://data.icecat.biz/xml_s3/xml_server3.cgi';
42
+ if (empty($productId)) {
43
+ $this->errorMessage = 'Given product has no MPN (SKU)';
44
+ return false;
45
+ }
46
+ if (empty($vendorName)){
47
+ $this->errorMessage = "Given product has no manufacturer specified.";
48
+ return false;
49
+ }
50
+ if (empty($locale)) {
51
+ $this->errorMessage = "Please specify product description locale";
52
+ return false;
53
+ }
54
+ if ( empty($userName)) {
55
+ $this->errorMessage = "No ICEcat login provided";
56
+ return false;
57
+ }
58
+ if (empty($userPass)){
59
+ $this->errorMessage = "No ICEcat password provided";
60
+ return false;
61
+ }
62
+
63
+ $getParamsArray = array("prod_id" => $productId,
64
+ "lang" =>$locale,
65
+ "vendor" => $vendorName,
66
+ "output" =>'productxml'
67
+ );
68
+ Varien_Profiler::start('Bintime FILE DOWNLOAD:');
69
+ try{
70
+ $webClient = new Zend_Http_Client();
71
+ $webClient->setUri($dataUrl);
72
+ $webClient->setMethod(Zend_Http_Client::GET);
73
+ $webClient->setHeaders('Content-Type: text/xml; charset=UTF-8');
74
+ $webClient->setParameterGet($getParamsArray);
75
+ $webClient->setAuth($userName, $userPass, Zend_Http_CLient::AUTH_BASIC);
76
+ $response = $webClient->request();
77
+ if ($response->isError()){
78
+ $this->errorMessage = 'Response Status: '.$response->getStatus()." Response Message: ".$response->getMessage();
79
+ return false;
80
+ }
81
+ }
82
+ catch (Exception $e) {
83
+ $this->errorMessage = "Warning: cannot connect to ICEcat. {$e->getMessage()}";
84
+ return false;
85
+ }
86
+ Varien_Profiler::stop('Bintime FILE DOWNLOAD:');
87
+ $resultString = $response->getBody();
88
+ Mage::app()->getCache()->save($resultString, $this->_cacheKey . $entityId);
89
+ } else {
90
+ $resultString = $cacheDataXml;
91
+ }
92
+ if(!$this->parseXml($resultString)){
93
+ return false;
94
+ }
95
+
96
+ if ($this->checkIcecatResponse($productId, $vendorName)){
97
+ // $_newProduct = Mage::getModel('catalog/product')->load($productId);
98
+ //echo $_newProduct->getDescription();die;
99
+ //$this->productDescription = $_newProduct->getDescription();
100
+ return false;
101
+ }
102
+ //$_newProduct = Mage::getModel('catalog/product')->load($productId);
103
+ //$_newProduct->getDescription();die();
104
+
105
+ $this->loadProductDescriptionList();
106
+ $this->loadOtherProductParams($productId);
107
+ $this->loadGalleryPhotos();
108
+ Varien_Profiler::start('Bintime FILE RELATED');
109
+ $this->loadRelatedProducts();
110
+ Varien_Profiler::stop('Bintime FILE RELATED');
111
+ }
112
+ return true;
113
+ }
114
+
115
+ public function getSystemError(){
116
+ return $this->errorSystemMessage;
117
+ }
118
+
119
+ public function getProductName(){
120
+ return $this->productName;
121
+ }
122
+
123
+ public function getGalleryPhotos(){
124
+ return $this->galleryPhotos;
125
+ }
126
+
127
+ public function getThumbPicture(){
128
+ return $this->thumb;
129
+ }
130
+
131
+ /**
132
+ * load Gallery array from XML
133
+ */
134
+ private function loadGalleryPhotos(){
135
+ $galleryPhotos = $this->simpleDoc->Product->ProductGallery->ProductPicture;
136
+ if (!count($galleryPhotos)){
137
+ return false;
138
+ }
139
+ foreach($galleryPhotos as $photo){
140
+ if($photo["Size"] > 0){//if
141
+ $picHeight = (int)$photo["PicHeight"];
142
+ $picWidth = (int)$photo["PicWidth"];
143
+ $thumbUrl = (string)$photo["ThumbPic"];
144
+ $picUrl = (string)$photo["Pic"];
145
+
146
+ array_push($this->galleryPhotos, array(
147
+ 'height' => $picHeight,
148
+ 'width' => $picWidth,
149
+ 'thumb' => $thumbUrl,
150
+ 'pic' => $picUrl
151
+ ));
152
+ }//endif
153
+ }
154
+ }
155
+
156
+ public function getErrorMessage(){
157
+ return $this->errorMessage;
158
+ }
159
+
160
+ /**
161
+ * Checks response XML for error messages
162
+ * @param int $productId
163
+ * @param string $vendorName
164
+ */
165
+ private function checkIcecatResponse(){
166
+ $errorMessage = $this->simpleDoc->Product['ErrorMessage'];
167
+ if ($errorMessage != ''){
168
+ if (preg_match('/^No xml data/', $errorMessage)){
169
+ $this->errorSystemMessage = $errorMessage;
170
+ return true;
171
+ }
172
+ if (preg_match('/^The specified vendor does not exist$/', $errorMessage)) {
173
+ $this->errorSystemMessage = $errorMessage;
174
+ return true;
175
+ }
176
+ $this->errorMessage = "Ice Cat Error: ".$errorMessage;
177
+ return true;
178
+ }
179
+ return false;
180
+ }
181
+
182
+ public function getProductDescriptionList(){
183
+ return $this->productDescriptionList;
184
+ }
185
+
186
+
187
+ public function getShortProductDescription(){
188
+ return $this->productDescription;
189
+ }
190
+
191
+ public function getFullProductDescription(){
192
+ return $this->fullProductDescription;
193
+ }
194
+
195
+ public function getLowPicUrl(){
196
+ return $this->highPicUrl;
197
+ }
198
+
199
+ public function getRelatedProducts(){
200
+ return $this->relatedProducts;
201
+ }
202
+
203
+ public function getVendor(){
204
+ return $this->vendor;
205
+ }
206
+
207
+ public function getMPN(){
208
+ return $this->productId;
209
+ }
210
+
211
+ public function getEAN(){
212
+ return $this->EAN;
213
+ }
214
+
215
+ /**
216
+ * Form related products Array
217
+ */
218
+ private function loadRelatedProducts(){
219
+ $relatedProductsArray = $this->simpleDoc->Product->ProductRelated;
220
+ if(count($relatedProductsArray)){
221
+ foreach($relatedProductsArray as $product){
222
+ $productArray = array();
223
+ $productNS = $product->Product;
224
+ $productArray['name'] = (string)$productNS['Name'];
225
+ $productArray['thumb'] = (string)$productNS['ThumbPic'];
226
+ $mpn = (string)$productNS['Prod_id'];
227
+ $productSupplier = $productNS->Supplier;
228
+ $productSupplierId = (int)$productSupplier['ID'];
229
+ $productArray['supplier_thumb'] = 'http://images2.icecat.biz/thumbs/SUP'.$productSupplierId.'.jpg';
230
+ $productArray['supplier_name'] = (string)$productSupplier['Name'];
231
+ $this->relatedProducts[$mpn] = $productArray;
232
+ }
233
+ }
234
+ }
235
+
236
+ /**
237
+ * Form product feature Arrray
238
+ */
239
+ private function loadProductDescriptionList(){
240
+ $descriptionArray = array();
241
+
242
+ $specGroups = $this->simpleDoc->Product->CategoryFeatureGroup;
243
+ $specFeatures = $this->simpleDoc->Product->ProductFeature;
244
+ foreach($specFeatures as $feature){
245
+ $id = (int)$feature['CategoryFeatureGroup_ID'];
246
+ $featureText = (string)$feature["Presentation_Value"];
247
+ $featureName = (string)$feature->Feature->Name["Value"];
248
+ foreach($specGroups as $group){
249
+ $groupId = (int)$group["ID"];
250
+ if ($groupId == $id){
251
+ $groupName = (string) $group->FeatureGroup->Name["Value"];
252
+ $rating = (int)$group['No'];
253
+ $descriptionArray[$rating][$groupName][$featureName] = $featureText;
254
+ break;
255
+ }
256
+ }
257
+ }
258
+ krsort($descriptionArray);
259
+ $this->productDescriptionList = $descriptionArray;
260
+ }
261
+
262
+ /**
263
+ * Form Array of non feature-value product params
264
+ */
265
+ private function loadOtherProductParams($productId){
266
+ $this->productDescription = (string) $this->simpleDoc->Product->ProductDescription['ShortDesc'];
267
+
268
+
269
+ $this->fullProductDescription = (string)$this->simpleDoc->Product->ProductDescription['LongDesc'];
270
+ $productTag = $this->simpleDoc->Product;
271
+ $this->lowPicUrl = (string)$productTag["LowPic"];
272
+ $this->highPicUrl = (string)$productTag["HighPic"];
273
+ $this->productName = (string)$productTag["Name"];
274
+ $this->productId = (string)$productTag['Prod_id'];
275
+ $this->thumb = (string)$productTag['ThumbPic'];
276
+ $this->vendor = (string)$productTag->Supplier['Name'];
277
+ $prodEAN = $productTag->EANCode;
278
+ $EANstr='';
279
+ $EANarr=null;
280
+ $j = 0;//counter
281
+ foreach($prodEAN as $ellEAN){
282
+ $EANarr[]=$ellEAN['EAN'];$j++;
283
+ }
284
+ //echo $j;
285
+ $i = 0;
286
+ $str = '';
287
+ for($i=0;$i<$j;$i++){
288
+ $g = $i%2;
289
+ //echo '<br>'.$g;
290
+ //$EANstr=implode(",",$EANarr);
291
+ if($g == '0'){if($j == 1){$str .= $EANarr[$i].'<br>';} else {$str .= $EANarr[$i].', ';}
292
+ }
293
+ else {if($i != $j-1){$str .= $EANarr[$i].', <br>';}else {$str .= $EANarr[$i].' <br>';}}
294
+ //var_dump($EANstr);die;
295
+ }
296
+ $this->EAN = $str;
297
+ //$this->EAN = (string)$EANstr;//$productTag->EANCode['EAN'];
298
+ }
299
+
300
+ /**
301
+ * parse response XML: to SimpleXml
302
+ * @param string $stringXml
303
+ */
304
+ private function parseXml($stringXml){
305
+ libxml_use_internal_errors(true);
306
+ $this->simpleDoc = simplexml_load_string($stringXml);
307
+ if ($this->simpleDoc){
308
+ return true;
309
+ }
310
+ $this->simpleDoc = simplexml_load_string(utf8_encode($stringXml));
311
+ if ($this->simpleDoc){
312
+ return true;
313
+ }
314
+ return false;
315
+ }
316
+ }
317
+ ?>
app/code/local/Bintime/Icecatimport/Model/Observer.php ADDED
@@ -0,0 +1,319 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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
+ private $errorMessage;
11
+ private $connection;
12
+
13
+ private $freeExportURLs = 'http://data.icecat.biz/export/freeurls/export_urls_rich.txt.gz';
14
+ private $fullExportURLs = 'http://data.icecat.biz/export/export_urls_rich.txt.gz';
15
+ protected $_supplierMappingUrl = 'http://data.icecat.biz/export/freeurls/supplier_mapping.xml';
16
+ protected $_connectorDir = '/bintime/icecatimport/';
17
+ protected $_productFile;
18
+ protected $_supplierFile;
19
+
20
+ protected function _construct()
21
+ {
22
+ $this->_init('icecatimport/observer');
23
+ }
24
+
25
+ /**
26
+ * root method for uploading images to DB
27
+ */
28
+ public function load(){
29
+
30
+ $loadUrl = $this->getLoadURL();
31
+ ini_set('max_execution_time', 0);
32
+
33
+ try {
34
+ $this->_productFile = $this->_prepareFile(basename($loadUrl));
35
+ $this->_supplierFile = $this->_prepareFile(basename($this->_supplierMappingUrl));
36
+ echo "Data file downloading started <br>";
37
+ $this->downloadFile($this->_productFile, $loadUrl);
38
+
39
+ echo "Start of supplier mapping file download<br>";
40
+ $this->downloadFile($this->_supplierFile, $this->_supplierMappingUrl);
41
+ $this->XMLfile = Mage::getBaseDir('var') . $this->_connectorDir . basename($loadUrl, ".gz");
42
+
43
+ echo "Start Unzipping Data File<br>";
44
+ $this->unzipFile();
45
+ echo "Start File Processing<br>";
46
+
47
+ $this->_loadSupplierListToDb();
48
+ $this->loadFileToDb();
49
+
50
+ echo "File Processed Succesfully<br>";
51
+ } catch( Exception $e) {
52
+ echo $e->getMessage();
53
+ Mage::log($e->getMessage());
54
+ }
55
+ }
56
+
57
+ /**
58
+ * parse given XML to SIMPLE XML
59
+ * @param string $stringXml
60
+ */
61
+ protected function _parseXml($stringXml){
62
+ libxml_use_internal_errors(true);
63
+ $simpleDoc = simplexml_load_string($stringXml);
64
+ if ($simpleDoc){
65
+ return $simpleDoc;
66
+ }
67
+ $simpleDoc = simplexml_load_string(utf8_encode($stringXml));
68
+ if ($simpleDoc){
69
+ return $simpleDoc;
70
+ }
71
+ return false;
72
+ }
73
+
74
+ /**
75
+ * Upload supplier mapping list to Database
76
+ */
77
+ protected function _loadSupplierListToDb()
78
+ {
79
+ $connection = $this->getDbConnection();
80
+ $mappingTable = Mage::getSingleton('core/resource')->getTableName('icecatimport/supplier_mapping');
81
+ try {
82
+ $connection->beginTransaction();
83
+ $xmlString = file_get_contents($this->_supplierFile);
84
+ $xmlDoc = $this->_parseXml($xmlString);
85
+ if ($xmlDoc) {
86
+ $connection->query("DROP TABLE IF EXISTS `".$mappingTable."_temp`");
87
+ $connection->query("
88
+ CREATE TABLE `".$mappingTable."_temp` (
89
+ `supplier_id` int(11) NOT NULL,
90
+ `supplier_symbol` varchar(255) DEFAULT NULL,
91
+ KEY `supplier_id` (`supplier_id`)
92
+ ) ENGINE=InnoDB DEFAULT CHARSET=utf8
93
+ ");
94
+
95
+ $supplierList = $xmlDoc->SupplierMappings->SupplierMapping;
96
+ foreach ($supplierList as $supplier) {
97
+ $supplierSymbolList = $supplier->Symbol;
98
+ $supplierId = $supplier['supplier_id'];
99
+ foreach($supplierSymbolList as $symbol) {
100
+ $symbolName = (string)$symbol;
101
+ $connection->insert($mappingTable."_temp", array('supplier_id' => $supplierId, 'supplier_symbol' => $symbolName));
102
+ }
103
+ }
104
+
105
+ $connection->query("DROP TABLE IF EXISTS `".$mappingTable."_old`");
106
+ $connection->query("rename table `".$mappingTable."` to `".$mappingTable."_old`, `".$mappingTable."_temp` to ".$mappingTable);
107
+
108
+ $connection->commit();
109
+ } else {
110
+ throw new Exception('Unable to process supplier file');
111
+ }
112
+ } catch (Exception $e) {
113
+ $connection->rollBack();
114
+ throw new Exception("Icecat Import Terminated: {$e->getMessage()}");
115
+ }
116
+ }
117
+ /**
118
+ * retrieve URL of data file that corresponds ICEcat account
119
+ */
120
+ private function getLoadURL(){
121
+ $subscripionLevel = Mage::getStoreConfig('icecat_root/icecat/icecat_type');
122
+
123
+ if ($subscripionLevel === 'full'){
124
+ return $this->fullExportURLs;
125
+ }
126
+ else {
127
+ return $this->freeExportURLs;
128
+ }
129
+ }
130
+
131
+ /**
132
+ * return error messages
133
+ */
134
+ public function getErrorMessage(){
135
+ return $this->errorMessage;
136
+ }
137
+
138
+ /**
139
+ * getImage URL from DB
140
+ * @param string $productSku
141
+ * @param string $productManufacturer
142
+ */
143
+ public function getImageURL($productSku, $productManufacturer){
144
+
145
+ $connection = $this->getDbConnection();
146
+ try {
147
+
148
+ $tableName = Mage::getSingleton('core/resource')->getTableName('icecatimport/data');
149
+ $mappingTable = Mage::getSingleton('core/resource')->getTableName('icecatimport/supplier_mapping');
150
+
151
+ $selectCondition = $connection->select()
152
+ ->from(array('connector' => $tableName), new Zend_Db_Expr('connector.prod_img'))
153
+ ->joinInner(array('supplier' => $mappingTable), "connector.supplier_id = supplier.supplier_id AND supplier.supplier_symbol = {$this->connection->quote($productManufacturer)}")
154
+ ->where('connector.prod_id = ? ', $productSku);
155
+
156
+ $imageURL = $connection->fetchOne($selectCondition);
157
+ if (empty($imageURL)){
158
+ $this->errorMessage = "Given product id is not present in database";
159
+ return false;
160
+ }
161
+ return $imageURL;
162
+ } catch (Exception $e) {
163
+ $this->errorMessage = "DB ERROR: {$e->getMessage()}";
164
+ return false;
165
+ }
166
+ }
167
+
168
+ /**
169
+ * Singletong for DB connection
170
+ */
171
+ private function getDbConnection(){
172
+ if ($this->connection){
173
+ return $this->connection;
174
+ }
175
+ $this->connection = Mage::getSingleton('core/resource')->getConnection('core_read');
176
+ return $this->connection;
177
+ }
178
+
179
+ /**
180
+ * Upload Data file to DP
181
+ */
182
+ private function loadFileToDb(){
183
+ $connection = $this->getDbConnection();
184
+
185
+ $tableName = Mage::getSingleton('core/resource')->getTableName('icecatimport/data');
186
+ try {
187
+ $connection->beginTransaction();
188
+ $fileHandler = fopen($this->XMLfile, "r");
189
+ if ($fileHandler) {
190
+ $connection->query("DROP TABLE IF EXISTS `".$tableName."_temp`");
191
+ $connection->query("
192
+ CREATE TABLE `".$tableName."_temp` (
193
+ `prod_id` varchar(255) NOT NULL,
194
+ `supplier_id` int(11) DEFAULT NULL,
195
+ `prod_name` varchar(255) DEFAULT NULL,
196
+ `prod_img` varchar(255) DEFAULT NULL,
197
+ KEY `PRODUCT_MPN` (`prod_id`),
198
+ KEY `supplier_id` (`supplier_id`)
199
+ ) ENGINE=InnoDB DEFAULT CHARSET=utf8
200
+ ");
201
+ $csvFile = Mage::getBaseDir('var') . $this->_connectorDir . 'ice_cat_temp.csv';
202
+ $csvFileRes = fopen($csvFile, "w+");
203
+
204
+ while (!feof($fileHandler)) {
205
+ $row = fgets($fileHandler);
206
+ $oneLine = explode("\t", $row);
207
+ if ($oneLine[0]!= 'product_id' && $oneLine[0]!= ''){
208
+ try{
209
+ // $connection->insert($tableName."_temp", array('prod_id' => $oneLine[1], 'prod_img' => $oneLine[6], 'prod_name' => $oneLine[12], 'supplier_id' => $oneLine[13]));
210
+
211
+ $prod_id = (!empty($oneLine[1])) ? $oneLine[1] : '';
212
+ $prod_img = (!empty($oneLine[6])) ? $oneLine[6] : '';
213
+ $prod_name = (!empty($oneLine[12])) ? $oneLine[12] : '';
214
+ $supplier_id = (!empty($oneLine[4])) ? $oneLine[4] : '';
215
+
216
+ $line = "$prod_id\t$supplier_id\t$prod_name\t$prod_img\n";
217
+
218
+ fwrite($csvFileRes, $line);
219
+
220
+ }catch(Exception $e){
221
+ Mage::log("connector issue: {$e->getMessage()}");
222
+ }
223
+ }
224
+ }
225
+
226
+ // write csv file into temp table
227
+ $connection->query('LOAD DATA LOCAL INFILE "'.$csvFile.'" INTO TABLE '.$tableName.'_temp ( prod_id, supplier_id, prod_name, prod_img )');
228
+ $connection->query("DROP TABLE IF EXISTS `".$tableName."_old`");
229
+ $connection->query("rename table `".$tableName."` to `".$tableName."_old`, `".$tableName."_temp` to ".$tableName);
230
+
231
+ $connection->commit();
232
+
233
+ fclose($fileHandler);
234
+ unlink($csvFile);
235
+ }
236
+ } catch (Exception $e) {
237
+ $connection->rollBack();
238
+ throw new Exception("Icecat Import Terminated: {$e->getMessage()}");
239
+ }
240
+ }
241
+
242
+ /**
243
+ * unzip Uploaded file
244
+ */
245
+ private function unzipFile(){
246
+ $gz = gzopen ( $this->_productFile, 'rb' );
247
+
248
+ if (file_exists($this->XMLfile)){
249
+ unlink($this->XMLfile);
250
+ }
251
+
252
+ $fileToWrite = @fopen($this->XMLfile, 'w+');
253
+
254
+ if (!$fileToWrite){
255
+ $this->errorMessage = 'Unable to open output txt file. Please remove all *.txt files from '.
256
+ Mage::getBaseDir('var'). $this->_connectorDir .'folder';
257
+ return false;
258
+ }
259
+ while (!gzeof($gz)) {
260
+ $buffer = gzgets($gz, 100000);
261
+ fputs($fileToWrite, $buffer) ;
262
+ }
263
+ gzclose ($gz);
264
+ fclose($fileToWrite);
265
+ }
266
+
267
+ /**
268
+ * Process downloading files
269
+ * @param string $destinationFile
270
+ * @param string $loadUrl
271
+ */
272
+ private function downloadFile($destinationFile, $loadUrl){
273
+ $userName = Mage::getStoreConfig('icecat_root/icecat/login');
274
+ $userPass = Mage::getStoreConfig('icecat_root/icecat/password');
275
+ $fileToWrite = @fopen($destinationFile, 'w+');
276
+
277
+ try{
278
+
279
+ $webClient = new Zend_Http_Client();
280
+ $webClient->setUri($loadUrl);
281
+ $webClient->setConfig(array('maxredirects' => 0, 'timeout' => 60));
282
+ $webClient->setMethod(Zend_Http_Client::GET);
283
+ $webClient->setHeaders('Content-Type: text/xml; charset=UTF-8');
284
+ $webClient->setAuth($userName, $userPass, Zend_Http_CLient::AUTH_BASIC);
285
+ $response = $webClient->request('GET');
286
+
287
+ if ($response->isError()){
288
+ throw new Exception('<br>ERROR Occured.<br>Response Status: '.$response->getStatus()."<br>Response Message: ".$response->getMessage());
289
+ }
290
+
291
+ }
292
+ catch (Exception $e) {
293
+ throw new Exception("Warning: cannot connect to ICEcat. {$e->getMessage()}");
294
+ }
295
+
296
+ $resultString = $response->getBody();
297
+ fwrite($fileToWrite, $resultString);
298
+ fclose($fileToWrite);
299
+ }
300
+
301
+ /**
302
+ * Prepares file and folder for futur download
303
+ * @param string $fileName
304
+ */
305
+ protected function _prepareFile($fileName){
306
+ $varDir = Mage::getBaseDir('var') . $this->_connectorDir;
307
+ $filePath = $varDir . $fileName;
308
+ if (!is_dir($varDir)){
309
+ mkdir($varDir, 0777, true);
310
+ }
311
+
312
+ if (file_exists($filePath)){
313
+ unlink($filePath);
314
+ }
315
+
316
+ return $filePath;
317
+ }
318
+ }
319
+ ?>
app/code/local/Bintime/Icecatimport/Model/Relatedcollection.php ADDED
@@ -0,0 +1,71 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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 ADDED
@@ -0,0 +1,21 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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/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/Bintime/Icecatimport/Model/System/Config/Locales.php ADDED
@@ -0,0 +1,45 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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/Subscription.php ADDED
@@ -0,0 +1,18 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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 ADDED
@@ -0,0 +1,16 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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 ADDED
@@ -0,0 +1,147 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?xml version="1.0"?>
2
+ <config>
3
+ <modules>
4
+ <Bintime_Icecatimport>
5
+ <version>0.1.1</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
+ <catalog>
22
+ <rewrite>
23
+ <product_view_attributes>Bintime_Icecatimport_Block_Attributes</product_view_attributes>
24
+ <product_view_media>Bintime_Icecatimport_Block_Media</product_view_media>
25
+ <product_list_related>Bintime_Icecatimport_Block_Related</product_list_related>
26
+ <product_list_upsell>Bintime_Icecatimport_Block_Upsell</product_list_upsell>
27
+ </rewrite>
28
+ </catalog>
29
+
30
+ </blocks>
31
+ <models>
32
+ <icecatimport>
33
+ <class>Bintime_Icecatimport_Model</class>
34
+ <resourceModel>icecatimport_resource_eav_mysql4</resourceModel>
35
+ </icecatimport>
36
+ <icecatimport_resource_eav_mysql4>
37
+ <entities>
38
+ <data><table>bintime_connector_data</table></data>
39
+ <supplier_mapping><table>bintime_supplier_mapping</table></supplier_mapping>
40
+ </entities>
41
+ </icecatimport_resource_eav_mysql4>
42
+ <catalog>
43
+ <rewrite>
44
+ <product>Bintime_Icecatimport_Model_Catalog_Product</product>
45
+ <category>Bintime_Icecatimport_Model_Catalog_Category</category>
46
+ </rewrite>
47
+ </catalog>
48
+ <catalogsearch_mysql4>
49
+ <rewrite>
50
+ <fulltext_collection>Bintime_Icecatimport_Model_Catalog_Search</fulltext_collection>
51
+ </rewrite>
52
+ </catalogsearch_mysql4>
53
+ </models>
54
+ <!--
55
+ <routers>
56
+ <catalog>
57
+ <rewrite>
58
+ <product>
59
+ <to>Bintime_Icecatimport/product</to>
60
+ <override_actions>false</override_actions>
61
+ <actions>
62
+ <view><to>Bintime_Icecatimport/product/view</to></view>
63
+ </actions>
64
+ </product>
65
+ </rewrite>
66
+ </catalog>
67
+ </routers>
68
+ -->
69
+ <resources>
70
+ <icecatimport_setup>
71
+ <setup>
72
+ <module>Bintime_Icecatimport</module>
73
+ </setup>
74
+ <connection>
75
+ <use>core_setup</use>
76
+ </connection>
77
+ </icecatimport_setup>
78
+ </resources>
79
+ </global>
80
+ <frontend>
81
+ <routers>
82
+ <icecatimport>
83
+ <use>standard</use>
84
+ <args>
85
+ <module>Bintime_Icecatimport</module>
86
+ <frontName>icecatimport</frontName>
87
+ </args>
88
+ </icecatimport>
89
+ </routers>
90
+ <layout>
91
+ <updates>
92
+ <icecatimport>
93
+ <file>icecatimport.xml</file>
94
+ </icecatimport>
95
+ </updates>
96
+ </layout>
97
+ <translate>
98
+ <modules>
99
+ <icecatimport>
100
+ <files>
101
+ <default>Bintime_Icecatimport.csv</default>
102
+ </files>
103
+ </icecatimport>
104
+ </modules>
105
+ </translate>
106
+ </frontend>
107
+ <adminhtml>
108
+ <acl>
109
+ <resources>
110
+ <admin>
111
+ <children>
112
+ <system>
113
+ <children>
114
+ <config>
115
+ <children>
116
+ <icecat_root translate="title" module="customer">
117
+ <title>Ice Cat Module powered by Bintime company</title>
118
+ <sort_order>200</sort_order>
119
+ </icecat_root>
120
+ </children>
121
+ </config>
122
+ </children>
123
+ </system>
124
+ </children>
125
+ </admin>
126
+ </resources>
127
+ </acl>
128
+ <events></events>
129
+ <translate>
130
+ <modules>
131
+ <mage_adminhtml>
132
+ <files>
133
+ <icecatimport>Bintime_Icecatimport.csv</icecatimport>
134
+ </files>
135
+ </mage_adminhtml>
136
+ </modules>
137
+ </translate>
138
+ </adminhtml>
139
+ <crontab>
140
+ <jobs>
141
+ <icecatimport>
142
+ <schedule><cron_expr>0 3 * * *</cron_expr></schedule>
143
+ <run><model>icecatimport/observer::load</model></run>
144
+ </icecatimport>
145
+ </jobs>
146
+ </crontab>
147
+ </config>
app/code/local/Bintime/Icecatimport/etc/system.xml ADDED
@@ -0,0 +1,79 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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
+ </fields>
75
+ </icecat>
76
+ </groups>
77
+ </icecat_root>
78
+ </sections>
79
+ </config>
app/code/local/Bintime/Icecatimport/sql/icecatimport_setup/mysql4-install-0.1.0.php ADDED
@@ -0,0 +1,23 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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
+ $installer->endSetup();
app/code/local/Bintime/Icecatimport/sql/icecatimport_setup/mysql4-upgrade-0.1.0-0.1.1.php ADDED
@@ -0,0 +1,12 @@
 
 
 
 
 
 
 
 
 
 
 
 
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/etc/modules/Bintime_Icecatimport.xml ADDED
@@ -0,0 +1,9 @@
 
 
 
 
 
 
 
 
 
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>
package.xml ADDED
@@ -0,0 +1,20 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?xml version="1.0"?>
2
+ <package>
3
+ <name>IcecatLive</name>
4
+ <version>1.0.0</version>
5
+ <stability>stable</stability>
6
+ <license uri="http://opensource.org/licenses/osl-3.0.php">OSL v.3</license>
7
+ <channel>community</channel>
8
+ <extends/>
9
+ <summary>ICEcat to Magento Open Source Connector</summary>
10
+ <description>ICEcat to Magento Open Source Connector - rich content in your magento shop</description>
11
+ <notes>- Optimized synchronize.&#xD;
12
+ - Fixed product listing.&#xD;
13
+ - Fixed caching already downloaded products info.</notes>
14
+ <authors><author><name>IceShop</name><user>IceShop</user><email>support@iceshop.nl</email></author></authors>
15
+ <date>2012-06-11</date>
16
+ <time>08:38:15</time>
17
+ <contents><target name="magelocal"><dir name="Bintime"><dir name="Icecatimport"><dir name="Block"><file name="Attributes.php" hash="ae93e0a964e8880e5b65fb5d08f1edf9"/><file name="Media.php" hash="a71e447a139b851da50937bccaf8bd37"/><file name="Related.php" hash="7ca2ad6520f2644ad1302c02d1cd6853"/><file name="Upsell.php" hash="624bd7b9c8708a67079efb2478a5a37d"/></dir><dir name="controllers"><file name="ImageController.php" hash="cdf4984c268346088729831b7abdf026"/></dir><dir name="etc"><file name="config.xml" hash="e7d5d2932a1320e107d5ac7af35ba29f"/><file name="system.xml" hash="5138720902ed8c530d7c91b82d0f4935"/></dir><dir name="Helper"><dir name="Catalog"><file name="Image.php" hash="7d563f9ffce9eb286839c3add7fd6c9f"/></dir><file name="Getdata.php" hash="b36ed387b06e2d2aa9860f693dda3f03"/><file name="Image.php" hash="aaaaaf9794622f80269fef4b5fc19476"/><file name="Output.php" hash="833218b04e3e7a5ef912802273515abb"/></dir><dir name="Model"><dir name="Catalog"><file name="Category.php" hash="21abeb7a7c2c85db8ce4d2f4ed203f50"/><file name="Product.php" hash="232f34dade19ddcf09d2da92e15cb682"/><file name="Search.php" hash="99c7eb706e67e01ea8167ebe88fe72d9"/></dir><dir name="System"><dir name="Config"><file name="Attributes.php" hash="23284e0d38677b4544fc87642a6bc8b5"/><file name="LanguageList.xml" hash="391ef56fab212879709780df5a7710e7"/><file name="Locales.php" hash="b8c699fa2a6f657b6d52d86e656872cc"/><file name="Subscription.php" hash="62168986f7a4eb3f10d38ac627aa6510"/></dir></dir><file name="Imagescollection.php" hash="718b575ef9472f85c323fa40f80bbd05"/><file name="Import.php" hash="e6cb92d1c5feda8a584490e188128a70"/><file name="Observer.php" hash="91a7409a4c11e4109665b5aab3f261f9"/><file name="Relatedcollection.php" hash="2ddf62c43a66c3fd70bf651d0078dbc1"/></dir><dir name="sql"><dir name="icecatimport_setup"><file name="mysql4-install-0.1.0.php" hash="a8f750e7667f8ef0dd077100c9fddf48"/><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>
18
+ <compatible/>
19
+ <dependencies><required><php><min>5.2.0</min><max>6.0.0</max></php></required></dependencies>
20
+ </package>