Lengow_Export - Version 2.1.2

Version Notes

New version of Lengow's Connector

Download this release

Release Info

Developer Ludovic
Extension Lengow_Export
Version 2.1.2
Comparing to
See all releases


Code changes from version 2.1.1 to 2.1.2

Files changed (30) hide show
  1. app/code/community/Lengow/Dashboard/etc/config.xml +1 -1
  2. app/code/community/Lengow/Export/Helper/Data.php +34 -13
  3. app/code/community/Lengow/Export/Model/Catalog/Product.php +19 -6
  4. app/code/community/Lengow/Export/Model/Feed/Xml.php +1 -1
  5. app/code/community/Lengow/Export/Model/Feed/Yaml.php +1 -1
  6. app/code/community/Lengow/Export/Model/Generate.php +86 -15
  7. app/code/community/Lengow/Export/Model/Generateoptimize.php +1436 -0
  8. app/code/community/Lengow/Export/Model/Observer.php +79 -11
  9. app/code/community/Lengow/Export/Model/Product/Collection.php +25 -0
  10. app/code/community/Lengow/Export/Model/Resource/Catalog/Product.php +8 -0
  11. app/code/community/Lengow/Export/controllers/Adminhtml/Lengow/ExportController.php +13 -4
  12. app/code/community/Lengow/Export/controllers/FeedController.php +38 -6
  13. app/code/community/Lengow/Export/etc/config.xml +17 -4
  14. app/code/community/Lengow/Export/etc/system.xml +19 -9
  15. app/code/community/Lengow/Feed/controllers/Adminhtml/Lengow/FeedController.php +13 -5
  16. app/code/community/Lengow/Feed/etc/config.xml +3 -3
  17. app/code/community/Lengow/Sync/Model/Import.php +1 -1
  18. app/code/community/Lengow/Sync/Model/Observer.php +3 -4
  19. app/code/community/Lengow/Sync/Model/Quote.php +7 -5
  20. app/code/community/Lengow/Sync/Model/Quote/Exception.php +0 -54
  21. app/code/community/Lengow/Sync/Model/Quote/Item.php +12 -103
  22. app/code/community/Lengow/Sync/controllers/Adminhtml/Lengow/LogController.php +13 -4
  23. app/code/community/Lengow/Sync/controllers/Adminhtml/Lengow/OrderController.php +8 -3
  24. app/code/community/Lengow/Sync/etc/config.xml +3 -3
  25. app/code/community/Lengow/Sync/etc/marketplaces.xml +13 -7
  26. app/code/community/Lengow/Sync/etc/system.xml +3 -4
  27. app/code/community/Lengow/Tracker/etc/config.xml +1 -1
  28. app/code/community/Lengow/Tracker/etc/system.xml +2 -1
  29. app/locale/fr_FR/Lengow_Connector.csv +14 -9
  30. package.xml +4 -4
app/code/community/Lengow/Dashboard/etc/config.xml CHANGED
@@ -2,7 +2,7 @@
2
  <config>
3
  <modules>
4
  <Lengow_Dashboard>
5
- <version>2.1.1</version>
6
  </Lengow_Dashboard>
7
  </modules>
8
  <admin>
2
  <config>
3
  <modules>
4
  <Lengow_Dashboard>
5
+ <version>2.1.2</version>
6
  </Lengow_Dashboard>
7
  </modules>
8
  <admin>
app/code/community/Lengow/Export/Helper/Data.php CHANGED
@@ -76,19 +76,40 @@ class Lengow_Export_Helper_Data extends Mage_Core_Helper_Abstract {
76
  }
77
  $value = preg_replace('/[\s]+/', ' ', $value); //nettoyage des espaces multiples
78
  $value = trim($value);
79
- $value = str_replace('&nbsp;', ' ', $value);
80
- $value = str_replace('|', ' ', $value);
81
- $value = str_replace('"', '\'', $value);
82
- $value = str_replace('', '\'', $value);
83
- $value = str_replace('&#39;', ' ', $value);
84
- $value = str_replace('&#150;', '-', $value);
85
- $value = str_replace(chr(9), ' ', $value);
86
- $value = str_replace(chr(10), ' ', $value);
87
- $value = str_replace(chr(13), ' ', $value);
88
- $value = str_replace(chr(31), '', $value);
89
- $value = str_replace(chr(30), '', $value);
90
- $value = str_replace(chr(29), '', $value);
91
- $value = str_replace(chr(28), '', $value);
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
92
  return $value;
93
  }
94
 
76
  }
77
  $value = preg_replace('/[\s]+/', ' ', $value); //nettoyage des espaces multiples
78
  $value = trim($value);
79
+ $value = str_replace(
80
+ array(
81
+ '&nbsp;',
82
+ '|',
83
+ '"',
84
+ '',
85
+ '&#39;',
86
+ '&#150;',
87
+ chr(9),
88
+ chr(10),
89
+ chr(13),
90
+ chr(31),
91
+ chr(30),
92
+ chr(29),
93
+ chr(28),
94
+ "\n",
95
+ "\r"
96
+ ), array(
97
+ ' ',
98
+ ' ',
99
+ '\'',
100
+ '\'',
101
+ ' ',
102
+ '-',
103
+ ' ',
104
+ ' ',
105
+ ' ',
106
+ '',
107
+ '',
108
+ '',
109
+ '',
110
+ '',
111
+ ''
112
+ ), $value);
113
  return $value;
114
  }
115
 
app/code/community/Lengow/Export/Model/Catalog/Product.php CHANGED
@@ -64,7 +64,7 @@ class Lengow_Export_Model_Catalog_Product extends Mage_Catalog_Model_Product {
64
  *
65
  * @return mixed
66
  */
67
- protected function _getShippingPrice($product_instance, $carrierValue, $countryCode = 'FR')
68
  {
69
  $carrierTab = explode('_', $carrierValue);
70
  list($carrierCode, $methodCode) = $carrierTab;
@@ -132,12 +132,13 @@ class Lengow_Export_Model_Catalog_Product extends Mage_Catalog_Model_Product {
132
  *
133
  * @param Mage_Catalog_Model_Product $product_instance
134
  * @param Mage_Catalog_Model_Product $configurable_instance
 
135
  *
136
  * @return array
137
  */
138
- public function getPrices($product_instance, $configurable_instance = null)
139
  {
140
- $store = Mage::app()->getStore();
141
  $config = Mage::helper('tax')->priceIncludesTax($store);
142
  $calculator = Mage::getSingleton('tax/calculation');
143
  $taxClassId = $product_instance->getTaxClassId();
@@ -206,9 +207,21 @@ class Lengow_Export_Model_Catalog_Product extends Mage_Catalog_Model_Product {
206
  $price_including_tax = $price;
207
  $final_price_including_tax = $final_price;
208
  }
209
- $discount_amount = Mage::helper('directory')->currencyConvert($price_including_tax, $this->getOriginalCurrency(), $this->getCurrentCurrencyCode()) - Mage::helper('directory')->currencyConvert($final_price_including_tax, $this->getOriginalCurrency(), $this->getCurrentCurrencyCode());
210
- $data['price-ttc'] = round(Mage::helper('directory')->currencyConvert($final_price_including_tax, $this->getOriginalCurrency(), $this->getCurrentCurrencyCode()), 2);
211
- $data['price-before-discount'] = round(Mage::helper('directory')->currencyConvert($price_including_tax, $this->getOriginalCurrency(), $this->getCurrentCurrencyCode()), 2);
 
 
 
 
 
 
 
 
 
 
 
 
212
  $data['discount-amount'] = $discount_amount > 0 ? round($discount_amount, 2) : '0';
213
  $data['discount-percent'] = $discount_amount > 0 ? round(($discount_amount * 100) / $price_including_tax, 0) : '0';
214
  $data['start-date-discount'] = $product_instance->getSpecialFromDate();
64
  *
65
  * @return mixed
66
  */
67
+ public function _getShippingPrice($product_instance, $carrierValue, $countryCode = 'FR')
68
  {
69
  $carrierTab = explode('_', $carrierValue);
70
  list($carrierCode, $methodCode) = $carrierTab;
132
  *
133
  * @param Mage_Catalog_Model_Product $product_instance
134
  * @param Mage_Catalog_Model_Product $configurable_instance
135
+ * @param integer $id_store
136
  *
137
  * @return array
138
  */
139
+ public function getPrices($product_instance, $configurable_instance = null, $id_store)
140
  {
141
+ $store = Mage::app()->getStore($id_store);
142
  $config = Mage::helper('tax')->priceIncludesTax($store);
143
  $calculator = Mage::getSingleton('tax/calculation');
144
  $taxClassId = $product_instance->getTaxClassId();
207
  $price_including_tax = $price;
208
  $final_price_including_tax = $final_price;
209
  }
210
+ // get currency for convert
211
+ if (!$this->getCurrentCurrencyCode())
212
+ $toCurrency = $store->getCurrentCurrency();
213
+ else
214
+ $toCurrency = Mage::getModel('directory/currency')->load($this->getCurrentCurrencyCode());
215
+ // get prices with or without convertion
216
+ if ($this->getOriginalCurrency() == $toCurrency->getCode()) {
217
+ $discount_amount = $price_including_tax - $final_price_including_tax;
218
+ $data['price-ttc'] = round($final_price_including_tax,2);
219
+ $data['price-before-discount'] = round($price_including_tax,2);
220
+ } else {
221
+ $discount_amount = Mage::helper('directory')->currencyConvert($price_including_tax, $this->getOriginalCurrency(), $toCurrency) - Mage::helper('directory')->currencyConvert($final_price_including_tax, $this->getOriginalCurrency(), $this->getCurrentCurrencyCode());
222
+ $data['price-ttc'] = round(Mage::helper('directory')->currencyConvert($final_price_including_tax, $this->getOriginalCurrency(), $this->getCurrentCurrencyCode()), 2);
223
+ $data['price-before-discount'] = round(Mage::helper('directory')->currencyConvert($price_including_tax, $this->getOriginalCurrency(), $this->getCurrentCurrencyCode()), 2);
224
+ }
225
  $data['discount-amount'] = $discount_amount > 0 ? round($discount_amount, 2) : '0';
226
  $data['discount-percent'] = $discount_amount > 0 ? round(($discount_amount * 100) / $price_including_tax, 0) : '0';
227
  $data['start-date-discount'] = $product_instance->getSpecialFromDate();
app/code/community/Lengow/Export/Model/Feed/Xml.php CHANGED
@@ -17,7 +17,7 @@ class Lengow_Export_Model_Feed_Xml extends Lengow_Export_Model_Feed_Abstract {
17
  }
18
 
19
  public function makeHeader() {
20
- return '<?xml version="1.0" ?>' . "\r\n"
21
  . '<catalog>' . "\r\n";
22
  }
23
 
17
  }
18
 
19
  public function makeHeader() {
20
+ return '<?xml version="1.0" encoding="UTF-8"?>' . "\r\n"
21
  . '<catalog>' . "\r\n";
22
  }
23
 
app/code/community/Lengow/Export/Model/Feed/Yaml.php CHANGED
@@ -17,7 +17,7 @@ class Lengow_Export_Model_Feed_Yaml extends Lengow_Export_Model_Feed_Abstract {
17
  }
18
 
19
  public function makeHeader() {
20
- return '';
21
  }
22
 
23
  public function makeData($array, $args = array()) {
17
  }
18
 
19
  public function makeHeader() {
20
+ return '"catalog":' . "\r\n";
21
  }
22
 
23
  public function makeData($array, $args = array()) {
app/code/community/Lengow/Export/Model/Generate.php CHANGED
@@ -14,7 +14,7 @@ class Lengow_Export_Model_Generate extends Varien_Object {
14
 
15
  protected $_file;
16
 
17
- protected $_filename = 'lengow_feed';
18
 
19
  protected $_stream;
20
 
@@ -28,12 +28,14 @@ class Lengow_Export_Model_Generate extends Varien_Object {
28
 
29
  protected $_helper;
30
 
31
- protected $_time = null;
32
 
33
  protected $_clear_parent_cache = 0;
34
 
35
  protected $categoryCache = array();
36
 
 
 
37
  var $storeParents = array();
38
 
39
  protected $_excludes = array('media_gallery',
@@ -41,6 +43,7 @@ class Lengow_Export_Model_Generate extends Varien_Object {
41
  'short_description',
42
  'description',
43
  'quantity');
 
44
  /**
45
  * Default fields.
46
  */
@@ -109,8 +112,23 @@ class Lengow_Export_Model_Generate extends Varien_Object {
109
  $time_start = $this->microtime_float();
110
 
111
  $this->_id_store = $id_store;
 
 
 
 
112
  if (!is_null($format))
113
  $this->_format = $format;
 
 
 
 
 
 
 
 
 
 
 
114
  // Get products list to export
115
  $products = $this->_getProductsCollection($types, $status, $export_child, $out_of_stock, $selected_products, $limit, $offset, $ids_product);
116
  // Mode size, return count of products
@@ -277,7 +295,7 @@ class Lengow_Export_Model_Generate extends Varien_Object {
277
  $array_data['qty'] = (integer) $qty_temp;
278
  $array_data['status'] = $product->getStatus() == Mage_Catalog_Model_Product_Status::STATUS_DISABLED ? 'Disabled' : 'Enabled';
279
  $array_data = array_merge($array_data, $product->getCategories($product, $parent_instance, $this->_id_store, $this->categoryCache));
280
- $array_data = array_merge($array_data, $product->getPrices($product, $configurable_instance));
281
  $array_data = array_merge($array_data, $product->getShippingInfo($product));
282
  // Images, gestion de la fusion parent / enfant
283
  if($this->_config_model->get('data/parentsimages') && isset($parent_instance) && $parent_instance !== false)
@@ -302,7 +320,7 @@ class Lengow_Export_Model_Generate extends Varien_Object {
302
  $array_data['product_type'] = $product_type;
303
  $array_data['product_variation'] = $variation_name;
304
  $array_data['image_default'] = Mage::getBaseUrl(Mage_Core_Model_Store::URL_TYPE_MEDIA) . 'catalog/product' . $product->getImage();
305
- $array_data['child_name'] = $product->getName();
306
  // Selected attributes to export with Frond End value of current shop
307
  if(!empty($attributes_to_export)) {
308
  foreach($attributes_to_export as $field => $attr) {
@@ -368,7 +386,7 @@ class Lengow_Export_Model_Generate extends Varien_Object {
368
  flush();
369
  $this->_copyFile();
370
  $store_code = Mage::app()->getStore($this->_id_store)->getCode();
371
- $url_file = Mage::getBaseUrl(Mage_Core_Model_Store::URL_TYPE_MEDIA) . 'lengow' . DS . $store_code . DS . $this->_filename . '.' . $this->_format;
372
  echo $this->_helper->__('Your feed is available here : %s' , '<a href="' . $url_file . '">' . $url_file . '</a>');
373
  Mage::helper('lensync/data')->log('Export of the store ' . Mage::app()->getStore($this->_id_store)->getName() . '(' . $this->_id_store . ') generated a file here : ' . $url_file);
374
  }
@@ -565,13 +583,67 @@ class Lengow_Export_Model_Generate extends Varien_Object {
565
  */
566
  protected function _initFile()
567
  {
568
- $this->_time = time();
569
- $store_code = Mage::app()->getStore($this->_id_store)->getCode();
570
- $file_path = Mage::getBaseDir('media') . DS . 'lengow' . DS . $store_code . DS;
571
  $this->_file = new Varien_Io_File;
572
- $this->_file->checkAndCreateFolder($file_path);
573
- $this->_file->cd($file_path);
574
- $this->_file->streamOpen($this->_filename . '.' . $this->_time . '.' . $this->_format, 'w+');
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
575
  }
576
 
577
  /**
@@ -579,10 +651,9 @@ class Lengow_Export_Model_Generate extends Varien_Object {
579
  */
580
  protected function _copyFile()
581
  {
582
- $store_code = Mage::app()->getStore($this->_id_store)->getCode();
583
- $file_path = Mage::getBaseDir('media') . DS . 'lengow' . DS . $store_code . DS;
584
- copy($file_path . $this->_filename . '.' . $this->_time . '.' . $this->_format, $file_path . $this->_filename . '.' . $this->_format);
585
- unlink($file_path . $this->_filename . '.' . $this->_time . '.' . $this->_format);
586
  }
587
 
588
  /**
14
 
15
  protected $_file;
16
 
17
+ protected $_fileName = 'lengow_feed';
18
 
19
  protected $_stream;
20
 
28
 
29
  protected $_helper;
30
 
31
+ protected $_fileTimeStamp = null;
32
 
33
  protected $_clear_parent_cache = 0;
34
 
35
  protected $categoryCache = array();
36
 
37
+ protected $_config = array();
38
+
39
  var $storeParents = array();
40
 
41
  protected $_excludes = array('media_gallery',
43
  'short_description',
44
  'description',
45
  'quantity');
46
+
47
  /**
48
  * Default fields.
49
  */
112
  $time_start = $this->microtime_float();
113
 
114
  $this->_id_store = $id_store;
115
+
116
+ $store_code = Mage::app()->getStore($this->_id_store)->getCode();
117
+ $this->_config['directory_path'] = Mage::getBaseDir('media') . DS . 'lengow' . DS . $store_code . DS;
118
+
119
  if (!is_null($format))
120
  $this->_format = $format;
121
+ $this->_fileFormat = $this->_format;
122
+
123
+ if ($this->_isAlreadyLaunch()){
124
+ Mage::helper('lensync/data')->log('Feed already launch');
125
+
126
+ if(!$this->_stream) {
127
+ echo date('Y-m-d h:i:s') . ' - FEED ALREADY LAUNCH<br />';
128
+ }
129
+ exit();
130
+ }
131
+
132
  // Get products list to export
133
  $products = $this->_getProductsCollection($types, $status, $export_child, $out_of_stock, $selected_products, $limit, $offset, $ids_product);
134
  // Mode size, return count of products
295
  $array_data['qty'] = (integer) $qty_temp;
296
  $array_data['status'] = $product->getStatus() == Mage_Catalog_Model_Product_Status::STATUS_DISABLED ? 'Disabled' : 'Enabled';
297
  $array_data = array_merge($array_data, $product->getCategories($product, $parent_instance, $this->_id_store, $this->categoryCache));
298
+ $array_data = array_merge($array_data, $product->getPrices($product, $configurable_instance, $this->_id_store));
299
  $array_data = array_merge($array_data, $product->getShippingInfo($product));
300
  // Images, gestion de la fusion parent / enfant
301
  if($this->_config_model->get('data/parentsimages') && isset($parent_instance) && $parent_instance !== false)
320
  $array_data['product_type'] = $product_type;
321
  $array_data['product_variation'] = $variation_name;
322
  $array_data['image_default'] = Mage::getBaseUrl(Mage_Core_Model_Store::URL_TYPE_MEDIA) . 'catalog/product' . $product->getImage();
323
+ $array_data['child_name'] = $this->_helper->cleanData($product->getName(), $formatData);
324
  // Selected attributes to export with Frond End value of current shop
325
  if(!empty($attributes_to_export)) {
326
  foreach($attributes_to_export as $field => $attr) {
386
  flush();
387
  $this->_copyFile();
388
  $store_code = Mage::app()->getStore($this->_id_store)->getCode();
389
+ $url_file = Mage::getBaseUrl(Mage_Core_Model_Store::URL_TYPE_MEDIA) . 'lengow' . DS . $store_code . DS . $this->_fileName . '.' . $this->_format;
390
  echo $this->_helper->__('Your feed is available here : %s' , '<a href="' . $url_file . '">' . $url_file . '</a>');
391
  Mage::helper('lensync/data')->log('Export of the store ' . Mage::app()->getStore($this->_id_store)->getName() . '(' . $this->_id_store . ') generated a file here : ' . $url_file);
392
  }
583
  */
584
  protected function _initFile()
585
  {
586
+ if (!$this->_createDirectory()){ exit(); }
587
+
588
+ $this->_fileTimeStamp = time();
589
  $this->_file = new Varien_Io_File;
590
+ $this->_file->cd($this->_config['directory_path']);
591
+ $this->_file->streamOpen($this->_fileName . '.' . $this->_fileTimeStamp . '.' . $this->_fileFormat, 'w+');
592
+ }
593
+
594
+ protected function _createDirectory(){
595
+ try {
596
+ $file = new Varien_Io_File;
597
+ $file->checkAndCreateFolder($this->_config['directory_path']);
598
+ } catch (Exception $e) {
599
+ Mage::helper('lensync/data')->log('can\'t create folder '.$this->_config['directory_path'].'');
600
+ if ($this->_debug){
601
+ $this->_log('can\'t create folder '.$this->_config['directory_path']);
602
+ }
603
+ return false;
604
+ }
605
+ return true;
606
+ }
607
+
608
+ /**
609
+ * Is Feed Already Launch
610
+ *
611
+ * @return boolean
612
+ */
613
+ protected function _isAlreadyLaunch(){
614
+
615
+ $directory = $this->_config['directory_path'];
616
+ if (!$this->_createDirectory()){
617
+ exit();
618
+ }
619
+
620
+ try {
621
+ $listFiles = array_diff(scandir($directory), array('..', '.'));
622
+ } catch (Exception $e) {
623
+ Mage::helper('lensync/data')->log('Can\'t access folder '.$this->_config['directory_path']);
624
+ if ($this->_debug){
625
+ $this->_log('Can\'t access folder '.$this->_config['directory_path']);
626
+ }
627
+ exit();
628
+ }
629
+ foreach ($listFiles as $file) {
630
+ if (preg_match('/^' . $this->_fileName . '\.[\d]{10}/', $file)) {
631
+ $fileModified = date('Y-m-d H:i:s', filemtime($directory . $file));
632
+ $fileModifiedDatetime = new DateTime($fileModified);
633
+ $fileModifiedDatetime->add(new DateInterval('P10D'));
634
+
635
+ if (date('Y-m-d') > $fileModifiedDatetime->format('Y-m-d')) {
636
+ unlink($directory . $file);
637
+ }
638
+
639
+ $fileModifiedDatetime = new DateTime($fileModified);
640
+ $fileModifiedDatetime->add(new DateInterval('PT20S'));
641
+ if (date('Y-m-d H:i:s') < $fileModifiedDatetime->format('Y-m-d H:i:s')) {
642
+ return true;
643
+ }
644
+ }
645
+ }
646
+ return false;
647
  }
648
 
649
  /**
651
  */
652
  protected function _copyFile()
653
  {
654
+ $file_path = $this->_config['directory_path'];
655
+ copy($file_path . $this->_fileName . '.' . $this->_fileTimeStamp . '.' . $this->_fileFormat, $file_path . $this->_fileName . '.' . $this->_fileFormat);
656
+ unlink($file_path . $this->_fileName . '.' . $this->_fileTimeStamp . '.' . $this->_fileFormat);
 
657
  }
658
 
659
  /**
app/code/community/Lengow/Export/Model/Generateoptimize.php ADDED
@@ -0,0 +1,1436 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * Lengow adminhtml export controller
4
+ *
5
+ * @category Lengow
6
+ * @package Lengow_Export
7
+ * @author Ludovic Drin <ludovic@lengow.com> & Benjamin Le Nevé <benjamin.le-neve@lengow.com>
8
+ * @copyright 2015 Lengow SAS
9
+ * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
10
+ */
11
+ class Lengow_Export_Model_Generateoptimize extends Varien_Object {
12
+
13
+ protected $_id_store;
14
+ protected $_websiteId;
15
+
16
+ //Export files options
17
+ protected $_file;
18
+ protected $_fileName = 'lengow_feed';
19
+ protected $_stream;
20
+ protected $_fileFormat;
21
+ protected $_fileTimeStamp = null;
22
+
23
+ protected $_config_model;
24
+ protected $_product_model;
25
+ protected $_eav_model;
26
+ protected $_helper;
27
+
28
+ protected $_clear_parent_cache = 0;
29
+
30
+ protected $categoryCache = array();
31
+
32
+ var $storeParents = array();
33
+
34
+ var $grouped = array();
35
+
36
+ //debug mode
37
+ protected $_debug = false;
38
+ //store data
39
+ protected $_listImages = array();
40
+ protected $_listCategories = array();
41
+ protected $_listGroupedProducts = array();
42
+ protected $_listCodeAttributes = array();
43
+ protected $_listTaxes = array();
44
+ protected $_listParentIds = array();
45
+ protected $_listChildrenIds = array();
46
+ protected $_listAttributeValues = array();
47
+ protected $_listAttributeCode = array();
48
+ protected $_listConfigurableVariation = array();
49
+ protected $_listOptionValues = array();
50
+ //start time of script
51
+ protected $_startScript = array();
52
+ protected $_productLimit;
53
+
54
+ //store magento table name
55
+ protected $_table = array();
56
+ //option in magento configration
57
+ protected $_config = array();
58
+
59
+ protected $_excludes = array('media_gallery',
60
+ 'tier_price',
61
+ 'short_description',
62
+ 'description',
63
+ 'quantity');
64
+ /**
65
+ * Default fields.
66
+ */
67
+ public static $DEFAULT_FIELDS = array('sku' => 'sku' ,
68
+ 'entity_id' => 'product-id' ,
69
+ 'parent-id' => 'parent-id' ,
70
+ 'qty' => 'qty' ,
71
+ 'name' => 'name' ,
72
+ 'description' => 'description' ,
73
+ 'short_description' => 'short_description' ,
74
+ 'price-ttc' => 'price-ttc' ,
75
+ 'shipping-name' => 'shipping-name' ,
76
+ 'image-url-1' => 'image-url-1' ,
77
+ 'product-url' => 'product-url');
78
+
79
+ protected $_attributes = array(
80
+ 'sku',
81
+ 'product_id',
82
+ 'name',
83
+ 'short_description',
84
+ 'description',
85
+ 'image',
86
+ 'small_image',
87
+ 'thumbnail',
88
+ 'manufacturer',
89
+ 'ean',
90
+ 'url',
91
+ 'url_key',
92
+ 'special_price',
93
+ 'special_from_date',
94
+ 'special_to_date',
95
+ 'price_type',
96
+ 'price',
97
+ 'final_price',
98
+ 'tax_class_id',
99
+ 'is_in_stock',
100
+ 'qty',
101
+ 'entity_id',
102
+ 'created_at',
103
+ 'updated_at',
104
+ 'visibility',
105
+ );
106
+
107
+ protected $_listHeaderCsvFile = array(
108
+ 'sku',
109
+ 'product_id',
110
+ 'qty',
111
+ 'status',
112
+ 'lengow_categories_header',
113
+ 'price_ttc',
114
+ 'price_before_discount',
115
+ 'discount_amount',
116
+ 'discount_percent',
117
+ 'start_date_discount',
118
+ 'end_date_discount',
119
+ 'shipping_name',
120
+ 'shipping_price',
121
+ 'lengow_images_header',
122
+ 'product_url',
123
+ 'name',
124
+ 'description',
125
+ 'short_description',
126
+ 'parent_id',
127
+ 'product_type',
128
+ 'product_variation',
129
+ 'image_default',
130
+ 'child_name',
131
+ );
132
+
133
+ protected $_attributesAdditional = array();
134
+
135
+ protected $_listAttributeToShow = array(
136
+ 'sku',
137
+ 'product_id',
138
+ 'qty',
139
+ 'status',
140
+ 'categories',
141
+ 'prices',
142
+ 'shipping_informations',
143
+ 'images',
144
+ 'product_url',
145
+ 'name',
146
+ 'description',
147
+ 'short_description',
148
+ 'parent_informations',
149
+ 'product_variation',
150
+ 'image_default',
151
+ );
152
+
153
+ protected $_listForbiddenAttributes = array(
154
+ 'group_price'
155
+ );
156
+
157
+ /**
158
+ * Construct generator
159
+ * Set models
160
+ */
161
+ public function __construct()
162
+ {
163
+ $this->_config_model = Mage::getSingleton('lenexport/config');
164
+ $this->_product_model = Mage::getModel('lenexport/catalog_product');
165
+ $this->_eav_model = Mage::getResourceModel('eav/entity_attribute_collection');
166
+
167
+ $this->_helper = Mage::helper('lenexport/data');
168
+
169
+ //get configuration data
170
+ $this->_config['category_max_level'] = $this->_config_model->get('data/levelcategory');
171
+ $this->_config['number_product_by_query'] = 2000;
172
+ $this->_config["query_url_option"] = (version_compare(Mage::getVersion(), '1.6.0', '<')) ? 'options=\'\'' : 'ISNULL(options)';
173
+
174
+
175
+ //Get Table Definition
176
+ $this->_coreResource = Mage::getSingleton('core/resource');
177
+ $this->_table['catalog_product_link'] = $this->_coreResource->getTableName('catalog_product_link');
178
+ $this->_table['cataloginventory_stock_item'] = $this->_coreResource->getTableName('cataloginventory_stock_item');
179
+ $this->_table['catalog_product_entity_media_gallery'] = $this->_coreResource->getTableName('catalog_product_entity_media_gallery');
180
+ $this->_table['catalog_product_entity_media_gallery_value'] = $this->_coreResource->getTableName('catalog_product_entity_media_gallery_value');
181
+ $this->_table['catalog_product_entity'] = $this->_coreResource->getTableName('catalog_product_entity');
182
+ $this->_table['eav_attribute'] = $this->_coreResource->getTableName('eav_attribute');
183
+ $this->_table['eav_entity_type'] = $this->_coreResource->getTableName('eav_entity_type');
184
+ $this->_table['catalog_product_entity_int'] = $this->_coreResource->getTableName('catalog_product_entity_int');
185
+ $this->_table['catalog_product_entity_varchar'] = $this->_coreResource->getTableName('catalog_product_entity_varchar');
186
+ $this->_table['catalog_product_entity_datetime'] = $this->_coreResource->getTableName('catalog_product_entity_datetime');
187
+ $this->_table['catalog_product_entity_decimal'] = $this->_coreResource->getTableName('catalog_product_entity_decimal');
188
+ $this->_table['catalog_product_entity_text'] = $this->_coreResource->getTableName('catalog_product_entity_text');
189
+ $this->_table['core_url_rewrite'] = $this->_coreResource->getTableName('core_url_rewrite');
190
+ $this->_table['catalog_category_product'] = $this->_coreResource->getTableName('catalog_category_product');
191
+ $this->_table['catalog_category_product_index'] = $this->_coreResource->getTableName('catalog_category_product_index');
192
+ $this->_table['catalog_product_index_price'] = $this->_coreResource->getTableName('catalog_product_index_price');
193
+ $this->_table['eav_attribute_option'] = $this->_coreResource->getTableName('eav_attribute_option');
194
+ $this->_table['eav_attribute_option_value'] = $this->_coreResource->getTableName('eav_attribute_option_value');
195
+ $this->_table['catalog_product_super_attribute'] = $this->_coreResource->getTableName('catalog_product_super_attribute');
196
+ $this->_table['catalog_product_super_link'] = $this->_coreResource->getTableName('catalog_product_super_link');
197
+ $this->_table['tax_class'] = $this->_coreResource->getTableName('tax_class');
198
+ $this->_table['tax_calculation'] = $this->_coreResource->getTableName('tax_calculation');
199
+ $this->_table['tax_calculation_rate'] = $this->_coreResource->getTableName('tax_calculation_rate');
200
+ $this->_table['directory_country_region'] = $this->_coreResource->getTableName('directory_country_region');
201
+ $this->_table['customer_group'] = $this->_coreResource->getTableName('customer_group');
202
+
203
+ $connection = $this->_coreResource->getConnection('core_read');
204
+
205
+ //get Catalog Product Entity Id
206
+ $query = $connection->select()->from($this->_table['eav_entity_type'])->where('entity_type_code=\'catalog_product\'');
207
+ $row = $connection->fetchAll($query);
208
+ $this->_catalogProductEntityId = $row[0]['entity_type_id'];
209
+
210
+ //get status attribute code
211
+ $query = $connection->select()->from($this->_table['eav_attribute'])->where('attribute_code=\'status\'');
212
+ $row = $connection->fetchAll($query);
213
+ $this->_attributeStatusId = $row[0]['attribute_id'];
214
+ }
215
+
216
+
217
+ public function getTotalProductStore($storeId){
218
+
219
+ $this->_id_store = $storeId;
220
+ $this->_websiteId = Mage::getModel('core/store')->load($this->_id_store)->getWebsiteId();
221
+
222
+ $productCollection = $this->_getQuery();
223
+
224
+ $productCollection = clone $productCollection;
225
+ $productCollection->getSelect()->columns('COUNT(DISTINCT e.entity_id) As total');
226
+ return $productCollection->getFirstItem()->getTotal();
227
+ }
228
+
229
+ public function _getQuery(){
230
+
231
+
232
+ $productCollection = Mage::getModel('lenexport/product_collection')->getCollection()->addStoreFilter($this->_id_store);
233
+
234
+ // Filter status
235
+ if ($this->_config['product_status'] !== null){
236
+ $productCollection->addAttributeToFilter('status', array('eq' => $this->_config['product_status']));
237
+ }
238
+
239
+ //filter type
240
+ if($this->_config['force_type']) {
241
+ $_types = explode(',', $this->_config['force_type']);
242
+ } else {
243
+ $_types = $this->_config_model->get('global/producttype');
244
+ $_types = explode(',', $_types);
245
+ }
246
+ $productCollection->addAttributeToFilter('type_id', array('in' => $_types));
247
+
248
+ if ($this->_config['mode'] != 'size') {
249
+ $productCollection->addAttributeToSelect($this->_attributes, true);
250
+ }
251
+
252
+ $this->_joinStock($productCollection);
253
+
254
+ if ($this->_config['only_selected_product']){
255
+ $productCollection->addAttributeToFilter('lengow_product', array('eq' => 1));
256
+ }
257
+ if ($this->_config['product_ids']){
258
+ $productCollection->addAttributeToFilter('entity_id', array('in' => $this->_config['product_ids']));
259
+ }
260
+
261
+ $productCollection->getSelect()->joinLeft($this->_table['core_url_rewrite'] . ' AS url',
262
+ 'url.product_id=e.entity_id AND url.target_path NOT LIKE "category%" AND is_system=1 AND ' . $this->_config["query_url_option"] . ' AND url.store_id=' . $this->_id_store,
263
+ array('request_path' => 'MAX(DISTINCT request_path)'));
264
+
265
+ $productCollection->getSelect()->joinLeft($this->_table['catalog_category_product'] . ' AS categories', 'categories.product_id=e.entity_id');
266
+ $productCollection->getSelect()->joinLeft($this->_table['catalog_category_product_index'] . ' AS categories_index',
267
+ '((categories_index.category_id=categories.category_id AND categories_index.product_id=categories.product_id) ) AND categories_index.store_id=' . $this->_id_store,
268
+ array('categories_ids' => 'GROUP_CONCAT(DISTINCT categories_index.category_id)'));
269
+ if (version_compare(Mage::getVersion(), '1.4.0', '>=')) {
270
+ $productCollection->getSelect()->joinLeft($this->_table['catalog_product_index_price'] . ' AS price_index',
271
+ 'price_index.entity_id=e.entity_id AND customer_group_id=0 AND price_index.website_id=' . $this->_websiteId,
272
+ array(
273
+ 'index_price' => 'price',
274
+ 'index_min_price' => 'min_price',
275
+ 'index_max_price' => 'max_price',
276
+ 'index_tier_price' => 'tier_price',
277
+ 'index_final_price' => 'final_price'
278
+ ));
279
+ }
280
+ $productCollection->getSelect()->group('e.entity_type_id');
281
+ return $productCollection;
282
+ }
283
+
284
+ /**
285
+ * Make the feed
286
+ *
287
+ * @param integer $id_store ID of store
288
+ * @param varchar $mode The mode of export
289
+ * size : display only count of products to export
290
+ * full : export simple product + configured product
291
+ * xxx,yyy : export xxx type product + yyy type product
292
+ * @param varchar $format Format of export
293
+ * @param array $params List of options
294
+ *
295
+ * @return Mage_Catalog_Model_Product
296
+ */
297
+ public function exec($id_store, $format, $params = array()) {
298
+
299
+ $this->_debug = true;
300
+
301
+ //store start time export
302
+ $this->_startScript = $this->microtime_float();
303
+ //set Store id / Website id
304
+ $this->_id_store = $id_store;
305
+ $this->_websiteId = Mage::getModel('core/store')->load($this->_id_store)->getWebsiteId();
306
+
307
+ $store_code = Mage::app()->getStore($this->_id_store)->getCode();
308
+
309
+ $this->_config['include_tax'] = Mage::getStoreConfig(Mage_Tax_Model_Config::CONFIG_XML_PATH_PRICE_INCLUDES_TAX, $this->_id_store);
310
+ $this->_config['directory_path'] = Mage::getBaseDir('media') . DS . 'lengow' . DS . $store_code . DS;
311
+ $this->_config['image_base_url'] = substr(Mage::app()->getStore($this->_id_store)->getBaseUrl(Mage_Core_Model_Store::URL_TYPE_MEDIA, false), 0, -1).'/catalog/product';
312
+ $this->_config['force_type'] = array_key_exists('forced_type',$params) ? $params['forced_type'] : false;
313
+ $this->_config['product_status'] = array_key_exists('status',$params) ? $params['status'] : null;
314
+ $this->_config['product_ids'] = array_key_exists('product_ids',$params) ? $params['product_ids'] : false;
315
+ $this->_debug = array_key_exists('debug',$params) ? $params["debug"] : false;
316
+
317
+ $this->_config['offset'] = array_key_exists('offset',$params) ? $params['offset'] : false;
318
+ $this->_productLimit = array_key_exists('limit',$params) ? $params['limit'] : false;
319
+ if ($this->_config['product_status'] === null){
320
+ $this->_config['product_status'] = (string) $this->_config_model->get('global/productstatus');
321
+ if($this->_config['product_status'] === Mage_Catalog_Model_Product_Status::STATUS_ENABLED
322
+ OR $this->_config['product_status'] === Mage_Catalog_Model_Product_Status::STATUS_DISABLED){
323
+ $this->_config['product_status'] = $this->_config['product_status'];
324
+ }else{
325
+ $this->_config['product_status'] = null;
326
+ }
327
+ }
328
+
329
+ $attributes = Mage::getStoreConfig('lenexport/data/html_attributes', $this->_id_store);
330
+ $this->_config['attribute_html'] = !empty($attributes) ? explode(',', $attributes) : array();
331
+ $this->_config['shipping_price'] = $this->_config_model->get('data/default_shipping_price', $this->_id_store);
332
+
333
+ $outOfStock = array_key_exists('out_of_stock',$params) ? $params['out_of_stock'] : null;
334
+ if ($outOfStock === null){
335
+ $this->_config['out_of_stock'] = (int)$this->_config_model->get('global/export_soldout');
336
+ }
337
+
338
+ $selectedProduct = array_key_exists('forced_type',$params) ? $params['selected_products'] : null;
339
+ if ($selectedProduct === null){
340
+ $this->_config['only_selected_product'] = (int)$this->_config_model->onlySelectedProducts();
341
+ }
342
+ if ($format === null){
343
+ $this->_fileFormat = $this->_config_model->get('data/format');
344
+ }else{
345
+ $this->_fileFormat = $format;
346
+ }
347
+ $this->_config['mode'] = array_key_exists('mode',$params) ? $params['mode'] : false;
348
+
349
+
350
+ $stream = array_key_exists('stream',$params) ? $params['stream'] : null;
351
+ if ($stream === null){
352
+ $this->_stream = $this->_config_model->get('performances/usesavefile') ? false : true;
353
+ }
354
+
355
+ if ($this->_isAlreadyLaunch()){
356
+ Mage::helper('lensync/data')->log('Feed already launch');
357
+
358
+ if(!$this->_stream) {
359
+ $this->_log('/!\ Feed already Launch');
360
+ }
361
+ exit();
362
+ }
363
+
364
+ if(!$this->_stream) {
365
+ header('Content-Type: text/html; charset=utf-8');
366
+ $this->_log('Start Store = ' . Mage::app()->getStore($this->_id_store)->getName() . '(' . $this->_id_store . ')');
367
+ }
368
+
369
+ if ($this->_config['mode'] == 'size'){
370
+
371
+ $this->_log('Total Products :'.$this->getTotalProductStore($this->_id_store));
372
+ $this->_log('Memory Usage '.(memory_get_usage()/1000000));
373
+ $this->_stop($this->_startScript, 'Execution time ');
374
+ exit();
375
+ }
376
+
377
+ // Get products list to export
378
+ $this->_getProductsCollection($format, $params);
379
+
380
+ if(!$this->_stream) {
381
+ $this->_log('Memory Usage '.(memory_get_usage()/1000000));
382
+ $this->_stop($this->_startScript, 'Execution time ');
383
+ }
384
+
385
+ }
386
+
387
+ /**
388
+ * Get Product Collection
389
+ *
390
+ * @param varchar $mode The mode of export
391
+ * size : display only count of products to export
392
+ * full : export simple product + configured product
393
+ * xxx,yyy : export xxx type product + yyy type product
394
+ * @param varchar $format Format of export
395
+ * @param array $params Parameters
396
+ *
397
+ * @return float price
398
+ */
399
+
400
+
401
+ protected function _getProductsCollection($format, $params = array())
402
+ {
403
+
404
+ //$out_of_stock = array_key_exists('out_of_stock',$params) ? $params['out_of_stock'] : false;
405
+
406
+
407
+ $this->_loadTaxes();
408
+ $this->_loadSelectedAttributes();
409
+ $this->_loadProductAttributes();
410
+ $this->_loadProductAttributeValues();
411
+ $this->_loadConfigurableProducts();
412
+ $this->_loadImages();
413
+ $this->_loadCategories();
414
+ $this->_loadGroupedProducts();
415
+ $this->_buildCsvHeader();
416
+
417
+
418
+ $productCollection = $this->_getQuery();
419
+
420
+ $tempProductCollection = clone $productCollection;
421
+ $tempProductCollection->getSelect()->columns('COUNT(DISTINCT e.entity_id) As total');
422
+ $nbProduct = $tempProductCollection->getFirstItem()->getTotal();
423
+ if ($this->_productLimit && $nbProduct > $this->_productLimit){
424
+ $nbProduct = $this->_productLimit;
425
+ }
426
+ $totalQueryToExecute = ceil($nbProduct / $this->_config['number_product_by_query']);
427
+
428
+ $productCollection->getSelect()->group(array('e.entity_id'))->order('e.entity_id');
429
+ $nbQueryExecuted = 0;
430
+
431
+ if ($this->_debug){
432
+ $this->_log('Total items calculated ('.$nbProduct.' in '.$totalQueryToExecute.' queries )');
433
+ }
434
+ Mage::helper('lensync/data')->log('Find ' . $nbProduct . ' product' . ($nbProduct > 1 ? 's ' : ' '));
435
+
436
+ $formatData = $this->_config_model->get('data/formatdata') == 1 ? true : false;
437
+
438
+
439
+ $feed = Mage::getModel('Lengow_Export_Model_Feed_' . ucfirst($this->_fileFormat));
440
+
441
+ // Get content type if streamed feed
442
+ if($this->_stream)
443
+ header('Content-Type: ' . $feed->getContentType() . '; charset=utf-8');
444
+ $feed->setFields($this->_listHeaderCsvFile);
445
+ $this->_write($feed->makeHeader());
446
+
447
+ $pi = 0;
448
+
449
+ while ($nbQueryExecuted < $totalQueryToExecute) {
450
+ $currentProductCollection = clone $productCollection;
451
+
452
+
453
+ if ($this->_config['offset']){
454
+ $offset = (int)$this->_config['offset'];
455
+ }else{
456
+ $offset = ($this->_config['number_product_by_query'] * $nbQueryExecuted);
457
+ }
458
+
459
+ if ($this->_config['number_product_by_query']){
460
+ if ($this->_productLimit && $this->_config['number_product_by_query'] > $this->_productLimit){
461
+ $currentProductCollection->getSelect()->limit($this->_productLimit, $offset);
462
+ }else{
463
+ $currentProductCollection->getSelect()->limit($this->_config['number_product_by_query'], $offset);
464
+ }
465
+ }
466
+
467
+
468
+ ++$nbQueryExecuted;
469
+
470
+ if ($this->_config['number_product_by_query'] * $nbQueryExecuted > $nbProduct) {
471
+ $totalOffset = $nbProduct;
472
+ } else {
473
+ $totalOffset = $this->_config['number_product_by_query'] * $nbQueryExecuted;
474
+ }
475
+ //if ($this->_debug){
476
+ $this->_log('Fetching products from ' . ($this->_config['number_product_by_query'] * ($nbQueryExecuted - 1) + 1) . ' to ' . $totalOffset);
477
+ //echo $currentProductCollection->getSelect();
478
+ //}
479
+
480
+ foreach ($currentProductCollection as $product) {
481
+ ++$pi;
482
+ $data = array();
483
+ $data['type'] = $product->getTypeId();
484
+ foreach($this->_listAttributeToShow as $attributeToShow){
485
+ switch($attributeToShow){
486
+ case 'sku':
487
+ $data['sku'] = $product->getSku();
488
+ break;
489
+ case 'product_id':
490
+ $data['product_id'] = $product->getId();
491
+ break;
492
+ case 'qty':
493
+ //todo : what quantity for configurable / bundle product ???
494
+ switch($product->getTypeId()){
495
+ case 'grouped':
496
+ $data['qty'] = (int)$this->_listGroupedProducts[$product->getId()]['qty'];
497
+ break;
498
+ default:
499
+ $data['qty'] = (int)$product->getQty();
500
+ break;
501
+ }
502
+ break;
503
+ case 'status':
504
+ switch($product->getTypeId()){
505
+ case 'grouped':
506
+ $data['status'] = $this->_listGroupedProducts[$product->getId()]['status'];
507
+ break;
508
+ default:
509
+ $data['status'] = $product->getStatus();
510
+ break;
511
+ }
512
+ $data['status'] = ($data['status'] == Mage_Catalog_Model_Product_Status::STATUS_DISABLED) ? 'Disabled' : 'Enabled';
513
+ break;
514
+ case 'categories':
515
+ $categoryTemp = array();
516
+ if($product->getVisibility() == Mage_Catalog_Model_Product_Visibility::VISIBILITY_NOT_VISIBLE && isset($this->_listChildrenIds[$product->getId()])){
517
+ $currentPathCategory = explode(',', $this->_listChildrenIds[$product->getId()]['categories_id']);
518
+ }else{
519
+ $currentPathCategory = explode(',', $product->getCategoriesIds());
520
+ }
521
+ $currentCategoryId = end($currentPathCategory);;
522
+ $i = 0;
523
+ if (!$currentCategoryId){
524
+ $data['category'] = '';
525
+ $data['category-url'] = '';
526
+ }else{
527
+ $level = 0;
528
+ foreach($currentPathCategory as $category){
529
+ if ($this->_listCategories[$category]['level'] > $level){
530
+ $level = $this->_listCategories[$category]['level'];
531
+ $currentCategoryId = $category;
532
+ }
533
+ }
534
+ $fullPathCategory = explode('/', $this->_listCategories[$currentCategoryId]['path']);
535
+ foreach ($fullPathCategory as $categoryId){
536
+ if($i == 0) { ++$i; continue; }
537
+ $categoryTemp[] = $this->_listCategories[$categoryId]['name'];
538
+
539
+ if($i == 1) {
540
+ $data['category'] = $this->_listCategories[$categoryId]['name'];
541
+ $data['category-url'] = $this->_listCategories[$categoryId]['url'];
542
+ } elseif($i <= $this->_config['category_max_level']) {
543
+ $data['category-sub-'.($i-1)] = $this->_listCategories[$categoryId]['name'];
544
+ $data['category-url-sub-'.($i-1)] = $this->_listCategories[$categoryId]['url'];
545
+ }
546
+ ++$i;
547
+ }
548
+ }
549
+ for ($j = $i; $j <= $this->_config['category_max_level']; ++$j) {
550
+ $data['category-sub-'.$j] = '';
551
+ $data['category-url-sub-'.$j] = '';
552
+ }
553
+
554
+ $data['category_breadcrumb'] = join(' > ',$categoryTemp);
555
+ break;
556
+ case 'prices':
557
+ if ($product->getIndexPrice()>0){
558
+ $product["price"] = $product->getIndexPrice();
559
+ }
560
+ if ($product->getIndexFinalPrice()>0){
561
+ $product["final_price"] = $product->getIndexFinalPrice();
562
+ }
563
+ if ($product["final_price"]==0){
564
+ $product["final_price"] = $product["price"];
565
+ }
566
+ switch($product->getTypeId()){
567
+ case 'grouped':
568
+ $data["price_ttc"] = $this->_calculatePrice($this->_listGroupedProducts[$product->getId()]['price'], $product->getTaxClassId());
569
+ $data["price_before_discount"] = $data["price_ttc"];
570
+ break;
571
+ default:
572
+ $data["price_ttc"] = $this->_calculatePrice($product["final_price"], $product->getTaxClassId());
573
+ $data["price_before_discount"] = $this->_calculatePrice($product["price"], $product->getTaxClassId());
574
+ break;
575
+ }
576
+ $discountAmount = ((float)$data["price_before_discount"]-(float)$data["price_ttc"]);
577
+ $data['discount_amount'] = $discountAmount > 0 ? round($discountAmount, 2) : '0';
578
+ $data['discount_percent'] = $discountAmount > 0 ? round(($discountAmount * 100) / (float)$data['price_before_discount'], 0) : '0';
579
+ $data['start_date_discount'] = $product->getSpecialFromDate();
580
+ $data['end_date_discount'] = $product->getSpecialToDate();
581
+ break;
582
+ case 'shipping_informations':
583
+ $data['shipping_name'] = '';
584
+ $data['shipping_price'] = '';
585
+ $data['shipping_delay'] = $this->_config_model->get('data/default_shipping_delay');
586
+ $carrier = $this->_config_model->get('data/default_shipping_method');
587
+ if ($carrier == 'flatrate_flatrate' || $carrier == ''){
588
+ $data['shipping_name'] = 'Flatrate';
589
+ $data['shipping_price'] = $this->_config['shipping_price'];
590
+ }else{
591
+ if(!empty($carrier)){
592
+ $carrierTab = explode('_',$carrier);
593
+ list($carrierCode,$methodCode) = $carrierTab;
594
+ //todo : wrong shipping name ?
595
+ $data['shipping_name'] = ucfirst($methodCode);
596
+ $shippingPrice = 0;
597
+ $countryCode = $this->_config_model->get('data/shipping_price_based_on');
598
+
599
+ $shippingPrice = $product->_getShippingPrice($product, $carrier, $countryCode);
600
+ if(!$shippingPrice) {
601
+ $shippingPrice = $this->_config['shipping_price'];
602
+ }
603
+ $data['shipping_price'] = $shippingPrice;
604
+ }
605
+ }
606
+ break;
607
+ case 'images':
608
+ $max_image = $this->_config_model->getCountExportImages();
609
+ for($i = 1; $i <= $max_image; ++$i) {
610
+ $data['image-url-'.$i] = '';
611
+ }
612
+
613
+ if (isset($this->_listImages[$product->getId()])){
614
+ $productImage = $this->_listImages[$product->getId()];
615
+ $i = 1;
616
+ foreach($productImage as $image){
617
+ if ($image['disabled']==0){
618
+ $data['image-url-' . $i] = $this->_config['image_base_url'].$image['src'];
619
+ ++$i;
620
+ }
621
+ }
622
+ for ($j = $i; $j < $max_image; ++$j) {
623
+ $data['image-url-'.$j] = '';
624
+ }
625
+ }
626
+
627
+ if ($data['image-url-1']=='' && isset($this->_listChildrenIds[$product->getId()])){
628
+ if (isset($this->_listImages[$this->_listChildrenIds[$product->getId()]['id']])){
629
+ foreach($this->_listImages[$this->_listChildrenIds[$product->getId()]['id']] as $img){
630
+ $data['image-url-1'] = $this->_config['image_base_url'].$img['src'];
631
+ }
632
+ }
633
+ }
634
+ $data['image_default'] = $data['image-url-1'];
635
+ break;
636
+ case 'product_url':
637
+ if($product->getVisibility() == Mage_Catalog_Model_Product_Visibility::VISIBILITY_NOT_VISIBLE && isset($this->_listChildrenIds[$product->getId()])) {
638
+ $data['product_url'] = $this->_listChildrenIds[$product->getId()]['url'];
639
+ }else{
640
+ if ($product->getProductUrl() == "" && isset($this->_listChildrenIds[$product->getId()]['url'])){
641
+ $data['product_url'] = $this->_listChildrenIds[$product->getId()]['url'];
642
+ } else{
643
+ $data['product_url'] = $product->getProductUrl();
644
+ }
645
+ }
646
+ break;
647
+ case 'name':
648
+ if($product->getVisibility() == Mage_Catalog_Model_Product_Visibility::VISIBILITY_NOT_VISIBLE && isset($this->_listChildrenIds[$product->getId()])) {
649
+ if ($this->_listChildrenIds[$product->getId()] !=''){
650
+ $data['name'] = $this->_helper->cleanData($this->_listChildrenIds[$product->getId()]['name'], $formatData, in_array('name', $this->_config['attribute_html']));
651
+ }else{
652
+ $data['name'] = $this->_helper->cleanData($product->getName(), $formatData, in_array('name', $this->_config['attribute_html']));
653
+ }
654
+ }else{
655
+ $data['name'] = $this->_helper->cleanData($product->getName(), $formatData, in_array('name', $this->_config['attribute_html']));
656
+ }
657
+ break;
658
+ case 'description':
659
+ $data['description'] = $this->_helper->cleanData($product->getDescription(), $formatData, in_array('description', $this->_config['attribute_html']));
660
+ break;
661
+ case 'short_description':
662
+ $data['short_description'] = $this->_helper->cleanData($product->getShortDescription(), $formatData, in_array('short_description', $this->_config['attribute_html']));
663
+ break;
664
+ case 'parent_informations':
665
+ if (isset($this->_listChildrenIds[$product->getId()])){
666
+ $data['parent_id'] = $this->_listChildrenIds[$product->getId()]['id'];
667
+ $data['product_type'] = 'child';
668
+ $data['child_name'] = $this->_listChildrenIds[$product->getId()]['name'];
669
+ if (isset($this->_listConfigurableVariation[$this->_listChildrenIds[$product->getId()]['id']])){
670
+ $variation = array();
671
+ foreach($this->_listConfigurableVariation[$this->_listChildrenIds[$product->getId()]['id']] as $variationAttributeId){
672
+ $variation[] = $this->_listCodeAttributes[$variationAttributeId]['frontend_label'];
673
+ }
674
+ $data['product_variation'] = join(',', $variation);
675
+ }else{
676
+ $data['product_variation'] = '';
677
+ }
678
+ }else{
679
+ if (isset($this->_listParentIds[$product->getId()])){
680
+ $data['parent_id'] = '';
681
+ $data['product_type'] = 'parent';
682
+ $data['child_name'] = $product->getName();
683
+ if (isset($this->_listConfigurableVariation[$product->getId()])){
684
+ $variation = array();
685
+ foreach($this->_listConfigurableVariation[$product->getId()] as $variationAttributeId){
686
+ $variation[] = $this->_listCodeAttributes[$variationAttributeId]['frontend_label'];
687
+ }
688
+ $data['product_variation'] = join(',', $variation);
689
+ }else{
690
+ $data['product_variation'] = '';
691
+ }
692
+ }else{
693
+ $data['parent_id'] = '';
694
+ $data['product_type'] = 'simple';
695
+ $data['child_name'] = $product->getName();
696
+ $data['product_variation'] = '';
697
+ }
698
+ }
699
+ break;
700
+ }
701
+ }
702
+ foreach($this->_attributesAdditional as $attributeCode){
703
+ if (!isset($data[$attributeCode])) {
704
+ if (!in_array($attributeCode, $this->_listForbiddenAttributes)) {
705
+ if (in_array($this->_listCodeAttributes[$this->_listAttributeCode[$attributeCode]]['backend_type'], array('text','varchar'))){
706
+ $data[$attributeCode] = $this->_helper->cleanData($this->_getAttributeValue($product->getId(), $attributeCode), $formatData, in_array($attributeCode, $this->_config['attribute_html']));
707
+ }else{
708
+ $data[$attributeCode] = $this->_getAttributeValue($product->getId(), $attributeCode);
709
+ }
710
+ } else {
711
+ $data[$attributeCode] = '';
712
+ }
713
+ }
714
+ }
715
+ //print_r($data);
716
+
717
+ if ($pi >= $nbProduct)
718
+ $this->_write($feed->makeData($data, array('last' => true)));
719
+ else
720
+ $this->_write($feed->makeData($data));
721
+
722
+ unset($data);
723
+ }
724
+ }
725
+
726
+ $this->_write($feed->makeFooter());
727
+ if(!$this->_stream) {
728
+ flush();
729
+ $this->_copyFile();
730
+ $store_code = Mage::app()->getStore($this->_id_store)->getCode();
731
+ $url_file = Mage::getBaseUrl(Mage_Core_Model_Store::URL_TYPE_MEDIA) . 'lengow' . DS . $store_code . DS . $this->_fileName . '.' . $this->_fileFormat;
732
+ $this->_log($this->_helper->__('Your feed is available here : %s' , '<a href=\'' . $url_file . '\'>' . $url_file . '</a>'));
733
+ Mage::helper('lensync/data')->log('Export of the store ' . Mage::app()->getStore($this->_id_store)->getName() . '(' . $this->_id_store . ') generated a file here : ' . $url_file);
734
+ }
735
+
736
+ }
737
+
738
+
739
+ protected function _buildCsvHeader(){
740
+
741
+ $tmpHeader = $this->_listHeaderCsvFile;
742
+ $this->_listHeaderCsvFile = array();
743
+ foreach($tmpHeader as $header){
744
+ switch($header){
745
+ case 'lengow_categories_header':
746
+ $this->_listHeaderCsvFile[] = 'category';
747
+ $this->_listHeaderCsvFile[] = 'category-url';
748
+ for ($j = 1; $j <= $this->_config['category_max_level']; ++$j) {
749
+ $this->_listHeaderCsvFile[] = 'category-sub-'.$j;
750
+ $this->_listHeaderCsvFile[] = 'category-url-sub-'.$j;
751
+ }
752
+ $this->_listHeaderCsvFile[] = 'category_breadcrumb';
753
+ break;
754
+ case 'lengow_images_header':
755
+ $max_image = $this->_config_model->getCountExportImages();
756
+ for($i = 1; $i <= $max_image; ++$i) {
757
+ $this->_listHeaderCsvFile[]= 'image-url-'.$i;
758
+ }
759
+ break;
760
+ default:
761
+ $this->_listHeaderCsvFile[] = $header;
762
+ break;
763
+ }
764
+ }
765
+ foreach($this->_attributesAdditional as $header){
766
+ $this->_listHeaderCsvFile[] = $header;
767
+ }
768
+
769
+ }
770
+
771
+
772
+ /**
773
+ * Set stock on query
774
+ * @param object $productCollection
775
+ *
776
+ * @return object $productCollection
777
+ */
778
+
779
+ protected function _joinStock($productCollection){
780
+ if (!$this->_config['out_of_stock']) {
781
+ $conditions = ' AND ((stock.is_in_stock = 1) '
782
+ . ' OR (IF(stock.use_config_manage_stock = 1,
783
+ ' . (int)Mage::getStoreConfigFlag(Mage_CatalogInventory_Model_Stock_Item::XML_PATH_MANAGE_STOCK) . ',
784
+ stock.manage_stock) = 0)) AND is_in_stock IS NOT NULL';
785
+
786
+ $productCollection->getSelect()->join($this->_table['cataloginventory_stock_item'] . ' AS stock', 'stock.product_id=e.entity_id ' . $conditions, array(
787
+ 'qty' => 'qty',
788
+ 'is_in_stock' => 'is_in_stock',
789
+ 'manage_stock' => 'manage_stock',
790
+ 'use_config_manage_stock' => 'use_config_manage_stock',
791
+ 'backorders' => 'backorders',
792
+ 'use_config_backorders' => 'use_config_backorders'
793
+ ));
794
+ }else{
795
+ $productCollection->getSelect()->joinLeft($this->_table['cataloginventory_stock_item'] . ' AS stock', 'stock.product_id=e.entity_id ', array(
796
+ 'qty' => 'qty',
797
+ 'is_in_stock' => 'is_in_stock',
798
+ 'manage_stock' => 'manage_stock',
799
+ 'use_config_manage_stock' => 'use_config_manage_stock',
800
+ 'backorders' => 'backorders',
801
+ 'use_config_backorders' => 'use_config_backorders'
802
+ ));
803
+ }
804
+ return $productCollection;
805
+ }
806
+
807
+ /**
808
+ * Load image of all entities
809
+ *
810
+ * @return void
811
+ */
812
+
813
+ protected function _loadImages(){
814
+
815
+ $connection = $this->_coreResource->getConnection('core_read');
816
+
817
+ $query = $connection->select(array('DISTINCT value'));
818
+ $query->from($this->_table['catalog_product_entity_media_gallery']);
819
+ $query->joinleft(array('cpemgv' => $this->_table['catalog_product_entity_media_gallery_value']),
820
+ 'cpemgv.value_id = ' . $this->_table['catalog_product_entity_media_gallery'] . '.value_id',
821
+ array('cpemgv.position', 'cpemgv.disabled'));
822
+ $query->where('value<>TRIM(\'\') AND (store_id=' . $this->_id_store . ' OR store_id=0)');
823
+ $query->order(array('position', 'value_id'));
824
+ $query->group(array('value_id'));
825
+ $rows = $connection->fetchAll($query);
826
+ $this->_listImages = array();
827
+ foreach ($rows as $row) {
828
+ if ($row['disabled'] != 1 && $row['value'] != '') {
829
+ $this->_listImages[$row['entity_id']][] = array('src' => $row['value'], 'disabled' => $row['disabled']) ;
830
+ }
831
+ }
832
+
833
+ if ($this->_debug){
834
+ $this->_log('Load Images ('.count($this->_listImages).')');
835
+ //print_r($this->_listImages);
836
+ }
837
+ }
838
+
839
+ /**
840
+ * Load all categories
841
+ *
842
+ * @return void
843
+ */
844
+
845
+ protected function _loadCategories(){
846
+ $categories = Mage::getModel('catalog/category')->getCollection()
847
+ ->setStoreId($this->_id_store)
848
+ ->addAttributeToSelect('name','store_id')
849
+ ->addAttributeToSelect('is_active')
850
+ ->addAttributeToSelect('include_in_menu');
851
+ $this->_listCategories = array();
852
+ foreach ($categories as $category) {
853
+ $this->_listCategories[$category->getId()]['name'] = $category->getName();
854
+ $this->_listCategories[$category->getId()]['path'] = $category->getPath();
855
+ $this->_listCategories[$category->getId()]['level'] = $category->getLevel();
856
+ $this->_listCategories[$category->getId()]['url'] = $category->getUrl();
857
+ }
858
+
859
+ if ($this->_debug){
860
+ $this->_log('Load Categories ('.count($this->_listCategories).')');
861
+ //print_r($this->_listCategories);
862
+ }
863
+ }
864
+
865
+ /**
866
+ * Load important information of grouped products :
867
+ * - status
868
+ * - quantity
869
+ *
870
+ * @return void
871
+ */
872
+
873
+ protected function _loadGroupedProducts(){
874
+
875
+ $productCollection = Mage::getModel('lenexport/product_collection')->getCollection()->addStoreFilter($this->_id_store);
876
+ $productCollection->addAttributeToFilter('type_id', array('in' => 'grouped'));
877
+ $productCollection->addAttributeToSelect('name','product_url');
878
+ if ($this->_config['product_status'] !== null){
879
+ $productCollection->addAttributeToFilter('status', array('eq' => $this->_config['product_status']));
880
+ }
881
+ $productCollection->getSelect()->joinLeft($this->_table['catalog_product_link'] . ' AS cpl',
882
+ 'cpl.product_id=e.entity_id AND cpl.link_type_id=3',
883
+ array('child_ids' => 'GROUP_CONCAT( cpl.linked_product_id)'));
884
+ $productCollection->getSelect()->joinLeft($this->_table['cataloginventory_stock_item'] . ' AS stock',
885
+ 'stock.product_id=cpl.linked_product_id',
886
+ array('child_qtys' => 'GROUP_CONCAT( qty)'));
887
+ $productCollection->getSelect()->joinLeft($this->_table['catalog_product_entity_int'] . ' AS entity_int',
888
+ 'entity_int.entity_id=cpl.linked_product_id AND entity_int.attribute_id ='.$this->_attributeStatusId ,
889
+ array('child_status' => 'GROUP_CONCAT( entity_int.value)'));
890
+ $productCollection->getSelect()->joinLeft($this->_table['catalog_product_index_price'] . ' AS price_index',
891
+ 'price_index.entity_id=cpl.linked_product_id AND customer_group_id=0 AND price_index.website_id=' . $this->_websiteId,
892
+ array('child_prices' => 'GROUP_CONCAT( final_price )'));
893
+ $productCollection->getSelect()->joinLeft($this->_table['catalog_category_product'] . ' AS categories', 'categories.product_id=e.entity_id');
894
+ $productCollection->getSelect()->joinLeft($this->_table['catalog_category_product_index'] . ' AS categories_index',
895
+ '((categories_index.category_id=categories.category_id AND categories_index.product_id=categories.product_id) ) AND categories_index.store_id=' . $this->_id_store,
896
+ array('categories_ids' => 'GROUP_CONCAT(DISTINCT categories_index.category_id)'));
897
+ $productCollection->getSelect()->group(array('cpl.product_id'));
898
+
899
+
900
+ $this->_listGroupedProducts = array();
901
+ foreach ($productCollection as $product) {
902
+ $quantities = array();
903
+ $status = true;
904
+ $totalPrice = 0;
905
+ $this->_listParentIds[$product->getId()] = true;
906
+ foreach (explode(',', $product->getChildIds()) as $id) {
907
+ $this->_listChildrenIds[$id] = array(
908
+ 'name' => $product->getName(),
909
+ 'id' => $product->getId(),
910
+ 'categories_id' => $product->getCategoriesIds(),
911
+ 'url' => '',//$product->getProductUrl()
912
+ );
913
+ }
914
+ foreach (explode(',', $product->getChildQtys()) as $qty) {
915
+ $quantities[] = $qty >= 0 ? $qty : 0;
916
+ }
917
+ foreach (explode(',', $product->getChildStatus()) as $status) {
918
+ if ($status==0){ $status = false; break; }
919
+ }
920
+ foreach (explode(',', $product->getChildPrices()) as $price) {
921
+ $totalPrice+=$price;
922
+ }
923
+ //keep the minimum quantity of product
924
+ $this->_listGroupedProducts[$product->getId()]['qty'] = min($quantities);
925
+ $this->_listGroupedProducts[$product->getId()]['status'] = $status;
926
+ $this->_listGroupedProducts[$product->getId()]['price'] = $totalPrice;
927
+ }
928
+
929
+ if ($this->_debug){
930
+ $this->_log('Load Grouped ('.count($this->_listGroupedProducts).')');
931
+ //print_r($this->_listGroupedProducts);
932
+ //print_r($this->_listParentIds);
933
+ }
934
+ }
935
+
936
+ /**
937
+ * Load grouped products
938
+ * - keep parent and children
939
+ *
940
+ * @return void
941
+ */
942
+
943
+ protected function _loadConfigurableProducts(){
944
+
945
+ $connection = $this->_coreResource->getConnection('core_read');
946
+ $query = 'SELECT * FROM '.$this->_table['catalog_product_super_attribute'];
947
+
948
+ $configurableAttributeCollection = $connection->fetchAll($query);
949
+ foreach($configurableAttributeCollection as $sa){
950
+ $this->_listConfigurableVariation[$sa['product_id']][] = $sa['attribute_id'];
951
+ }
952
+
953
+ $productCollection = Mage::getModel('lenexport/product_collection')->getCollection()->addStoreFilter($this->_id_store);
954
+ $productCollection->addAttributeToFilter('type_id', array('in' => 'configurable'));
955
+ $productCollection->addAttributeToSelect('name');
956
+ if ($this->_config['product_status'] !== null){
957
+ $productCollection->addAttributeToFilter('status', array('eq' => $this->_config['product_status']));
958
+ }
959
+ $productCollection->getSelect()->joinLeft($this->_table['catalog_product_super_link'] . ' AS sl',
960
+ 'sl.parent_id=e.entity_id',
961
+ array('child_ids' => 'GROUP_CONCAT( sl.product_id)'));
962
+ $productCollection->getSelect()->joinLeft($this->_table['catalog_product_entity_int'] . ' AS entity_int',
963
+ 'sl.parent_id=entity_int.entity_id AND entity_int.attribute_id = '.$this->_attributeStatusId,
964
+ array('child_statuses' => 'GROUP_CONCAT( entity_int.value)'));
965
+ $productCollection->getSelect()->joinLeft($this->_table['catalog_category_product'] . ' AS categories', 'categories.product_id=e.entity_id');
966
+ $productCollection->getSelect()->joinLeft($this->_table['catalog_category_product_index'] . ' AS categories_index',
967
+ '((categories_index.category_id=categories.category_id AND categories_index.product_id=categories.product_id) ) AND categories_index.store_id=' . $this->_id_store,
968
+ array('categories_ids' => 'GROUP_CONCAT(DISTINCT categories_index.category_id)'));
969
+
970
+ $productCollection->getSelect()->joinLeft($this->_table['core_url_rewrite'] . ' AS url',
971
+ 'url.product_id=e.entity_id AND url.target_path NOT LIKE "category%" AND is_system=1 AND ' . $this->_config["query_url_option"] . ' AND url.store_id=' . $this->_id_store,
972
+ array('request_path' => 'MAX(DISTINCT request_path)'));
973
+
974
+ $productCollection->getSelect()->group(array('sl.parent_id'));
975
+
976
+ foreach ($productCollection as $product) {
977
+ $this->_listParentIds[$product->getId()] = true;
978
+ $name = $product->getName();
979
+ $categoriesId = $product->getCategoriesIds();
980
+ $url = $product->getProductUrl();
981
+
982
+ foreach (explode(',', $product->getChildIds()) as $id) {
983
+ $this->_listChildrenIds[$id] = array(
984
+ 'name' => $name,
985
+ 'id' => $product->getId(),
986
+ 'categories_id' => $categoriesId,
987
+ 'url' => $url,
988
+ );
989
+ // foreach (explode(',', $product->getPrice()) as $price) {
990
+ // $this->_listChildrenIds[$id]['price'] = $price;
991
+ // break;
992
+ // }
993
+ // foreach (explode(',', $product->getFinalPrice()) as $price) {
994
+ // $this->_listChildrenIds[$id]['final_price'] = $price;
995
+ // break;
996
+ // }
997
+ }
998
+ }
999
+
1000
+ if ($this->_debug){
1001
+ $this->_log('Load Configurable');
1002
+ //print_r($this->_listParentIds);
1003
+ //print_r($this->_listChildrenIds);
1004
+ }
1005
+ }
1006
+
1007
+ /**
1008
+ * Load Taxes
1009
+ *
1010
+ * build array _listTaxes[tax_class_id][0]['rate'|'code'|'country']
1011
+ *
1012
+ * @return void
1013
+ */
1014
+
1015
+ protected function _loadTaxes(){
1016
+
1017
+
1018
+ $taxCalculation = Mage::getModel('tax/calculation');
1019
+ $request = $taxCalculation->getRateRequest(null, null, null, $this->_id_store);
1020
+
1021
+ $connection = $this->_coreResource->getConnection('core_read');
1022
+
1023
+ $query = $connection->select();
1024
+ $query->from($this->_table['tax_class'])->order(array('class_id', 'tax_calculation_rate_id'));
1025
+ $query->joinleft(array('tc' => $this->_table['tax_calculation']), 'tc.product_tax_class_id = ' . $this->_table['tax_class']. '.class_id',
1026
+ 'tc.tax_calculation_rate_id');
1027
+ $query->joinleft(array('tcr' => $this->_table['tax_calculation_rate']), 'tcr.tax_calculation_rate_id = tc.tax_calculation_rate_id',
1028
+ array('tcr.rate', 'tax_country_id', 'tax_region_id'));
1029
+ $query->joinleft(array('dcr' => $this->_table['directory_country_region']), 'dcr.region_id=tcr.tax_region_id', 'code');
1030
+ $query->joinInner(array('cg' => $this->_table['customer_group']),
1031
+ 'cg.tax_class_id=tc.customer_tax_class_id AND cg.customer_group_code=\'NOT LOGGED IN\'');
1032
+ $taxCollection = $connection->fetchAll($query);
1033
+ $this->_listTaxes = array();
1034
+ $tempClassId = '';
1035
+ $classValue = 0;
1036
+ foreach ($taxCollection as $tax) {
1037
+ if ($tempClassId != $tax['class_id']) {
1038
+ $classValue = 0;
1039
+ } else {
1040
+ ++$classValue;
1041
+ }
1042
+ $tempClassId = $tax['class_id'];
1043
+ if ($request['country_id'] == $tax['tax_country_id']){
1044
+ $this->_listTaxes[$tax['class_id']] = $tax['rate'];
1045
+ //$this->_listTaxes[$tax['class_id']][$classValue]['code'] = $tax['code'];
1046
+ //$this->_listTaxes[$tax['class_id']][$classValue]['country'] = $tax['tax_country_id'];
1047
+ }
1048
+ }
1049
+ if ($this->_debug){
1050
+ $this->_log('Load Tax Class ('.count($this->_listTaxes).')');
1051
+ //print_r($this->_listTaxes);
1052
+ }
1053
+
1054
+ if (count($this->_listTaxes)==0){
1055
+ Mage::helper('lensync/data')->log('Tax configuration is not correct, please enable country : '.$request['country_id']);
1056
+ }
1057
+ }
1058
+
1059
+ /**
1060
+ * Load additional attributes
1061
+ * check if already exist
1062
+ *
1063
+ * @return void
1064
+ */
1065
+
1066
+ protected function _loadSelectedAttributes(){
1067
+ $attributeToExport = $this->_config_model->getMappingAllAttributes($this->_id_store);
1068
+
1069
+ foreach($attributeToExport as $key => $value){
1070
+ if ($key == 'none') { continue; }
1071
+ if (!in_array($key, $this->_attributes)){
1072
+ $this->_attributesAdditional[] = $key;
1073
+ }
1074
+ }
1075
+
1076
+ if ($this->_debug){
1077
+ $this->_log('Load New Attributes ('.count($attributeToExport).')');
1078
+ //print_r($this->_attributes);
1079
+ }
1080
+
1081
+ }
1082
+
1083
+ /**
1084
+ * Load attributes information
1085
+ * - attribute_id
1086
+ * - backend_type
1087
+ * - attribute_code
1088
+ * - frontend_input
1089
+ * - frontend_label
1090
+ *
1091
+ * build array _listCodeAttributes[attribute_id]['attribute_id'|'backend_type'|'attribute_code'|'frontend_input'|'frontend_label']
1092
+ *
1093
+ * @return void
1094
+ */
1095
+
1096
+ protected function _loadProductAttributes(){
1097
+
1098
+ $attributeCollection = Mage::getResourceModel('eav/entity_attribute_collection')
1099
+ ->setEntityTypeFilter($this->_catalogProductEntityId)
1100
+ ->addSetInfo()
1101
+ ->getData();
1102
+ $listAttributes = array();
1103
+ foreach ($attributeCollection as $attribute) {
1104
+ $listAttributes[] = $attribute['attribute_code'];
1105
+ $this->_listAttributeCode[$attribute['attribute_code']] = $attribute['attribute_id'];
1106
+ $this->_listCodeAttributes[$attribute['attribute_id']]['attribute_id'] = $attribute['attribute_id'];
1107
+ $this->_listCodeAttributes[$attribute['attribute_id']]['backend_type'] = $attribute['backend_type'];
1108
+ $this->_listCodeAttributes[$attribute['attribute_id']]['attribute_code'] = $attribute['attribute_code'];
1109
+ $this->_listCodeAttributes[$attribute['attribute_id']]['frontend_input'] = $attribute['frontend_input'];
1110
+ $this->_listCodeAttributes[$attribute['attribute_id']]['frontend_label'] = $attribute['frontend_label'];
1111
+ }
1112
+
1113
+ $findDiff = array_diff($this->_attributes, $listAttributes);
1114
+ $this->_attributes = array_diff($this->_attributes, $findDiff);
1115
+ if ($this->_debug){
1116
+ $this->_log('Load Attributes ('.count($this->_listCodeAttributes).')');
1117
+ //print_r($this->_listCodeAttributes);
1118
+ }
1119
+ }
1120
+
1121
+ /**
1122
+ * Load option values
1123
+ *
1124
+ * build array _listOptionValues[attribute_id][option_id] = value
1125
+ *
1126
+ * @return void
1127
+ */
1128
+
1129
+ protected function _loadOptionValues(){
1130
+ $attributeIdToQuery = array();
1131
+ foreach($this->_listCodeAttributes as $codeAttribute){
1132
+ if ( in_array($codeAttribute['frontend_input'], array('select','multiselect') )){
1133
+ $attributeIdToQuery[] = $codeAttribute['attribute_id'];
1134
+ }
1135
+ }
1136
+
1137
+ if (count($attributeIdToQuery)){
1138
+ $connection = $this->_coreResource->getConnection('core_read');
1139
+ $query = 'SELECT * FROM '.$this->_table['eav_attribute_option'].' eavo
1140
+ LEFT JOIN '.$this->_table['eav_attribute_option_value'].' eavov ON ( eavo.option_id = eavov.option_id )
1141
+ WHERE eavo.attribute_id IN ('.join(',',$attributeIdToQuery).') AND eavov.store_id = 0';
1142
+ $entityOptionValueCollection = $connection->fetchAll($query);
1143
+ foreach($entityOptionValueCollection as $optionValue){
1144
+ $this->_listOptionValues[$optionValue['attribute_id']][$optionValue['option_id']] = $optionValue['value'];
1145
+ }
1146
+
1147
+ $connection = $this->_coreResource->getConnection('core_read');
1148
+ $query = 'SELECT * FROM '.$this->_table['eav_attribute_option'].' eavo
1149
+ LEFT JOIN '.$this->_table['eav_attribute_option_value'].' eavov ON ( eavo.option_id = eavov.option_id )
1150
+ WHERE eavo.attribute_id IN ('.join(',',$attributeIdToQuery).') AND eavov.store_id = '.$this->_id_store;
1151
+ $entityOptionValueCollection = $connection->fetchAll($query);
1152
+ foreach($entityOptionValueCollection as $optionValue){
1153
+ $this->_listOptionValues[$optionValue['attribute_id']][$optionValue['option_id']] = $optionValue['value'];
1154
+ }
1155
+ }
1156
+
1157
+ if ($this->_debug){
1158
+ $this->_log('Load Option Values ('.count($this->_listOptionValues).')');
1159
+ //print_r($this->_listOptionValues);
1160
+ }
1161
+ }
1162
+
1163
+ /**
1164
+ * Load attributes values for all entities
1165
+ *
1166
+ * (int|varchar|text|decimal|datetime)
1167
+ *
1168
+ * @return void
1169
+ */
1170
+
1171
+ protected function _loadProductAttributeValues(){
1172
+
1173
+ $this->_loadOptionValues();
1174
+ $this->_loadAttributeValuesByType('int', $this->_table['catalog_product_entity_int']);
1175
+ $this->_loadAttributeValuesByType('varchar', $this->_table['catalog_product_entity_varchar']);
1176
+ $this->_loadAttributeValuesByType('datetime', $this->_table['catalog_product_entity_datetime']);
1177
+ $this->_loadAttributeValuesByType('text', $this->_table['catalog_product_entity_text']);
1178
+ $this->_loadAttributeValuesByType('decimal', $this->_table['catalog_product_entity_decimal']);
1179
+
1180
+ if ($this->_debug){
1181
+ $this->_log('Load Attributes Values ('.count($this->_listAttributeValues).')');
1182
+ //print_r($this->_listCodeAttributes);
1183
+ }
1184
+
1185
+ }
1186
+
1187
+ /**
1188
+ * Load attributes values for all entities by type
1189
+ *
1190
+ * @param string $type Entity Type (int/varchar/text/decimal/float)
1191
+ * @param string $tableName Table Name by Entity Type
1192
+ *
1193
+ * @return void
1194
+ */
1195
+
1196
+ protected function _loadAttributeValuesByType($type, $tableName){
1197
+ $connection = $this->_coreResource->getConnection('core_read');
1198
+
1199
+ $attributeIdToQuery = array();
1200
+ foreach($this->_listCodeAttributes as $codeAttribute){
1201
+ if ($codeAttribute['backend_type'] == $type){
1202
+ //load only selected attributes
1203
+ if (in_array($codeAttribute['attribute_code'], $this->_attributesAdditional)){
1204
+ $attributeIdToQuery[] = $codeAttribute['attribute_id'];
1205
+ }
1206
+ }
1207
+ }
1208
+
1209
+ if ($this->_config['product_ids']){
1210
+ $sqlWhere = ' AND entity_id IN ('.$this->_config['product_ids'].') ';
1211
+ }else{
1212
+ $sqlWhere = '';
1213
+ }
1214
+
1215
+ if (count($attributeIdToQuery)>0){
1216
+ $query = 'SELECT attribute_id, value, entity_id FROM '.$tableName.' WHERE attribute_id IN ('.join(',',$attributeIdToQuery).') AND store_id = 0 '.$sqlWhere;
1217
+ $entityIntCollection = $connection->fetchAll($query);
1218
+ foreach($entityIntCollection as $int){
1219
+ if ($int['value']==''){
1220
+ $this->_listAttributeValues[$int['entity_id']][$this->_listCodeAttributes[$int['attribute_id']]['attribute_code']] = '';
1221
+ }else{
1222
+ if ($this->_listCodeAttributes[$int['attribute_id']]['frontend_input'] == 'select' && $this->_listCodeAttributes[$int['attribute_id']]['backend_type'] == 'int'){
1223
+ if (isset($this->_listOptionValues[$int['attribute_id']][$int['value']])){
1224
+ $this->_listAttributeValues[$int['entity_id']][$this->_listCodeAttributes[$int['attribute_id']]['attribute_code']] = $this->_listOptionValues[$int['attribute_id']][$int['value']] ;
1225
+ }else{
1226
+ $this->_listAttributeValues[$int['entity_id']][$this->_listCodeAttributes[$int['attribute_id']]['attribute_code']] = $int['value'];
1227
+ }
1228
+ }else{
1229
+ $this->_listAttributeValues[$int['entity_id']][$this->_listCodeAttributes[$int['attribute_id']]['attribute_code']] = $int['value'];
1230
+ }
1231
+ }
1232
+ }
1233
+ $query = 'SELECT attribute_id, value, entity_id FROM '.$tableName.' WHERE attribute_id IN ('.join(',',$attributeIdToQuery).') AND store_id = '.$this->_id_store.' '.$sqlWhere;
1234
+ $entityIntCollection = $connection->fetchAll($query);
1235
+ foreach($entityIntCollection as $int){
1236
+ if ($int['value']==''){
1237
+ $this->_listAttributeValues[$int['entity_id']][$this->_listCodeAttributes[$int['attribute_id']]['attribute_code']] = '';
1238
+ }else{
1239
+ if ($this->_listCodeAttributes[$int['attribute_id']]['frontend_input'] == 'select' && $this->_listCodeAttributes[$int['attribute_id']]['backend_type'] == 'int'){
1240
+ if (isset($this->_listOptionValues[$int['attribute_id']][$int['value']])){
1241
+ $this->_listAttributeValues[$int['entity_id']][$this->_listCodeAttributes[$int['attribute_id']]['attribute_code']] = $this->_listOptionValues[$int['attribute_id']][$int['value']] ;
1242
+ }else{
1243
+ $this->_listAttributeValues[$int['entity_id']][$this->_listCodeAttributes[$int['attribute_id']]['attribute_code']] = $int['value'];
1244
+ }
1245
+ }else{
1246
+ $this->_listAttributeValues[$int['entity_id']][$this->_listCodeAttributes[$int['attribute_id']]['attribute_code']] = $int['value'];
1247
+ }
1248
+ }
1249
+ }
1250
+ }
1251
+
1252
+ if ($this->_debug){
1253
+ $this->_log('Load Attributes Values '.$type.' ('.count($this->_listAttributeValues).')');
1254
+ //print_r($this->_listAttributeValues);
1255
+ }
1256
+
1257
+ }
1258
+
1259
+ /**
1260
+ * Calculate price with Taxes
1261
+ *
1262
+ * @param float $price Price
1263
+ * @param integer $taxClassId Tax Class Id
1264
+ *
1265
+ * @return float price
1266
+ */
1267
+
1268
+ protected function _calculatePrice($price, $taxClassId){
1269
+ $currentRate = $this->_listTaxes;
1270
+ if (!$this->_config['include_tax'] && isset($currentRate[$taxClassId])) {
1271
+ if (count($currentRate[$taxClassId]) > 1) {
1272
+ return round($price,2);
1273
+ } else {
1274
+ return round($price * ($currentRate[$taxClassId] / 100 + 1),2);
1275
+ }
1276
+ } else {
1277
+ return round($price,2);
1278
+ }
1279
+ }
1280
+
1281
+ /**
1282
+ * Get Store attribute value
1283
+ *
1284
+ * @param integer $productId Id Product
1285
+ * @param varchar $attributeCode Attribute Code
1286
+ *
1287
+ * @return float price
1288
+ */
1289
+
1290
+ protected function _getAttributeValue($productId,$attributeCode){
1291
+ if (isset($this->_listAttributeValues[$productId]) && isset($this->_listAttributeValues[$productId][$attributeCode])){
1292
+ return $this->_listAttributeValues[$productId][$attributeCode];
1293
+ }else{
1294
+ return '';
1295
+ }
1296
+ }
1297
+
1298
+ /**
1299
+ * File generation
1300
+ *
1301
+ * @param array $data
1302
+ */
1303
+ protected function _write($data)
1304
+ {
1305
+ if($this->_stream == false) {
1306
+ if(!$this->_file) {
1307
+ $this->_initFile();
1308
+ }
1309
+ $this->_file->streamLock();
1310
+ $this->_file->streamWrite($data);
1311
+ $this->_file->streamUnlock();
1312
+ } else {
1313
+ echo $data;
1314
+ }
1315
+ }
1316
+
1317
+ /**
1318
+ * Create File for export
1319
+ */
1320
+ protected function _initFile()
1321
+ {
1322
+ if (!$this->_createDirectory()){ exit(); }
1323
+
1324
+ $this->_fileTimeStamp = time();
1325
+ $this->_file = new Varien_Io_File;
1326
+ $this->_file->cd($this->_config['directory_path']);
1327
+ $this->_file->streamOpen($this->_fileName . '.' . $this->_fileTimeStamp . '.' . $this->_fileFormat, 'w+');
1328
+ }
1329
+
1330
+ protected function _createDirectory(){
1331
+ try {
1332
+ $file = new Varien_Io_File;
1333
+ $file->checkAndCreateFolder($this->_config['directory_path']);
1334
+ } catch (Exception $e) {
1335
+ Mage::helper('lensync/data')->log('can\'t create folder '.$this->_config['directory_path'].'');
1336
+ if ($this->_debug){
1337
+ $this->_log('can\'t create folder '.$this->_config['directory_path']);
1338
+ }
1339
+ return false;
1340
+ }
1341
+ return true;
1342
+ }
1343
+
1344
+ /**
1345
+ * Copies the file to the correct folder
1346
+ */
1347
+ protected function _copyFile()
1348
+ {
1349
+ $file_path = $this->_config['directory_path'];
1350
+ copy($file_path . $this->_fileName . '.' . $this->_fileTimeStamp . '.' . $this->_fileFormat, $file_path . $this->_fileName . '.' . $this->_fileFormat);
1351
+ unlink($file_path . $this->_fileName . '.' . $this->_fileTimeStamp . '.' . $this->_fileFormat);
1352
+ }
1353
+
1354
+ /**
1355
+ * get current microtime float
1356
+ *
1357
+ * @return float
1358
+ */
1359
+ protected function microtime_float()
1360
+ {
1361
+ list($usec, $sec) = explode(' ', microtime());
1362
+ return ((float)$usec + (float)$sec);
1363
+ }
1364
+
1365
+ /**
1366
+ * Display log time + title
1367
+ *
1368
+ * @param float $timeStart
1369
+ * @param string $title
1370
+ *
1371
+ * @return void
1372
+ */
1373
+ protected function _stop($timeStart, $title){
1374
+ $time_end = $this->microtime_float();
1375
+ $time = $time_end - $timeStart;
1376
+ if ($time<0.0001){ $time = 0;}
1377
+ echo round($time,4).' &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; '.$title.' secondes <br/>';
1378
+ }
1379
+
1380
+ /**
1381
+ * Display log time + title
1382
+ *
1383
+ * @param string $title
1384
+ *
1385
+ * @return void
1386
+ */
1387
+ protected function _log($title){
1388
+ if($this->_stream){ return;}
1389
+ $time_end = $this->microtime_float();
1390
+ $time = $time_end - $this->_startScript;
1391
+
1392
+ echo date('Y-m-d h:i:s').'|'.str_pad(sprintf('%0.4f', round($time,4)),10,'0',STR_PAD_LEFT).' '.str_pad($title, 40, '=', STR_PAD_BOTH).'<br/>';
1393
+ }
1394
+
1395
+ /**
1396
+ * Is Feed Already Launch
1397
+ *
1398
+ * @return boolean
1399
+ */
1400
+ protected function _isAlreadyLaunch(){
1401
+
1402
+ $directory = $this->_config['directory_path'];
1403
+ if (!$this->_createDirectory()){
1404
+ exit();
1405
+ }
1406
+
1407
+ try {
1408
+ $listFiles = array_diff(scandir($directory), array('..', '.'));
1409
+ } catch (Exception $e) {
1410
+ Mage::helper('lensync/data')->log('Can\'t access folder '.$this->_config['directory_path']);
1411
+ if ($this->_debug){
1412
+ $this->_log('Can\'t access folder '.$this->_config['directory_path']);
1413
+ }
1414
+ exit();
1415
+ }
1416
+ foreach ($listFiles as $file) {
1417
+ if (preg_match('/^' . $this->_fileName . '\.[\d]{10}/', $file)) {
1418
+ $fileModified = date('Y-m-d H:i:s', filemtime($directory . $file));
1419
+ $fileModifiedDatetime = new DateTime($fileModified);
1420
+ $fileModifiedDatetime->add(new DateInterval('P10D'));
1421
+
1422
+ if (date('Y-m-d') > $fileModifiedDatetime->format('Y-m-d')) {
1423
+ unlink($directory . $file);
1424
+ }
1425
+
1426
+ $fileModifiedDatetime = new DateTime($fileModified);
1427
+ $fileModifiedDatetime->add(new DateInterval('PT20S'));
1428
+ if (date('Y-m-d H:i:s') < $fileModifiedDatetime->format('Y-m-d H:i:s')) {
1429
+ return true;
1430
+ }
1431
+ }
1432
+ }
1433
+ return false;
1434
+ }
1435
+
1436
+ }
app/code/community/Lengow/Export/Model/Observer.php CHANGED
@@ -5,8 +5,8 @@
5
  *
6
  * @category Lengow
7
  * @package Lengow_Export
8
- * @author Ludovic Drin <ludovic@lengow.com> & Benjamin Le Nevé <benjamin.le-neve@lengow.com>
9
- * @copyright 2015 Lengow SAS
10
  * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
11
  */
12
  class Lengow_Export_Model_Observer {
@@ -16,30 +16,42 @@ class Lengow_Export_Model_Observer {
16
  */
17
  public function export($observer)
18
  {
19
- if(Mage::getStoreConfig('lenexport/performances/active_cron')) {
20
  // clean old log (20 days)
21
  Mage::helper('lensync/data')->cleanLog();
22
  Mage::helper('lensync/data')->log('## Start cron export ##');
23
  set_time_limit(0);
24
  ini_set('memory_limit', '1G');
25
- $store_collection = Mage::getResourceModel('core/store_collection')
26
- ->addFieldToFilter('is_active', 1);
27
  $exceptions = array();
28
  foreach($store_collection as $store) {
29
  try {
30
- if(Mage::getStoreConfig('lenexport/global/active_store', $store)) {
31
  Mage::helper('lensync/data')->log('Start cron export in Store ' . $store->getName() . '(' . $store->getId() . ')');
32
  $_configModel = Mage::getSingleton('lenexport/config');
33
  $_configModel->setStore($store->getId());
34
  $format =Mage::getStoreConfig('lenexport/data/format', $store);
35
- $generate = Mage::getModel('lenexport/generate');
 
 
 
36
  $generate->setCurrentStore($store->getId());
37
  $generate->setOriginalCurrency($store->getCurrentCurrencyCode());
38
- $generate->exec($store->getId(), null, $format, null, null, null, null, null, false, false);
 
 
 
 
 
 
 
 
 
39
  } else {
40
- Mage::helper('lensync/data')->log('Stop cron export - Store ' . $store->getName() . '(' . $store->getId() . ') is disabled');
41
  }
42
  } catch (Exception $e) {
 
43
  Mage::log($e->getMessage());
44
  Mage::log($e->getTraceAsString());
45
  }
@@ -61,10 +73,66 @@ class Lengow_Export_Model_Observer {
61
  $_product->setLengowProduct(1);
62
  } catch (Exception $e) {
63
  Mage::log($e->getMessage());
64
- Mage::log($e->getTraceAsString());
65
  }
66
  Mage::log('Auto export product ' . $_product->getId(). ' (SKU ' . $_product->getSku(). ') to Lengow');
67
  }
68
  }
69
-
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
70
  }
5
  *
6
  * @category Lengow
7
  * @package Lengow_Export
8
+ * @author Ludovic Drin <ludovic@lengow.com> & Benjamin Le Nevé <benjamin.le-neve@lengow.com>
9
+ * @copyright 2015 Lengow SAS
10
  * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
11
  */
12
  class Lengow_Export_Model_Observer {
16
  */
17
  public function export($observer)
18
  {
19
+ if (Mage::getStoreConfig('lenexport/performances/active_cron')) {
20
  // clean old log (20 days)
21
  Mage::helper('lensync/data')->cleanLog();
22
  Mage::helper('lensync/data')->log('## Start cron export ##');
23
  set_time_limit(0);
24
  ini_set('memory_limit', '1G');
25
+ $store_collection = Mage::getResourceModel('core/store_collection')->addFieldToFilter('is_active', 1);
 
26
  $exceptions = array();
27
  foreach($store_collection as $store) {
28
  try {
29
+ if (Mage::getStoreConfig('lenexport/global/active_store', $store)) {
30
  Mage::helper('lensync/data')->log('Start cron export in Store ' . $store->getName() . '(' . $store->getId() . ')');
31
  $_configModel = Mage::getSingleton('lenexport/config');
32
  $_configModel->setStore($store->getId());
33
  $format =Mage::getStoreConfig('lenexport/data/format', $store);
34
+ if(Mage::getStoreConfig('lenexport/performances/optimizeexport'))
35
+ $generate = Mage::getModel('lenexport/generateoptimize');
36
+ else
37
+ $generate = Mage::getModel('lenexport/generate');
38
  $generate->setCurrentStore($store->getId());
39
  $generate->setOriginalCurrency($store->getCurrentCurrencyCode());
40
+ if(Mage::getStoreConfig('lenexport/performances/optimizeexport'))
41
+ $generate->exec(
42
+ $store->getId(),
43
+ $format,
44
+ array(
45
+ 'stream' => false
46
+ )
47
+ );
48
+ else
49
+ $generate->exec($store->getId(), null, $format, null, null, null, null, null, false, false);
50
  } else {
51
+ Mage::helper('lensync/data')->log('Stop cron export - Store ' . $store->getName() . '(' . $store->getId() . ') is disabled');
52
  }
53
  } catch (Exception $e) {
54
+ Mage::helper('lensync/data')->log('Stop cron export - Store ' . $store->getName() . '(' . $store->getId() . ') - Error: '.$e->getMessage());
55
  Mage::log($e->getMessage());
56
  Mage::log($e->getTraceAsString());
57
  }
73
  $_product->setLengowProduct(1);
74
  } catch (Exception $e) {
75
  Mage::log($e->getMessage());
76
+ Mage::log($e->getTraceAsString());
77
  }
78
  Mage::log('Auto export product ' . $_product->getId(). ' (SKU ' . $_product->getSku(). ') to Lengow');
79
  }
80
  }
81
+
82
+
83
+ public function afterSaveConfiguration($observer)
84
+ {
85
+ $postData = $observer->getEvent()->getData();
86
+ $params = Mage::app()->getRequest()->getParams();
87
+
88
+ if (isset($params["groups"]["global"]["fields"]["active_store"])) {
89
+ if (isset($params["groups"]["global"]["fields"]["active_store"]["value"])
90
+ && $params["groups"]["global"]["fields"]["active_store"]["value"] == 1
91
+ ) {
92
+ return true;
93
+ }
94
+ }
95
+
96
+ if (is_null($postData['store']) && $postData['website']) //check for website scope
97
+ {
98
+ //do nothing
99
+ }
100
+ elseif($postData['store']) //check for store scope
101
+ {
102
+ $current_store = Mage::getModel('core/store')->load($postData['store']);
103
+ //delete feed
104
+ $this->_deleteStoreFiles($current_store);
105
+ }
106
+ else //for default scope
107
+ {
108
+ //check individual store
109
+ //delete all feeds
110
+ foreach (Mage::app()->getWebsites() as $website) {
111
+ foreach ($website->getGroups() as $group) {
112
+ $stores = $group->getStores();
113
+ foreach ($stores as $store) {
114
+ //check if individual value is on
115
+ if (Mage::getStoreConfig('lenexport/global/active_store', $store)==0){
116
+ $this->_deleteStoreFiles($store);
117
+ }
118
+ }
119
+ }
120
+ }
121
+ }
122
+
123
+ }
124
+
125
+
126
+ private function _deleteStoreFiles($store)
127
+ {
128
+ $formatFeed = array("csv","xml","yaml","json");
129
+ foreach($formatFeed as $format){
130
+ $filePath = Mage::getBaseDir('media') . DS . 'lengow' . DS . $store->getCode() . DS."lengow_feed.".$format;
131
+ if (file_exists($filePath)){
132
+ unlink($filePath);
133
+ Mage::helper('lensync/data')->log('Store '.$store->getName().' desactived - Feed delete : '.$filePath);
134
+ }
135
+ }
136
+ }
137
+
138
  }
app/code/community/Lengow/Export/Model/Product/Collection.php ADDED
@@ -0,0 +1,25 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ class Lengow_Export_Model_Product_Collection extends Mage_Catalog_Model_Resource_Eav_Mysql4_Product_Collection
4
+ {
5
+
6
+ public function isEnabledFlat()
7
+ {
8
+ return false;
9
+ }
10
+ public function getCollection(){
11
+ return $this;
12
+ }
13
+
14
+ /**
15
+ * Initialize resources
16
+ *
17
+ */
18
+ protected function _construct()
19
+ {
20
+
21
+ $this->_init('lenexport/catalog_product');
22
+ $this->_initTables();
23
+ }
24
+
25
+ }
app/code/community/Lengow/Export/Model/Resource/Catalog/Product.php ADDED
@@ -0,0 +1,8 @@
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ class Lengow_Export_Model_Resource_Catalog_Product extends Mage_Catalog_Model_Resource_Eav_Mysql4_Product
4
+ {
5
+
6
+
7
+
8
+ }
app/code/community/Lengow/Export/controllers/Adminhtml/Lengow/ExportController.php CHANGED
@@ -10,7 +10,8 @@
10
  */
11
  class Lengow_Export_Adminhtml_Lengow_ExportController extends Mage_Adminhtml_Controller_Action {
12
 
13
- public function indexAction() {
 
14
  $this->loadLayout();
15
  $this->renderLayout();
16
  return $this;
@@ -19,14 +20,16 @@ class Lengow_Export_Adminhtml_Lengow_ExportController extends Mage_Adminhtml_Con
19
  /**
20
  * Product grid for AJAX request
21
  */
22
- public function gridAction() {
 
23
  $this->loadLayout();
24
  $this->getResponse()->setBody(
25
  $this->getLayout()->createBlock('lenexport/adminhtml_product_grid')->toHtml()
26
  );
27
  }
28
 
29
- public function massPublishAction() {
 
30
  $_product_ids = (array) $this->getRequest()->getParam('product');
31
  $_store_id = (integer) $this->getRequest()->getParam('store', Mage::app()->getStore()->getId());
32
  $_publish = (integer) $this->getRequest()->getParam('publish');
@@ -69,8 +72,14 @@ class Lengow_Export_Adminhtml_Lengow_ExportController extends Mage_Adminhtml_Con
69
  }
70
 
71
 
72
- protected function _getSession() {
 
73
  return Mage::getSingleton('adminhtml/session');
74
  }
75
 
 
 
 
 
 
76
  }
10
  */
11
  class Lengow_Export_Adminhtml_Lengow_ExportController extends Mage_Adminhtml_Controller_Action {
12
 
13
+ public function indexAction()
14
+ {
15
  $this->loadLayout();
16
  $this->renderLayout();
17
  return $this;
20
  /**
21
  * Product grid for AJAX request
22
  */
23
+ public function gridAction()
24
+ {
25
  $this->loadLayout();
26
  $this->getResponse()->setBody(
27
  $this->getLayout()->createBlock('lenexport/adminhtml_product_grid')->toHtml()
28
  );
29
  }
30
 
31
+ public function massPublishAction()
32
+ {
33
  $_product_ids = (array) $this->getRequest()->getParam('product');
34
  $_store_id = (integer) $this->getRequest()->getParam('store', Mage::app()->getStore()->getId());
35
  $_publish = (integer) $this->getRequest()->getParam('publish');
72
  }
73
 
74
 
75
+ protected function _getSession()
76
+ {
77
  return Mage::getSingleton('adminhtml/session');
78
  }
79
 
80
+ protected function _isAllowed()
81
+ {
82
+ return Mage::getSingleton('admin/session')->isAllowed('lengow/export');
83
+ }
84
+
85
  }
app/code/community/Lengow/Export/controllers/FeedController.php CHANGED
@@ -4,7 +4,7 @@
4
  *
5
  * @category Lengow
6
  * @package Lengow_Export
7
- * @author Ludovic Drin <ludovic@lengow.com> & Benjamin Le Nevé <benjamin.le-neve@lengow.com>
8
  * @copyright 2015 Lengow SAS
9
  * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
10
  */
@@ -44,10 +44,14 @@ class Lengow_Export_FeedController extends Mage_Core_Controller_Front_Action {
44
 
45
  // check if store is enable for export
46
  if(Mage::getStoreConfig('lenexport/global/active_store', Mage::app()->getStore($id_store))) {
47
-
48
- $generate = Mage::getSingleton('lenexport/generate');
 
 
 
 
49
  $generate->setCurrentStore($id_store);
50
- $generate->setOriginalCurrency(Mage::app()->getStore()->getCurrentCurrencyCode());
51
 
52
  // other params
53
  $format = $this->getRequest()->getParam('format', null);
@@ -60,6 +64,7 @@ class Lengow_Export_FeedController extends Mage_Core_Controller_Front_Action {
60
  $limit = $this->getRequest()->getParam('limit', null);
61
  $offset = $this->getRequest()->getParam('offset', null);
62
  $ids_product = $this->getRequest()->getParam('ids_product', null);
 
63
 
64
  if ($locale = $this->getRequest()->getParam('locale', null)) {
65
  // changing locale works!
@@ -73,7 +78,34 @@ class Lengow_Export_FeedController extends Mage_Core_Controller_Front_Action {
73
  $generate->setCurrentCurrencyCode($currency);
74
  }
75
  Mage::helper('lensync/data')->log('Start manual export in store ' . Mage::app()->getStore($id_store)->getName() . '(' . $id_store . ')');
76
- $generate->exec($id_store, $mode, $format, $types, $status, $export_child, $out_of_stock, $selected_products, $stream, $limit, $offset, $ids_product);
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
77
  } else {
78
  Mage::helper('lensync/data')->log('Stop manual export - Store ' . Mage::app()->getStore($id_store)->getName() . '(' . $id_store . ') is disabled');
79
  header('Content-Type: text/html; charset=utf-8');
@@ -85,4 +117,4 @@ class Lengow_Export_FeedController extends Mage_Core_Controller_Front_Action {
85
  echo Mage::helper('lenexport')->__('Unauthorised IP : %s', $_SERVER['REMOTE_ADDR']);
86
  }
87
  }
88
- }
4
  *
5
  * @category Lengow
6
  * @package Lengow_Export
7
+ * @author Ludovic Drin <ludovic@lengow.com> & Benjamin Le Nevé <benjamin.le-neve@lengow.com>
8
  * @copyright 2015 Lengow SAS
9
  * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
10
  */
44
 
45
  // check if store is enable for export
46
  if(Mage::getStoreConfig('lenexport/global/active_store', Mage::app()->getStore($id_store))) {
47
+
48
+ if(Mage::getStoreConfig('lenexport/performances/optimizeexport')) {
49
+ $generate = Mage::getSingleton('lenexport/generateoptimize');
50
+ } else {
51
+ $generate = Mage::getSingleton('lenexport/generate');
52
+ }
53
  $generate->setCurrentStore($id_store);
54
+ $generate->setOriginalCurrency(Mage::app()->getStore($id_store)->getCurrentCurrencyCode());
55
 
56
  // other params
57
  $format = $this->getRequest()->getParam('format', null);
64
  $limit = $this->getRequest()->getParam('limit', null);
65
  $offset = $this->getRequest()->getParam('offset', null);
66
  $ids_product = $this->getRequest()->getParam('ids_product', null);
67
+ $debug = $this->getRequest()->getParam('debug', null);
68
 
69
  if ($locale = $this->getRequest()->getParam('locale', null)) {
70
  // changing locale works!
78
  $generate->setCurrentCurrencyCode($currency);
79
  }
80
  Mage::helper('lensync/data')->log('Start manual export in store ' . Mage::app()->getStore($id_store)->getName() . '(' . $id_store . ')');
81
+
82
+ try {
83
+ if(Mage::getStoreConfig('lenexport/performances/optimizeexport')) {
84
+ $generate->exec(
85
+ $id_store,
86
+ $format,
87
+ array(
88
+ 'mode' => $mode,
89
+ 'types' => $types,
90
+ 'status' => $status,
91
+ 'export_child' => $export_child,
92
+ 'out_of_stock' => $out_of_stock,
93
+ 'selected_products' => $selected_products,
94
+ 'stream' => $stream,
95
+ 'limit' => $limit,
96
+ 'offset' => $offset,
97
+ 'product_ids' => $ids_product,
98
+ 'debug' => $debug,
99
+ )
100
+ );
101
+ } else {
102
+ $generate->exec($id_store, $mode, $format, $types, $status, $export_child, $out_of_stock, $selected_products, $stream, $limit, $offset, $ids_product);
103
+ }
104
+ } catch (Exception $e) {
105
+ Mage::helper('lensync/data')->log('Stop manual export - Store ' . Mage::app()->getStore($id_store)->getName() . '(' . $id_store . ') - Error: ' . $e->getMessage());
106
+ echo 'Error: '.$e->getMessage();
107
+ flush();
108
+ }
109
  } else {
110
  Mage::helper('lensync/data')->log('Stop manual export - Store ' . Mage::app()->getStore($id_store)->getName() . '(' . $id_store . ') is disabled');
111
  header('Content-Type: text/html; charset=utf-8');
117
  echo Mage::helper('lenexport')->__('Unauthorised IP : %s', $_SERVER['REMOTE_ADDR']);
118
  }
119
  }
120
+ }
app/code/community/Lengow/Export/etc/config.xml CHANGED
@@ -2,7 +2,7 @@
2
  <config>
3
  <modules>
4
  <Lengow_Export>
5
- <version>2.1.1</version>
6
  </Lengow_Export>
7
  </modules>
8
  <admin>
@@ -27,8 +27,11 @@
27
  <models>
28
  <lenexport>
29
  <class>Lengow_Export_Model</class>
30
- <resourceModel>export_mysql4</resourceModel>
31
  </lenexport>
 
 
 
32
  <export_mysql4>
33
  <class>Lengow_Export_Model_Mysql4</class>
34
  <entities>
@@ -75,6 +78,15 @@
75
  </yourmodule>
76
  </observers>
77
  </catalog_product_save_before>
 
 
 
 
 
 
 
 
 
78
  </events>
79
  </global>
80
  <frontend>
@@ -129,9 +141,9 @@
129
  <lengow translate="title" module="lenexport">
130
  <title>Lengow</title>
131
  <children>
132
- <lenexport translate="title" module="lenexport">
133
  <title>Manage Products Export</title>
134
- </lenexport>
135
  </children>
136
  </lengow>
137
  </children>
@@ -179,6 +191,7 @@
179
  </attributelist>
180
  <performances>
181
  <valid_ip></valid_ip>
 
182
  <usesavefile>0</usesavefile>
183
  <active_cron>0</active_cron>
184
  </performances>
2
  <config>
3
  <modules>
4
  <Lengow_Export>
5
+ <version>2.1.2</version>
6
  </Lengow_Export>
7
  </modules>
8
  <admin>
27
  <models>
28
  <lenexport>
29
  <class>Lengow_Export_Model</class>
30
+ <resourceModel>lenexport_resource</resourceModel>
31
  </lenexport>
32
+ <lenexport_resource>
33
+ <class>Lengow_Export_Model_Resource</class>
34
+ </lenexport_resource>
35
  <export_mysql4>
36
  <class>Lengow_Export_Model_Mysql4</class>
37
  <entities>
78
  </yourmodule>
79
  </observers>
80
  </catalog_product_save_before>
81
+ <admin_system_config_changed_section_lenexport>
82
+ <observers>
83
+ <mymodule>
84
+ <type>singleton</type>
85
+ <class>Lengow_Export_Model_Observer</class>
86
+ <method>afterSaveConfiguration</method>
87
+ </mymodule>
88
+ </observers>
89
+ </admin_system_config_changed_section_lenexport>
90
  </events>
91
  </global>
92
  <frontend>
141
  <lengow translate="title" module="lenexport">
142
  <title>Lengow</title>
143
  <children>
144
+ <export translate="title" module="lenexport">
145
  <title>Manage Products Export</title>
146
+ </export>
147
  </children>
148
  </lengow>
149
  </children>
191
  </attributelist>
192
  <performances>
193
  <valid_ip></valid_ip>
194
+ <optimizeexport>0</optimizeexport>
195
  <usesavefile>0</usesavefile>
196
  <active_cron>0</active_cron>
197
  </performances>
app/code/community/Lengow/Export/etc/system.xml CHANGED
@@ -44,8 +44,8 @@
44
  <source_model>adminhtml/system_config_source_yesno</source_model>
45
  </export_only_selected>
46
  <autoexport_newproduct>
47
- <label><![CDATA[Auto export new product]]></label>
48
- <comment><![CDATA[Auto export a new product on Lengow]]></comment>
49
  <frontend_type>select</frontend_type>
50
  <sort_order>30</sort_order>
51
  <show_in_default>1</show_in_default>
@@ -54,7 +54,7 @@
54
  <source_model>adminhtml/system_config_source_yesno</source_model>
55
  </autoexport_newproduct>
56
  <export_soldout>
57
- <label>Export product out of stock</label>
58
  <comment></comment>
59
  <frontend_type>select</frontend_type>
60
  <sort_order>40</sort_order>
@@ -104,7 +104,7 @@
104
  <sort_order>2</sort_order>
105
  <fields>
106
  <format>
107
- <label>Format</label>
108
  <frontend_type>select</frontend_type>
109
  <sort_order>10</sort_order>
110
  <show_in_default>1</show_in_default>
@@ -152,7 +152,7 @@
152
  </without_product_ordering>
153
  <formatdata>
154
  <label>Convert data</label>
155
- <comment><![CDATA[Replace special chars with html chars]]></comment>
156
  <frontend_type>select</frontend_type>
157
  <sort_order>60</sort_order>
158
  <show_in_default>1</show_in_default>
@@ -237,16 +237,26 @@
237
  <fields>
238
  <valid_ip>
239
  <label>Ip authorised to export</label>
240
- <comment><![CDATA[Authorized acces to catalog export by IP, separated by ;]]></comment>
241
  <frontend_type>text</frontend_type>
242
  <sort_order>10</sort_order>
243
  <show_in_default>1</show_in_default>
244
  <show_in_website>0</show_in_website>
245
  <show_in_store>0</show_in_store>
246
  </valid_ip>
 
 
 
 
 
 
 
 
 
 
247
  <usesavefile>
248
  <label>Save feed on file</label>
249
- <comment><![CDATA[Save the feed on a file]]></comment>
250
  <frontend_type>select</frontend_type>
251
  <sort_order>10</sort_order>
252
  <show_in_default>1</show_in_default>
@@ -255,8 +265,8 @@
255
  <source_model>adminhtml/system_config_source_yesno</source_model>
256
  </usesavefile>
257
  <active_cron>
258
- <label><![CDATA[Active cron]]></label>
259
- <comment><![CDATA[Active the scheduled task for export your feed every 4h]]></comment>
260
  <frontend_type>select</frontend_type>
261
  <sort_order>20</sort_order>
262
  <show_in_default>1</show_in_default>
44
  <source_model>adminhtml/system_config_source_yesno</source_model>
45
  </export_only_selected>
46
  <autoexport_newproduct>
47
+ <label>Auto export new product</label>
48
+ <comment>Auto export a new product on Lengow</comment>
49
  <frontend_type>select</frontend_type>
50
  <sort_order>30</sort_order>
51
  <show_in_default>1</show_in_default>
54
  <source_model>adminhtml/system_config_source_yesno</source_model>
55
  </autoexport_newproduct>
56
  <export_soldout>
57
+ <label>Export out of stock product</label>
58
  <comment></comment>
59
  <frontend_type>select</frontend_type>
60
  <sort_order>40</sort_order>
104
  <sort_order>2</sort_order>
105
  <fields>
106
  <format>
107
+ <label>Export default format</label>
108
  <frontend_type>select</frontend_type>
109
  <sort_order>10</sort_order>
110
  <show_in_default>1</show_in_default>
152
  </without_product_ordering>
153
  <formatdata>
154
  <label>Convert data</label>
155
+ <comment>Replace special chars with html chars</comment>
156
  <frontend_type>select</frontend_type>
157
  <sort_order>60</sort_order>
158
  <show_in_default>1</show_in_default>
237
  <fields>
238
  <valid_ip>
239
  <label>Ip authorised to export</label>
240
+ <comment>Authorized acces to catalog export by IP, separated by ;</comment>
241
  <frontend_type>text</frontend_type>
242
  <sort_order>10</sort_order>
243
  <show_in_default>1</show_in_default>
244
  <show_in_website>0</show_in_website>
245
  <show_in_store>0</show_in_store>
246
  </valid_ip>
247
+ <optimizeexport>
248
+ <label>Optimize Export File</label>
249
+ <comment>Beta feature: enable this option to get a faster export</comment>
250
+ <frontend_type>select</frontend_type>
251
+ <sort_order>10</sort_order>
252
+ <show_in_default>1</show_in_default>
253
+ <show_in_website>0</show_in_website>
254
+ <show_in_store>0</show_in_store>
255
+ <source_model>adminhtml/system_config_source_yesno</source_model>
256
+ </optimizeexport>
257
  <usesavefile>
258
  <label>Save feed on file</label>
259
+ <comment>Save the feed on a file</comment>
260
  <frontend_type>select</frontend_type>
261
  <sort_order>10</sort_order>
262
  <show_in_default>1</show_in_default>
265
  <source_model>adminhtml/system_config_source_yesno</source_model>
266
  </usesavefile>
267
  <active_cron>
268
+ <label>Active cron</label>
269
+ <comment>Active the scheduled task for export your feed every 4h</comment>
270
  <frontend_type>select</frontend_type>
271
  <sort_order>20</sort_order>
272
  <show_in_default>1</show_in_default>
app/code/community/Lengow/Feed/controllers/Adminhtml/Lengow/FeedController.php CHANGED
@@ -10,7 +10,8 @@
10
  */
11
  class Lengow_Feed_Adminhtml_Lengow_FeedController extends Mage_Adminhtml_Controller_Action {
12
 
13
- public function indexAction() {
 
14
  $this->loadLayout();
15
  $this->renderLayout();
16
  return $this;
@@ -19,22 +20,24 @@ class Lengow_Feed_Adminhtml_Lengow_FeedController extends Mage_Adminhtml_Control
19
  /**
20
  * Product grid for AJAX request
21
  */
22
- public function gridAction() {
 
23
  $this->loadLayout();
24
  $this->getResponse()->setBody(
25
  $this->getLayout()->createBlock('lenfeed/adminhtml_feed')->toHtml()
26
  );
27
  }
28
 
29
- protected function _getSession() {
 
30
  return Mage::getSingleton('adminhtml/session');
31
  }
32
 
33
  /**
34
  * Migrate feed
35
  */
36
- public function migrateAction() {
37
-
38
  $feed_ids = $this->getRequest()->getParam('feed_id');
39
  $selected_products = $this->getRequest()->getParam('selected_products');
40
  $product_out_stock = $this->getRequest()->getParam('product_out_stock');
@@ -94,4 +97,9 @@ class Lengow_Feed_Adminhtml_Lengow_FeedController extends Mage_Adminhtml_Control
94
  $this->_redirect('*/*/index');
95
  }
96
 
 
 
 
 
 
97
  }
10
  */
11
  class Lengow_Feed_Adminhtml_Lengow_FeedController extends Mage_Adminhtml_Controller_Action {
12
 
13
+ public function indexAction()
14
+ {
15
  $this->loadLayout();
16
  $this->renderLayout();
17
  return $this;
20
  /**
21
  * Product grid for AJAX request
22
  */
23
+ public function gridAction()
24
+ {
25
  $this->loadLayout();
26
  $this->getResponse()->setBody(
27
  $this->getLayout()->createBlock('lenfeed/adminhtml_feed')->toHtml()
28
  );
29
  }
30
 
31
+ protected function _getSession()
32
+ {
33
  return Mage::getSingleton('adminhtml/session');
34
  }
35
 
36
  /**
37
  * Migrate feed
38
  */
39
+ public function migrateAction()
40
+ {
41
  $feed_ids = $this->getRequest()->getParam('feed_id');
42
  $selected_products = $this->getRequest()->getParam('selected_products');
43
  $product_out_stock = $this->getRequest()->getParam('product_out_stock');
97
  $this->_redirect('*/*/index');
98
  }
99
 
100
+ protected function _isAllowed()
101
+ {
102
+ return Mage::getSingleton('admin/session')->isAllowed('lengow/feed');
103
+ }
104
+
105
  }
app/code/community/Lengow/Feed/etc/config.xml CHANGED
@@ -2,7 +2,7 @@
2
  <config>
3
  <modules>
4
  <Lengow_Feed>
5
- <version>2.1.1</version>
6
  </Lengow_Feed>
7
  </modules>
8
  <admin>
@@ -99,9 +99,9 @@
99
  </system>
100
  <lengow translate="title" module="lenfeed">
101
  <children>
102
- <lenfeed translate="title" module="lenfeed">
103
  <title>Manage Feeds</title>
104
- </lenfeed>
105
  </children>
106
  </lengow>
107
  </children>
2
  <config>
3
  <modules>
4
  <Lengow_Feed>
5
+ <version>2.1.2</version>
6
  </Lengow_Feed>
7
  </modules>
8
  <admin>
99
  </system>
100
  <lengow translate="title" module="lenfeed">
101
  <children>
102
+ <feed translate="title" module="lenfeed">
103
  <title>Manage Feeds</title>
104
+ </feed>
105
  </children>
106
  </lengow>
107
  </children>
app/code/community/Lengow/Sync/Model/Import.php CHANGED
@@ -194,7 +194,7 @@ class Lengow_Sync_Model_Import extends Varien_Object {
194
 
195
  try {
196
  $quote = $this->_createQuote($id_lengow_order, $order_data, $customer, $marketplace);
197
- } catch (Lengow_Sync_Model_Quote_Exception $e) {
198
  $this->_helper->log('create quote fail : ' . $e->getMessage(), $id_lengow_order);
199
  continue;
200
  }
194
 
195
  try {
196
  $quote = $this->_createQuote($id_lengow_order, $order_data, $customer, $marketplace);
197
+ } catch (Exception $e) {
198
  $this->_helper->log('create quote fail : ' . $e->getMessage(), $id_lengow_order);
199
  continue;
200
  }
app/code/community/Lengow/Sync/Model/Observer.php CHANGED
@@ -63,14 +63,13 @@ class Lengow_Sync_Model_Observer {
63
  }
64
  // check if group was already imported
65
  $new_id_lengow_group = false;
66
- $id_groups = explode(';', $id_lengow_group);
67
  foreach ($id_groups as $id_group) {
68
  if (is_numeric($id_group) && !in_array($id_group, $lengow_groups)) {
69
  $lengow_groups[] = $id_group;
70
- $new_id_lengow_group .= !$new_id_lengow_group ? $id_group : ';'.$id_group;
71
  }
72
  }
73
-
74
  if (!$error_import && $new_id_lengow_group) {
75
  $days = $lensync_config->get('orders/period');
76
  $args = array(
@@ -177,7 +176,7 @@ class Lengow_Sync_Model_Observer {
177
  */
178
  private function _cleanGroup($data)
179
  {
180
- return trim(str_replace(array("\r\n", ';', '-', '|', ' '), ';', $data), ',');
181
  }
182
 
183
  }
63
  }
64
  // check if group was already imported
65
  $new_id_lengow_group = false;
66
+ $id_groups = explode(',', $id_lengow_group);
67
  foreach ($id_groups as $id_group) {
68
  if (is_numeric($id_group) && !in_array($id_group, $lengow_groups)) {
69
  $lengow_groups[] = $id_group;
70
+ $new_id_lengow_group .= !$new_id_lengow_group ? $id_group : ','.$id_group;
71
  }
72
  }
 
73
  if (!$error_import && $new_id_lengow_group) {
74
  $days = $lensync_config->get('orders/period');
75
  $args = array(
176
  */
177
  private function _cleanGroup($data)
178
  {
179
+ return trim(str_replace(array("\r\n", ';', '-', '|', ' '), ',', $data), ',');
180
  }
181
 
182
  }
app/code/community/Lengow/Sync/Model/Quote.php CHANGED
@@ -63,9 +63,10 @@ class Lengow_Sync_Model_Quote extends Mage_Sales_Model_Quote {
63
  if (Mage::getStoreConfig('lensync/orders/title', $this->getStore()))
64
  $product->setName((string) $product_line->title);
65
  // add item to quote
66
- $quote_item = Mage::getModel('sales/quote_item')
67
  ->setProduct($product)
68
- ->setQty((int) $product_line->quantity);
 
69
  $this->addItem($quote_item);
70
  }
71
  }
@@ -93,6 +94,7 @@ class Lengow_Sync_Model_Quote extends Mage_Sales_Model_Quote {
93
  // search product foreach sku
94
  $i = 0;
95
  $found = false;
 
96
  $count = count($api_fields);
97
  while(!$found && $i < $count) {
98
  // search with sku type field first
@@ -115,7 +117,7 @@ class Lengow_Sync_Model_Quote extends Mage_Sales_Model_Quote {
115
  }
116
  // search by id or sku
117
  if (!$product || !$product->getId()) {
118
- if (is_integer($sku) && $sku != 0) {
119
  $product = $product_model->load((integer) $sku);
120
  } else {
121
  $sku = str_replace('\_', '_', $sku);
@@ -126,9 +128,9 @@ class Lengow_Sync_Model_Quote extends Mage_Sales_Model_Quote {
126
  $found = true;
127
  }
128
  if (!$found)
129
- throw new Lengow_Sync_Model_Quote_Exception('product ' . (string) $lengow_product->sku . ' could not be found.');
130
  elseif ($product->getTypeId() == Mage_Catalog_Model_Product_Type::TYPE_CONFIGURABLE)
131
- throw new Lengow_Sync_Model_Quote_Exception('product ' . (string) $lengow_product->sku . ' is a parent product.');
132
  return $product;
133
  }
134
 
63
  if (Mage::getStoreConfig('lensync/orders/title', $this->getStore()))
64
  $product->setName((string) $product_line->title);
65
  // add item to quote
66
+ $quote_item = Mage::getModel('lensync/quote_item')
67
  ->setProduct($product)
68
+ ->setQty((int) $product_line->quantity)
69
+ ->setConvertedPrice($price);
70
  $this->addItem($quote_item);
71
  }
72
  }
94
  // search product foreach sku
95
  $i = 0;
96
  $found = false;
97
+ $product = false;
98
  $count = count($api_fields);
99
  while(!$found && $i < $count) {
100
  // search with sku type field first
117
  }
118
  // search by id or sku
119
  if (!$product || !$product->getId()) {
120
+ if (preg_match('/^[0-9]*$/',$sku)) {
121
  $product = $product_model->load((integer) $sku);
122
  } else {
123
  $sku = str_replace('\_', '_', $sku);
128
  $found = true;
129
  }
130
  if (!$found)
131
+ throw new Exception('product ' . (string) $lengow_product->sku . ' could not be found.');
132
  elseif ($product->getTypeId() == Mage_Catalog_Model_Product_Type::TYPE_CONFIGURABLE)
133
+ throw new Exception('product ' . (string) $lengow_product->sku . ' is a parent product.');
134
  return $product;
135
  }
136
 
app/code/community/Lengow/Sync/Model/Quote/Exception.php DELETED
@@ -1,54 +0,0 @@
1
- <?php
2
-
3
- class Lengow_Sync_Model_Quote_Exception extends Exception
4
- {
5
- /**
6
- * The result from the WSDL server that represents the exception information.
7
- */
8
- protected $result;
9
-
10
- /**
11
- * Make a new WSDL Exception with the given result.
12
- *
13
- * @param array $result The error result
14
- */
15
- public function __construct($result, $noerror) {
16
- $this->result = $result;
17
- if(is_array($result))
18
- $msg = $result['message'];
19
- else
20
- $msg = $result;
21
- parent::__construct($msg, $noerror);
22
- }
23
-
24
- /**
25
- * Return the associated result object returned by the WSDL server.
26
- *
27
- * @return array The result from the WSDL server
28
- */
29
- public function getResult() {
30
- return $this->result;
31
- }
32
-
33
- /**
34
- * Returns the associated type for the error.
35
- *
36
- * @return string
37
- */
38
- public function getType() {
39
- if(isset($this->result['type']))
40
- return $this->result['type'];
41
- return 'Lengow_Sync_Model_Quote_Exception';
42
- }
43
-
44
- /**
45
- * To make debugging easier.
46
- *
47
- * @return string The string representation of the error
48
- */
49
- public function __toString() {
50
- if(isset($this->result['message']))
51
- return $this->result['message'];
52
- return $this->message;
53
- }
54
- }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
app/code/community/Lengow/Sync/Model/Quote/Item.php CHANGED
@@ -10,108 +10,17 @@
10
  */
11
  class Lengow_Sync_Model_Quote_Item extends Mage_Sales_Model_Quote_Item {
12
 
13
- public function initPrice($value) {
14
- $store = $this->getQuote()->getStore();
15
- if (!Mage::helper('tax')->priceIncludesTax($store)) {
16
- // DEEE
17
- $_deee_amount = 0;
18
- if (!Mage::helper('tax')->priceIncludesTax($store)) {
19
- $_helper_weee = Mage::helper('weee');
20
- $_deee_amount = $_helper_weee->getAmount($this->getProduct());
21
- }
22
- $bAddress = $this->getQuote()->getBillingAddress();
23
- $sAddress = $this->getQuote()->getShippingAddress();
24
- $address = $this->getAddress();
25
- if ($address) {
26
- switch ($address->getAddressType()) {
27
- case Mage_Sales_Model_Quote_Address::TYPE_BILLING:
28
- $bAddress = $address;
29
- break;
30
- case Mage_Sales_Model_Quote_Address::TYPE_SHIPPING:
31
- $sAddress = $address;
32
- break;
33
- }
34
- }
35
-
36
- if ($this->getProduct()->getIsVirtual()) {
37
- $sAddress = $bAddress;
38
- }
39
-
40
- $priceExcludingTax = Mage::helper('tax')->getPrice(
41
- $this->getProduct()->setTaxPercent(null),
42
- $value,
43
- false,
44
- $sAddress,
45
- $bAddress,
46
- $this->getQuote()->getCustomerTaxClassId(),
47
- $store,
48
- true
49
- ) - $_deee_amount;
50
- $this->setCustomPrice($priceExcludingTax);
51
- $this->setOriginalCustomPrice($priceExcludingTax);
52
- $this->setOriginalPrice($priceExcludingTax);
53
-
54
- $priceIncludingTax = Mage::helper('tax')->getPrice(
55
- $this->getProduct()->setTaxPercent(null),
56
- $value,
57
- true,
58
- $sAddress,
59
- $bAddress,
60
- $this->getQuote()->getCustomerTaxClassId(),
61
- $store,
62
- true
63
- );
64
- $qty = $this->getQty();
65
- if ($this->getParentItem()) {
66
- $qty = $qty*$this->getParentItem()->getQty();
67
- }
68
-
69
- //if (Mage::helper('tax')->displayCartPriceInclTax($store)) {
70
- $rowTotal = $value * $qty;
71
- $rowTotalExcTax = Mage::helper('tax')->getPrice(
72
- $this->getProduct()->setTaxPercent(null),
73
- $rowTotal,
74
- false,
75
- $sAddress,
76
- $bAddress,
77
- $this->getQuote()->getCustomerTaxClassId(),
78
- $store,
79
- true
80
- ) - ($_deee_amount * $qty);
81
- $rowTotalIncTax = Mage::helper('tax')->getPrice(
82
- $this->getProduct()->setTaxPercent(null),
83
- $rowTotal,
84
- true,
85
- $sAddress,
86
- $bAddress,
87
- $this->getQuote()->getCustomerTaxClassId(),
88
- $store,
89
- true
90
- );
91
- $totalBaseTax = $rowTotalIncTax-$rowTotalExcTax;
92
- $this->setBaseRowTotal($rowTotal);
93
- $this->setBaseRowTotalInclTax($rowTotal);
94
- //} else {
95
- $taxAmount = $priceIncludingTax - $priceExcludingTax ;
96
- $this->setTaxPercent($this->getProduct()->getTaxPercent());
97
- $totalBaseTax = $taxAmount*$qty;
98
- //}
99
-
100
- $totalTax = $this->getStore()->convertPrice($totalBaseTax);
101
- $this->setTaxBeforeDiscount($totalTax);
102
- $this->setBaseTaxBeforeDiscount($totalBaseTax);
103
-
104
- $this->setTaxAmount($totalTax);
105
- $this->setBaseTaxAmount($totalBaseTax);
106
- $this->setBaseOriginalPrice($priceExcludingTax);
107
- $this->setTaxAmount($totalTax);
108
- $this->setPrice($priceExcludingTax);
109
- $this->setPriceInclTax($priceIncludingTax);
110
- $this->setBasePriceInclTax($priceIncludingTax);
111
- return $this;
112
- } else {
113
- return $this;
114
- }
115
  }
116
-
117
  }
10
  */
11
  class Lengow_Sync_Model_Quote_Item extends Mage_Sales_Model_Quote_Item {
12
 
13
+ /**
14
+ * Specify item price (base calculation price and converted price will be refreshed too)
15
+ *
16
+ * @param float $value
17
+ * @return Mage_Sales_Model_Quote_Item_Abstract
18
+ */
19
+ public function setPrice($value)
20
+ {
21
+ $this->setBaseCalculationPrice(null);
22
+ //dont set converted price to 0
23
+ //$this->setConvertedPrice(null);
24
+ return $this->setData('price', $value);
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
25
  }
 
26
  }
app/code/community/Lengow/Sync/controllers/Adminhtml/Lengow/LogController.php CHANGED
@@ -10,20 +10,23 @@
10
  */
11
  class Lengow_Sync_Adminhtml_Lengow_LogController extends Mage_Adminhtml_Controller_Action {
12
 
13
- protected function _initAction() {
 
14
  $this->loadLayout()
15
  ->_setActiveMenu('lengow/log')
16
  ->_addBreadcrumb(Mage::helper('lensync')->__('Lengow orders'), Mage::helper('lensync')->__('Lengow orders'));
17
  return $this;
18
  }
19
 
20
- public function indexAction() {
 
21
  $this->_initAction()
22
  ->renderLayout();
23
  return $this;
24
  }
25
 
26
- public function deleteAction() {
 
27
  $collection = Mage::getModel('lensync/log')->getCollection();
28
  foreach($collection as $log)
29
  $log->delete();
@@ -32,9 +35,15 @@ class Lengow_Sync_Adminhtml_Lengow_LogController extends Mage_Adminhtml_Controll
32
 
33
  }
34
 
35
- public function gridAction() {
 
36
  $this->getResponse()->setBody($this->getLayout()->createBlock('lensync/adminhtml_log_grid')->toHtml());
37
  return $this;
38
  }
 
 
 
 
 
39
 
40
  }
10
  */
11
  class Lengow_Sync_Adminhtml_Lengow_LogController extends Mage_Adminhtml_Controller_Action {
12
 
13
+ protected function _initAction()
14
+ {
15
  $this->loadLayout()
16
  ->_setActiveMenu('lengow/log')
17
  ->_addBreadcrumb(Mage::helper('lensync')->__('Lengow orders'), Mage::helper('lensync')->__('Lengow orders'));
18
  return $this;
19
  }
20
 
21
+ public function indexAction()
22
+ {
23
  $this->_initAction()
24
  ->renderLayout();
25
  return $this;
26
  }
27
 
28
+ public function deleteAction()
29
+ {
30
  $collection = Mage::getModel('lensync/log')->getCollection();
31
  foreach($collection as $log)
32
  $log->delete();
35
 
36
  }
37
 
38
+ public function gridAction()
39
+ {
40
  $this->getResponse()->setBody($this->getLayout()->createBlock('lensync/adminhtml_log_grid')->toHtml());
41
  return $this;
42
  }
43
+
44
+ protected function _isAllowed()
45
+ {
46
+ return Mage::getSingleton('admin/session')->isAllowed('lengow/log');
47
+ }
48
 
49
  }
app/code/community/Lengow/Sync/controllers/Adminhtml/Lengow/OrderController.php CHANGED
@@ -125,11 +125,11 @@ class Lengow_Sync_Adminhtml_Lengow_OrderController extends Mage_Adminhtml_Contro
125
  }
126
  // check if group was already imported
127
  $new_id_lengow_group = false;
128
- $id_groups = explode(';', $id_lengow_group);
129
  foreach ($id_groups as $id_group) {
130
  if (is_numeric($id_group) && !in_array($id_group, $lengow_groups)) {
131
  $lengow_groups[] = $id_group;
132
- $new_id_lengow_group .= !$new_id_lengow_group ? $id_group : ';'.$id_group;
133
  }
134
  }
135
  // start import for current store
@@ -182,7 +182,12 @@ class Lengow_Sync_Adminhtml_Lengow_OrderController extends Mage_Adminhtml_Contro
182
  */
183
  private function _cleanGroup($data)
184
  {
185
- return trim(str_replace(array("\r\n", ';', '-', '|', ' '), ';', $data), ';');
 
 
 
 
 
186
  }
187
 
188
  }
125
  }
126
  // check if group was already imported
127
  $new_id_lengow_group = false;
128
+ $id_groups = explode(',', $id_lengow_group);
129
  foreach ($id_groups as $id_group) {
130
  if (is_numeric($id_group) && !in_array($id_group, $lengow_groups)) {
131
  $lengow_groups[] = $id_group;
132
+ $new_id_lengow_group .= !$new_id_lengow_group ? $id_group : ','.$id_group;
133
  }
134
  }
135
  // start import for current store
182
  */
183
  private function _cleanGroup($data)
184
  {
185
+ return trim(str_replace(array("\r\n", ';', '-', '|', ' '), ',', $data), ',');
186
+ }
187
+
188
+ protected function _isAllowed()
189
+ {
190
+ return Mage::getSingleton('admin/session')->isAllowed('lengow/sync');
191
  }
192
 
193
  }
app/code/community/Lengow/Sync/etc/config.xml CHANGED
@@ -2,7 +2,7 @@
2
  <config>
3
  <modules>
4
  <Lengow_Sync>
5
- <version>2.1.1</version>
6
  </Lengow_Sync>
7
  </modules>
8
  <admin>
@@ -214,9 +214,9 @@
214
  <lengow translate="title" module="lensync">
215
  <title>Lengow</title>
216
  <children>
217
- <lensync translate="title" module="lensync">
218
  <title>Manage Orders</title>
219
- </lensync>
220
  <log translate="title" module="lensync">
221
  <title>Manage Logs</title>
222
  </log>
2
  <config>
3
  <modules>
4
  <Lengow_Sync>
5
+ <version>2.1.2</version>
6
  </Lengow_Sync>
7
  </modules>
8
  <admin>
214
  <lengow translate="title" module="lensync">
215
  <title>Lengow</title>
216
  <children>
217
+ <sync translate="title" module="lensync">
218
  <title>Manage Orders</title>
219
+ </sync>
220
  <log translate="title" module="lensync">
221
  <title>Manage Logs</title>
222
  </log>
app/code/community/Lengow/Sync/etc/marketplaces.xml CHANGED
@@ -152,14 +152,20 @@
152
  <value default="true">Colissimo</value>
153
  <value>So Colissimo</value>
154
  <value>CHRONOPOST</value>
 
 
155
  <value>TNT</value>
156
  <value>UPS</value>
157
  <value>Fedex</value>
158
  <value>Tatex</value>
159
  <value>GLS</value>
160
  <value>DHL</value>
161
- <value>DPD</value>
 
 
162
  <value>Courrier Suivi</value>
 
 
163
  </accepted_values>
164
  </param>
165
  </additional_params>
@@ -3958,9 +3964,9 @@
3958
  </param>
3959
  </additional_params>
3960
  </marketplace>
3961
- <marketplace name="home24_swde">
3962
- <api>https://wsdl.lengow.com/wsdl/home24_swde/#ID_FLUX#/#ORDER_ID#/#ACTION#.xml</api>
3963
- <apibyline>https://wsdl.lengow.com/wsdl/home24_swde/#ID_FLUX#/#ORDER_ID#/#ORDER_LINE_ID#/#QUANTITY#/action_lines.xml</apibyline>
3964
  <states>
3965
  <state name="new">
3966
  <lengow>new</lengow>
@@ -4018,9 +4024,9 @@
4018
  </param>
4019
  </additional_params>
4020
  </marketplace>
4021
- <marketplace name="home24_swfr">
4022
- <api>https://wsdl.lengow.com/wsdl/home24_swfr/#ID_FLUX#/#ORDER_ID#/#ACTION#.xml</api>
4023
- <apibyline>https://wsdl.lengow.com/wsdl/home24_swfr/#ID_FLUX#/#ORDER_ID#/#ORDER_LINE_ID#/#QUANTITY#/action_lines.xml</apibyline>
4024
  <states>
4025
  <state name="new">
4026
  <lengow>new</lengow>
152
  <value default="true">Colissimo</value>
153
  <value>So Colissimo</value>
154
  <value>CHRONOPOST</value>
155
+ <value>DPD</value>
156
+ <value>Mondial Relay</value>
157
  <value>TNT</value>
158
  <value>UPS</value>
159
  <value>Fedex</value>
160
  <value>Tatex</value>
161
  <value>GLS</value>
162
  <value>DHL</value>
163
+ <value>France Express</value>
164
+ <value>Kiala</value>
165
+ <value>Exapaq</value>
166
  <value>Courrier Suivi</value>
167
+ <value>Colis Prive</value>
168
+ <value>Autre</value>
169
  </accepted_values>
170
  </param>
171
  </additional_params>
3964
  </param>
3965
  </additional_params>
3966
  </marketplace>
3967
+ <marketplace name="home24_chde">
3968
+ <api>https://wsdl.lengow.com/wsdl/home24_chde/#ID_FLUX#/#ORDER_ID#/#ACTION#.xml</api>
3969
+ <apibyline>https://wsdl.lengow.com/wsdl/home24_chde/#ID_FLUX#/#ORDER_ID#/#ORDER_LINE_ID#/#QUANTITY#/action_lines.xml</apibyline>
3970
  <states>
3971
  <state name="new">
3972
  <lengow>new</lengow>
4024
  </param>
4025
  </additional_params>
4026
  </marketplace>
4027
+ <marketplace name="home24_chfr">
4028
+ <api>https://wsdl.lengow.com/wsdl/home24_chfr/#ID_FLUX#/#ORDER_ID#/#ACTION#.xml</api>
4029
+ <apibyline>https://wsdl.lengow.com/wsdl/home24_chfr/#ID_FLUX#/#ORDER_ID#/#ORDER_LINE_ID#/#QUANTITY#/action_lines.xml</apibyline>
4030
  <states>
4031
  <state name="new">
4032
  <lengow>new</lengow>
app/code/community/Lengow/Sync/etc/system.xml CHANGED
@@ -39,7 +39,7 @@
39
  <show_in_default>1</show_in_default>
40
  <show_in_website>0</show_in_website>
41
  <show_in_store>1</show_in_store>
42
- <comment>Choose period for Sync order</comment>
43
  </period>
44
  <date_import>
45
  <label>Use the real date of import's order</label>
@@ -53,7 +53,6 @@
53
  </date_import>
54
  <processing_fee>
55
  <label>Import processing fee from Marketplace</label>
56
- <comment>Import the processing fee</comment>
57
  <frontend_type>select</frontend_type>
58
  <sort_order>50</sort_order>
59
  <show_in_default>1</show_in_default>
@@ -111,8 +110,8 @@
111
  <source_model>adminhtml/system_config_source_shipping_allmethods</source_model>
112
  </default_shipping>
113
  <fake_email>
114
- <label>Use fake emails</label>
115
- <comment>Use fake emails for customer creation</comment>
116
  <frontend_type>select</frontend_type>
117
  <sort_order>100</sort_order>
118
  <show_in_default>1</show_in_default>
39
  <show_in_default>1</show_in_default>
40
  <show_in_website>0</show_in_website>
41
  <show_in_store>1</show_in_store>
42
+ <comment>Choose a number of days</comment>
43
  </period>
44
  <date_import>
45
  <label>Use the real date of import's order</label>
53
  </date_import>
54
  <processing_fee>
55
  <label>Import processing fee from Marketplace</label>
 
56
  <frontend_type>select</frontend_type>
57
  <sort_order>50</sort_order>
58
  <show_in_default>1</show_in_default>
110
  <source_model>adminhtml/system_config_source_shipping_allmethods</source_model>
111
  </default_shipping>
112
  <fake_email>
113
+ <label>Use fictitious emails</label>
114
+ <comment>Use fictitious emails for customer creation</comment>
115
  <frontend_type>select</frontend_type>
116
  <sort_order>100</sort_order>
117
  <show_in_default>1</show_in_default>
app/code/community/Lengow/Tracker/etc/config.xml CHANGED
@@ -2,7 +2,7 @@
2
  <config>
3
  <modules>
4
  <Lengow_Tracker>
5
- <version>2.1.1</version>
6
  </Lengow_Tracker>
7
  </modules>
8
  <global>
2
  <config>
3
  <modules>
4
  <Lengow_Tracker>
5
+ <version>2.1.2</version>
6
  </Lengow_Tracker>
7
  </modules>
8
  <global>
app/code/community/Lengow/Tracker/etc/system.xml CHANGED
@@ -51,7 +51,8 @@
51
  <show_in_store>1</show_in_store>
52
  </group>
53
  <api_key>
54
- <label>Token API</label>
 
55
  <frontend_type>text</frontend_type>
56
  <sort_order>20</sort_order>
57
  <show_in_default>1</show_in_default>
51
  <show_in_store>1</show_in_store>
52
  </group>
53
  <api_key>
54
+ <label>Token API</label>
55
+ <comment>You can find credentials on your Lengow Dashboard</comment>
56
  <frontend_type>text</frontend_type>
57
  <sort_order>20</sort_order>
58
  <show_in_default>1</show_in_default>
app/locale/fr_FR/Lengow_Connector.csv CHANGED
@@ -4,7 +4,7 @@
4
  "Ip authorised to export","Ip autorisée pour l'export"
5
  "Authorized acces to catalog export by IP, separated by ;","Autoriser l'accès de l'export du catalogue aux IPs séparées par des ;"
6
  "Export only selected product","Exporter uniquement les produits sélectionnés"
7
- "Export product out of stock","Exporter les produits sans stock"
8
  "Product type to export","Type de produit à exporter"
9
  "Status of product to export","Statut des produits à exporter"
10
  "Level max for category","Niveau maximum de profondeur de catégorie"
@@ -18,7 +18,7 @@
18
  "Default shipping cost if matching find","Coût par défaut de la livraison si aucune correspondance n'est trouvée"
19
  "Shipping method","Méthode de transport"
20
  "Default shipping method to calculate shipping cost","Méthode de transport par défaut pour calculer les frais d'envois"
21
- "Format","Format"
22
  "Performances","Performances"
23
  "Save feed on file","Sauvegarder le flux dans un fichier"
24
  "Save the feed on a file","Sauvegarder votre flux dans un fichier"
@@ -31,7 +31,7 @@
31
  "Feed configuration","Gestion des flux"
32
  "Manage Orders","Gestion des commandes"
33
  "Import orders from x days","Importer les commandes depuis x jours"
34
- "Choose period for Sync order","Sélectionner une période "
35
  "Auto import","Import automatique"
36
  "Enable import every 30 minutes","Activer l'import automatique toutes les 30 min"
37
  "Debug mode","Mode debug"
@@ -63,7 +63,7 @@
63
  "Attrib. Set Name","Nom attribut"
64
  "SKU","Ref"
65
  "Price","Prix"
66
- "Qty","Qty"
67
  "Visibility","Visibilité"
68
  "Status","Statut"
69
  "Publish on Lengow","Publié sur Lengow"
@@ -141,7 +141,7 @@
141
  "IP of your server","IP du serveur"
142
  "Your module is already updated","Votre module est bien à jour"
143
  "There is a new version %s of Lengow Module, please update it on your Magento Connect Manager !","Il y a une nouvelle version %s du module Lengow, merci de la mettre à jour avec votre Magento Connect Manager"
144
- "Make sure your website IP (%s) address is filled in your Lengow Dashboard.","Vérifier bien que l'adresse IP (%s) de votre site web est bien renseignée dans la Solution Lengow"
145
  "Click here to update it","Cliquez-ici pour la mettre à jour"
146
  "Tracker Product's identifiant","Identifiant produit à utiliser"
147
  "Stock without products ordering","Stock sans les produits en cours de commande"
@@ -157,7 +157,7 @@
157
  "Import an order in pendinf payment (like check or money order)","Importer une commande si elle est en attente de paiement (par exemple, une commande payé par chèque ou par virement)"
158
  "To change the date of import's order with the date of marketplace","Changer la date d'import de la commande avec la date d'achat sur les places de marchés"
159
  "Split name","Scinder les noms"
160
- "If one of the name fields is empty, the non-empty field will be split to fill the empty name field","Si le champs des marketplaces nom ou prénom est vide, le module sindéra le champs correctement renseigné en 2"
161
  "Keep html","Conserver le html"
162
  "Keep html chars in descrption","Conserver le <html> dans les descriptions"
163
  "Auto export new product","Exporter les nouveaux produits automatiquement"
@@ -168,8 +168,8 @@
168
  "Keep html for the selected fields","Garder l'HTML pour les champs sélectionnés"
169
  "Choose default shipping","Sélectionner le transporteur par défaut"
170
  "Default shipping method","La méthode de transport par défaut"
171
- "Use fake emails","Utilisation de faux emails"
172
- "Use fake emails for customer creation","Utilisation de faux emails pour la création de client"
173
  "Import is already started","Une importation est déjà en cours"
174
  "Please checks your plugin configuration. ID customer or token API is empty","Merci de vérifier votre configuration de plugin. L'ID client ou le token API est vide"
175
  "Please checks your plugin configuration. No store enabled to import","Merci de vérifier votre configuration de plugin. Aucune boutique active pour l'importation"
@@ -197,4 +197,9 @@
197
  "Code","Code"
198
  "Scheduled at","Date de planification"
199
  "Executed at","Date d'exécution"
200
- "Finished at","Date de fin"
 
 
 
 
 
4
  "Ip authorised to export","Ip autorisée pour l'export"
5
  "Authorized acces to catalog export by IP, separated by ;","Autoriser l'accès de l'export du catalogue aux IPs séparées par des ;"
6
  "Export only selected product","Exporter uniquement les produits sélectionnés"
7
+ "Export out of stock product","Export des produits dont les stocks sont à 0"
8
  "Product type to export","Type de produit à exporter"
9
  "Status of product to export","Statut des produits à exporter"
10
  "Level max for category","Niveau maximum de profondeur de catégorie"
18
  "Default shipping cost if matching find","Coût par défaut de la livraison si aucune correspondance n'est trouvée"
19
  "Shipping method","Méthode de transport"
20
  "Default shipping method to calculate shipping cost","Méthode de transport par défaut pour calculer les frais d'envois"
21
+ "Export default format","Format d'export par défaut"
22
  "Performances","Performances"
23
  "Save feed on file","Sauvegarder le flux dans un fichier"
24
  "Save the feed on a file","Sauvegarder votre flux dans un fichier"
31
  "Feed configuration","Gestion des flux"
32
  "Manage Orders","Gestion des commandes"
33
  "Import orders from x days","Importer les commandes depuis x jours"
34
+ "Choose a number of days","Indiquer le nombre de jours "
35
  "Auto import","Import automatique"
36
  "Enable import every 30 minutes","Activer l'import automatique toutes les 30 min"
37
  "Debug mode","Mode debug"
63
  "Attrib. Set Name","Nom attribut"
64
  "SKU","Ref"
65
  "Price","Prix"
66
+ "Qty","Qté"
67
  "Visibility","Visibilité"
68
  "Status","Statut"
69
  "Publish on Lengow","Publié sur Lengow"
141
  "IP of your server","IP du serveur"
142
  "Your module is already updated","Votre module est bien à jour"
143
  "There is a new version %s of Lengow Module, please update it on your Magento Connect Manager !","Il y a une nouvelle version %s du module Lengow, merci de la mettre à jour avec votre Magento Connect Manager"
144
+ "Make sure your website IP (%s) address is filled in your Lengow Dashboard.","Vérifiez bien que l'adresse IP (%s) de votre site web est bien renseignée dans la Solution Lengow"
145
  "Click here to update it","Cliquez-ici pour la mettre à jour"
146
  "Tracker Product's identifiant","Identifiant produit à utiliser"
147
  "Stock without products ordering","Stock sans les produits en cours de commande"
157
  "Import an order in pendinf payment (like check or money order)","Importer une commande si elle est en attente de paiement (par exemple, une commande payé par chèque ou par virement)"
158
  "To change the date of import's order with the date of marketplace","Changer la date d'import de la commande avec la date d'achat sur les places de marchés"
159
  "Split name","Scinder les noms"
160
+ "If one of the name fields is empty, the non-empty field will be split to fill the empty name field","Si les champs des marketplaces 'nom' ou 'prénom' sont vides, le module scindera le champ correctement renseigné en 2"
161
  "Keep html","Conserver le html"
162
  "Keep html chars in descrption","Conserver le <html> dans les descriptions"
163
  "Auto export new product","Exporter les nouveaux produits automatiquement"
168
  "Keep html for the selected fields","Garder l'HTML pour les champs sélectionnés"
169
  "Choose default shipping","Sélectionner le transporteur par défaut"
170
  "Default shipping method","La méthode de transport par défaut"
171
+ "Use fictitious emails","Utilisation d'emails fictifs"
172
+ "Use fictitious emails for customer creation","Utilisation d'emails fictifs pour la création de client"
173
  "Import is already started","Une importation est déjà en cours"
174
  "Please checks your plugin configuration. ID customer or token API is empty","Merci de vérifier votre configuration de plugin. L'ID client ou le token API est vide"
175
  "Please checks your plugin configuration. No store enabled to import","Merci de vérifier votre configuration de plugin. Aucune boutique active pour l'importation"
197
  "Code","Code"
198
  "Scheduled at","Date de planification"
199
  "Executed at","Date d'exécution"
200
+ "Finished at","Date de fin"
201
+ "Optimize Export File","Flux d'export optimisé"
202
+ "Beta feature: enable this option to get a faster export","Fonctionnalité en test : activez cette option pour profiter d'un export plus rapide"
203
+ "Purchased On","Date d'achat"
204
+ "You can find credentials on your Lengow Dashboard","Vous pouvez retrouver vos informations clients dans votre espace Lengow"
205
+ "Manage Feeds","Gestion des flux"
package.xml CHANGED
@@ -1,7 +1,7 @@
1
  <?xml version="1.0"?>
2
  <package>
3
  <name>Lengow_Export</name>
4
- <version>2.1.1</version>
5
  <stability>stable</stability>
6
  <license>GPL</license>
7
  <channel>community</channel>
@@ -11,9 +11,9 @@
11
  Export your catalog, import your orders from all Marketplaces.</description>
12
  <notes>New version of Lengow's Connector</notes>
13
  <authors><author><name>Ludovic</name><user>ludo</user><email>ludovic@lengow.com</email></author><author><name>Romain</name><user>romain</user><email>romain@lengow.com</email></author><author><name>Mathieu</name><user>mathieu</user><email>mathieu.sabourin@lengow.com</email></author><author><name>Benjamin</name><user>benjamin</user><email>benjamin.le-neve@lengow.com</email></author></authors>
14
- <date>2015-11-26</date>
15
- <time>14:18:41</time>
16
- <contents><target name="magecommunity"><dir name="Lengow"><dir name="Dashboard"><dir name="Block"><dir name="Adminhtml"><dir name="Dashboard"><file name="Charts.php" hash="71641cf5b1ccd6267b5566a025dc96a4"/><file name="Diagrams.php" hash="0aeb53d09f0a83d03ce66825283b0046"/></dir></dir></dir><dir name="Helper"><file name="Data.php" hash="7129af0e9ab390e0695f84865a02fdb5"/></dir><dir name="Model"><file name="Config.php" hash="7e0b019175b5ad29f0b70a6e43b5ebce"/></dir><dir name="etc"><file name="config.xml" hash="405a7ff301cf4c62818bbb178cd899f5"/></dir></dir><dir name="Export"><dir name="Block"><dir name="Adminhtml"><dir name="Product"><file name="Grid.php" hash="9299bea84d78c5c852e0b8f6c05b17b6"/></dir><file name="Product.php" hash="e043c5abef03d0c46ccd51e49c868cf9"/></dir></dir><dir name="Helper"><file name="Data.php" hash="3f6f4b46059a479394786987d66eb027"/><file name="Security.php" hash="c8771b29a19c2ef12796a3affc837ae5"/></dir><dir name="Model"><dir name="Catalog"><file name="Product.php" hash="5cefda415930c953311c8aad2cca5fda"/></dir><file name="Config.php" hash="fba4bed58d9c1a69d247b7cc7c0b6b64"/><dir name="Convert"><dir name="Parser"><file name="Product.php" hash="bc664380ca9d37256460613ecdbd8f92"/></dir></dir><dir name="Export"><dir name="Rewrite"><dir name="Catalog"><file name="Config.php" hash="e192cd30c6ed7e4cc370953c3ecd2367"/></dir></dir></dir><dir name="Feed"><file name="Abstract.php" hash="ed13409ab1c507b48b9460c8886bef8d"/><file name="Csv.php" hash="5958c0bdfc04dd33f59245fded2949d7"/><file name="Json.php" hash="4df743bce6647eea36d2677ab7f6a9a8"/><file name="Xml.php" hash="3202baa8a64b22bd7c39c1022a9b48c8"/><file name="Yaml.php" hash="f0c24bd481039c4fc13fa26ef7a4d1b9"/></dir><file name="Generate.php" hash="31f31de72d0452437ffdabe4ab1311d0"/><file name="Observer.php" hash="dcfeae8ac1130cd4f8e952b3d75d59b4"/><dir name="Shipping"><dir name="Carrier"><file name="Lengow.php" hash="685809c2367ec3509ecbf9f4d07f4661"/></dir></dir><dir name="Source"><file name="Attributes.php" hash="f8cae8fe1a7a15c7b4cd76503bffd053"/><file name="Types.php" hash="513868577816d51f6cc61e75ba43a938"/></dir><dir name="System"><dir name="Config"><dir name="Backend"><file name="Apikey.php" hash="140ba6e9cce1204fe0e0c50cf81762ec"/></dir><dir name="Source"><dir name="Category"><file name="Level.php" hash="a1875080def0c89a2bb4b4088f57eac8"/></dir><file name="Format.php" hash="fd069f484cc3ae0d914fb7a965789d9f"/><file name="Getattributes.php" hash="d42c66b3f0ed0c21d5e824400c0b1dc5"/><file name="Images.php" hash="e6ec93f301599ea91d69a1f4847e240d"/><file name="Status.php" hash="449b2bf3c121c3a07aab6072aa629a90"/><file name="Types.php" hash="cab52d0a7e34ff4629ad17d0a2c96362"/></dir></dir></dir></dir><dir name="controllers"><dir name="Adminhtml"><dir name="Lengow"><file name="ExportController.php" hash="1ee080105825d45ce474065e57a4e89e"/></dir></dir><file name="FeedController.php" hash="4ac4e3fa4f69099c89d951411bc51838"/></dir><dir name="etc"><file name="config.xml" hash="f4adcb9c0dd62272ffedaebe471aac6d"/><file name="system.xml" hash="04d019632939dc948d3b1acd0c9bb32b"/></dir></dir><dir name="Feed"><dir name="Block"><dir name="Adminhtml"><dir name="Feed"><file name="Grid.php" hash="74fcb8c472666b89d9ba550357102c38"/><dir name="Renderer"><file name="Migrate.php" hash="a6a1fd08b4269b052d8c9ed447589ae3"/><file name="Select.php" hash="78808e9061b7a5aa73c2273f18bc0746"/><file name="Url.php" hash="2a3c4fa22460806dda478a088a17ced7"/></dir></dir><file name="Feed.php" hash="30e2d20268eb24bbcc9554ba97e5149e"/></dir></dir><dir name="Helper"><file name="Data.php" hash="799d69122855da8c287b86e663f3562d"/></dir><dir name="Model"><file name="Config.php" hash="7487c73a3fe292614c9f4a2b66d8a664"/><file name="Feed.php" hash="9e7096ba72dcb071662842c681e50928"/></dir><dir name="controllers"><dir name="Adminhtml"><dir name="Lengow"><file name="FeedController.php" hash="964721ca7619b7c1f16b66d13fed2a54"/></dir></dir></dir><dir name="etc"><file name="config.xml" hash="8002389dc536a9c705cd491dd64e9b8e"/><file name="system.xml" hash="81e6692a37fead4aaa02a4e255ce8464"/></dir></dir><dir name="Sync"><dir name="Block"><dir name="Adminhtml"><dir name="Cron"><file name="Grid.php" hash="ac84c0ace4548928d5e7706a67eac7c1"/></dir><file name="Cron.php" hash="0be9b2a4d2b751d54a51bd1f1e5a15d3"/><file name="Import.php" hash="832bc82dde18ae4bc886933b28f41885"/><dir name="Log"><file name="Grid.php" hash="31416dda25b833416ef9dad2143b2d9f"/></dir><file name="Log.php" hash="e4032e885dbbdd0c3f4112efbc8ef5a2"/><dir name="Order"><file name="Grid.php" hash="313ea7fde1df56b36159e5d37a757ac9"/><file name="Tab.php" hash="405c887f100b259ba9750088b1c17b44"/></dir><file name="Order.php" hash="c5cecae61feb8dacd348124ba3a2ffef"/></dir><dir name="Payment"><dir name="Info"><file name="Purchaseorder.php" hash="ccf3a1c41c21d1ffd315819be1808fec"/></dir></dir></dir><dir name="Helper"><file name="Api.php" hash="e8846c81d34c1025579151c7372492fb"/><file name="Cron.php" hash="cf6c9289006e4bdea116e90ba8ec8d10"/><file name="Data.php" hash="d66a6bf80a4d4cb86aa793ad10e4aef3"/></dir><dir name="Model"><file name="Config.php" hash="938e26ef034db15e8a3d977b1a665e25"/><dir name="Connector"><file name="Exception.php" hash="de1fa1b69e24fe7b976c03f1ed1ca7f7"/></dir><file name="Connector.php" hash="544000640f47a5e12482138b1d920ce8"/><dir name="Customer"><file name="Customer.php" hash="2cb9388279a880b8bd602f4b026c9162"/></dir><file name="File.php" hash="d5c9e6af9ca7c7c6013430327b2019df"/><file name="Import.php" hash="773149f38880af977721af9ffb65f70f"/><file name="Log.php" hash="29e1e489b6d125fe64d91693f987a502"/><dir name="Marketplace"><file name="Exception.php" hash="bd7ab8db94e241d022cd6e467e8596ec"/></dir><file name="Marketplace.php" hash="19c8254e80a459b7304a75dc84afd280"/><dir name="Mysql4"><dir name="Log"><file name="Collection.php" hash="22e087b5cfee173440877dd0714fee55"/></dir><file name="Log.php" hash="ab90ef25ea4f6369f713325b6ba247e5"/></dir><file name="Observer.php" hash="32e0c71fa9b39308983efdee11eb8ac2"/><file name="Order.php" hash="fd722ee55aa18db7f0d84cd80f00547e"/><dir name="Payment"><dir name="Method"><file name="Lengow.php" hash="34c96c7a150ee18598301f57dbc707bc"/></dir></dir><dir name="Quote"><file name="Exception.php" hash="7002f0d752509f576352e7bbd78b590c"/><file name="Item.php" hash="30f9faf6b299ef64f10785ba16030a17"/></dir><file name="Quote.php" hash="725f739d4664e5bc5da424aa1f6b3df1"/><dir name="Shipping"><dir name="Carrier"><file name="Lengow.php" hash="8340d3cef16fc86306d626a71d2e9ebc"/></dir></dir><dir name="System"><dir name="Config"><dir name="Source"><dir name="Customer"><file name="Group.php" hash="640638dcee398949ec4d0c1e2731005d"/></dir><dir name="Shipping"><file name="Carrier.php" hash="f83fd1e7fb5c2bd50d2ba983e24b6240"/><file name="Method.php" hash="8df07e95712559dad4b37bde3acf9f77"/></dir></dir></dir></dir></dir><dir name="controllers"><dir name="Adminhtml"><dir name="Lengow"><file name="DebugController.php" hash="a0197d3783c806e97aed734378735014"/><file name="LogController.php" hash="118fa3fdb4aa3fdd70a7bfb06c7174a2"/><file name="OrderController.php" hash="13b50921f4cb1a5148195e92345602a8"/></dir></dir><file name="ApiController.php" hash="3d62e46fd860b326f288c5869fbe3389"/></dir><dir name="etc"><file name="config.xml" hash="0ec189f2fece1b334f8f5c2018d9de8b"/><file name="marketplaces.xml" hash="e8f110f4a879bc522effc70ec71eb65f"/><file name="system.xml" hash="0366aaf26d72400188bffbc11f85524c"/><file name="wsdl.xml" hash="d299fecf68e9f795e26037be4f2115b3"/></dir><dir name="sql"><dir name="lengow_setup"><file name="mysql4-install-2.0.0.0.php" hash="6856dcca18117fb112e6523139fb47c5"/><file name="mysql4-upgrade-2.0.0.0-2.0.0.1.php" hash="92edfe3518259e1a11213cc80ccaeb34"/><file name="mysql4-upgrade-2.0.2-2.1.0.php" hash="187da13f6ae76378f1118bbf5acaf683"/></dir></dir></dir><dir name="Tracker"><dir name="Block"><dir name="Adminhtml"><dir name="System"><dir name="Config"><dir name="Check"><file name="Point.php" hash="de29cb19427434c1713d2dae9c97900a"/></dir><file name="Check.php" hash="877fd7a030feff2ad8bc561a3785be5b"/></dir></dir></dir><dir name="Tag"><file name="Capsule.php" hash="d2ed189be29fd76f6ceb0b8d68f21efe"/><file name="Simple.php" hash="ff8fe8fa9767b75de69f5f8e2dfa6ba1"/></dir><file name="Tracker.php" hash="3bdb94f577a831310f8f12f854739906"/></dir><dir name="Helper"><file name="Check.php" hash="01f7145b0963867f78c29ec53e5ea5b7"/><file name="Data.php" hash="e526694354fe760f266bf925e5e4ac39"/></dir><dir name="Model"><file name="Capsule.php" hash="55504d0b6398f5a88b5977bf54f5b54b"/><file name="Config.php" hash="7848ae5ddc1f2617effa39e27b3e838e"/><dir name="System"><dir name="Config"><dir name="Source"><file name="Identifiant.php" hash="51943c288cab9456c62a2130405b695b"/><file name="Tracker.php" hash="8fdc4f1d9f02300525aeb295e9cd3dfc"/></dir></dir></dir><file name="Tracker.php" hash="4c740aa3a311a93b8143a69fd1ea3221"/></dir><dir name="etc"><file name="config.xml" hash="c4fd5a45956aa46ed3da05d51800549a"/><file name="plugins.xml" hash="e35408d7ea61c7ccc669cfb5b7bb8567"/><file name="system.xml" hash="e80c43066774e6fdf6e164bf06bf38ee"/></dir></dir></dir></target><target name="magedesign"><dir name="adminhtml"><dir name="default"><dir name="default"><dir name="layout"><file name="lengow.xml" hash="359ec9ffc2b7f6785750ef0a760b7c6b"/></dir><dir name="template"><dir name="lengow"><dir name="check"><file name="point.phtml" hash="9791a2a673d45bb6db850ec802c63a71"/></dir><dir name="dashboard"><file name="charts.phtml" hash="51964c7bcace68d8f4ef23e314f07a8c"/></dir><dir name="debug"><file name="index.phtml" hash="23df3288336269a12024f13ed3ae0023"/></dir><dir name="export"><file name="product.phtml" hash="8c0c893621573c316bb7da14a3533224"/></dir><dir name="feed"><file name="grid.phtml" hash="b34e7f8ce18ce9605e88a5bc8b806442"/></dir><dir name="sales"><dir name="order"><dir name="tab"><file name="info.phtml" hash="fcaa52401ea83b17e52d0db2f8367b93"/></dir></dir><dir name="payment"><dir name="info"><file name="purchaseorder.phtml" hash="8e9e7a287ef57fe72023e28747fb0864"/></dir></dir></dir></dir></dir></dir></dir></dir><dir name="frontend"><dir name="base"><dir name="default"><dir name="layout"><file name="lengow.xml" hash="0e6a4eb11f6433d54474bfed8061d560"/></dir><dir name="template"><dir name="lengow"><dir name="tracker"><file name="simpletag.phtml" hash="3b73552b323d00bd053e1086e6f5ff45"/><file name="tag.phtml" hash="619f7bc6fe20c3dd6c1d82cdf12811b5"/><file name="tagcapsule.phtml" hash="2916e7693ef8ec9fcce5f5a8079d2beb"/></dir></dir></dir></dir></dir></dir></target><target name="magelocale"><dir name="fr_FR"><file name="Lengow_Connector.csv" hash="4913a36467b3a1893131839b68b8dd91"/></dir></target><target name="mageetc"><dir name="modules"><file name="Lengow_Connector.xml" hash="34b39beecc725740ea1e0bc8d339287a"/></dir></target><target name="magemedia"><dir name="lengow"><file name="import.flag" hash="d41d8cd98f00b204e9800998ecf8427e"/></dir></target><target name="mageskin"><dir name="adminhtml"><dir name="default"><dir name="default"><dir name="lengow"><dir name="css"><file name="admin.css" hash="45e6eca21d130d11c1e6fda8dae35f3d"/></dir><dir name="js"><file name="charts.min.js" hash="6806368c6a0bf73a5236b452fd5c2332"/></dir></dir></dir></dir></dir><dir name="frontend"><dir name="base"><dir name="default"><dir name="lengow"><dir name="js"><file name="tracker.js" hash="6402a4fbbb81a3b0587ec8c4c375e0a0"/></dir></dir></dir></dir></dir></target></contents>
17
  <compatible/>
18
  <dependencies><required><php><min>5.2.0</min><max>6.0.0</max></php></required></dependencies>
19
  </package>
1
  <?xml version="1.0"?>
2
  <package>
3
  <name>Lengow_Export</name>
4
+ <version>2.1.2</version>
5
  <stability>stable</stability>
6
  <license>GPL</license>
7
  <channel>community</channel>
11
  Export your catalog, import your orders from all Marketplaces.</description>
12
  <notes>New version of Lengow's Connector</notes>
13
  <authors><author><name>Ludovic</name><user>ludo</user><email>ludovic@lengow.com</email></author><author><name>Romain</name><user>romain</user><email>romain@lengow.com</email></author><author><name>Mathieu</name><user>mathieu</user><email>mathieu.sabourin@lengow.com</email></author><author><name>Benjamin</name><user>benjamin</user><email>benjamin.le-neve@lengow.com</email></author></authors>
14
+ <date>2015-12-18</date>
15
+ <time>15:31:38</time>
16
+ <contents><target name="magecommunity"><dir name="Lengow"><dir name="Dashboard"><dir name="Block"><dir name="Adminhtml"><dir name="Dashboard"><file name="Charts.php" hash="71641cf5b1ccd6267b5566a025dc96a4"/><file name="Diagrams.php" hash="0aeb53d09f0a83d03ce66825283b0046"/></dir></dir></dir><dir name="Helper"><file name="Data.php" hash="7129af0e9ab390e0695f84865a02fdb5"/></dir><dir name="Model"><file name="Config.php" hash="7e0b019175b5ad29f0b70a6e43b5ebce"/></dir><dir name="etc"><file name="config.xml" hash="dd71373a31043cba10ccc224be5d2f98"/></dir></dir><dir name="Export"><dir name="Block"><dir name="Adminhtml"><dir name="Product"><file name="Grid.php" hash="9299bea84d78c5c852e0b8f6c05b17b6"/></dir><file name="Product.php" hash="e043c5abef03d0c46ccd51e49c868cf9"/></dir></dir><dir name="Helper"><file name="Data.php" hash="56be39f342b500f7a59c2a17c95527cd"/><file name="Security.php" hash="c8771b29a19c2ef12796a3affc837ae5"/></dir><dir name="Model"><dir name="Catalog"><file name="Product.php" hash="4b97758ec4e6b2f4d6a0cf51ac1721cb"/></dir><file name="Config.php" hash="fba4bed58d9c1a69d247b7cc7c0b6b64"/><dir name="Convert"><dir name="Parser"><file name="Product.php" hash="bc664380ca9d37256460613ecdbd8f92"/></dir></dir><dir name="Export"><dir name="Rewrite"><dir name="Catalog"><file name="Config.php" hash="e192cd30c6ed7e4cc370953c3ecd2367"/></dir></dir></dir><dir name="Feed"><file name="Abstract.php" hash="ed13409ab1c507b48b9460c8886bef8d"/><file name="Csv.php" hash="5958c0bdfc04dd33f59245fded2949d7"/><file name="Json.php" hash="4df743bce6647eea36d2677ab7f6a9a8"/><file name="Xml.php" hash="7c1a17b034a6b249da39ac9948227f88"/><file name="Yaml.php" hash="76070611f6a0b8eb6c63503ab4116c22"/></dir><file name="Generate.php" hash="544a0a21f81c25035fad0b285d9227d2"/><file name="Generateoptimize.php" hash="6b9576eb488e00384d33b810024b58a8"/><file name="Observer.php" hash="8cb4a5de53497658357410ccd49b1a5d"/><dir name="Product"><file name="Collection.php" hash="3c9c30d1b08dd8f291438358a4ee21fb"/></dir><dir name="Resource"><dir name="Catalog"><file name="Product.php" hash="b1daebdecf6504804fcab3085de51667"/></dir></dir><dir name="Shipping"><dir name="Carrier"><file name="Lengow.php" hash="685809c2367ec3509ecbf9f4d07f4661"/></dir></dir><dir name="Source"><file name="Attributes.php" hash="f8cae8fe1a7a15c7b4cd76503bffd053"/><file name="Types.php" hash="513868577816d51f6cc61e75ba43a938"/></dir><dir name="System"><dir name="Config"><dir name="Backend"><file name="Apikey.php" hash="140ba6e9cce1204fe0e0c50cf81762ec"/></dir><dir name="Source"><dir name="Category"><file name="Level.php" hash="a1875080def0c89a2bb4b4088f57eac8"/></dir><file name="Format.php" hash="fd069f484cc3ae0d914fb7a965789d9f"/><file name="Getattributes.php" hash="d42c66b3f0ed0c21d5e824400c0b1dc5"/><file name="Images.php" hash="e6ec93f301599ea91d69a1f4847e240d"/><file name="Status.php" hash="449b2bf3c121c3a07aab6072aa629a90"/><file name="Types.php" hash="cab52d0a7e34ff4629ad17d0a2c96362"/></dir></dir></dir></dir><dir name="controllers"><dir name="Adminhtml"><dir name="Lengow"><file name="ExportController.php" hash="722a7c72d7cb9885e42531e2cfa719bc"/></dir></dir><file name="FeedController.php" hash="19fa16a8970e13c863f4da7018fdd837"/></dir><dir name="etc"><file name="config.xml" hash="18e5d0159c3dc2c41f103ddf9821dbbf"/><file name="system.xml" hash="5f7838932242b134766fd20385ac5547"/></dir></dir><dir name="Feed"><dir name="Block"><dir name="Adminhtml"><dir name="Feed"><file name="Grid.php" hash="74fcb8c472666b89d9ba550357102c38"/><dir name="Renderer"><file name="Migrate.php" hash="a6a1fd08b4269b052d8c9ed447589ae3"/><file name="Select.php" hash="78808e9061b7a5aa73c2273f18bc0746"/><file name="Url.php" hash="2a3c4fa22460806dda478a088a17ced7"/></dir></dir><file name="Feed.php" hash="30e2d20268eb24bbcc9554ba97e5149e"/></dir></dir><dir name="Helper"><file name="Data.php" hash="799d69122855da8c287b86e663f3562d"/></dir><dir name="Model"><file name="Config.php" hash="7487c73a3fe292614c9f4a2b66d8a664"/><file name="Feed.php" hash="9e7096ba72dcb071662842c681e50928"/></dir><dir name="controllers"><dir name="Adminhtml"><dir name="Lengow"><file name="FeedController.php" hash="c808d1b5afc0aef6145ecb187d84b93b"/></dir></dir></dir><dir name="etc"><file name="config.xml" hash="d1fa57ae0a66c365e783a0aea0a233cb"/><file name="system.xml" hash="81e6692a37fead4aaa02a4e255ce8464"/></dir></dir><dir name="Sync"><dir name="Block"><dir name="Adminhtml"><dir name="Cron"><file name="Grid.php" hash="ac84c0ace4548928d5e7706a67eac7c1"/></dir><file name="Cron.php" hash="0be9b2a4d2b751d54a51bd1f1e5a15d3"/><file name="Import.php" hash="832bc82dde18ae4bc886933b28f41885"/><dir name="Log"><file name="Grid.php" hash="31416dda25b833416ef9dad2143b2d9f"/></dir><file name="Log.php" hash="e4032e885dbbdd0c3f4112efbc8ef5a2"/><dir name="Order"><file name="Grid.php" hash="313ea7fde1df56b36159e5d37a757ac9"/><file name="Tab.php" hash="405c887f100b259ba9750088b1c17b44"/></dir><file name="Order.php" hash="c5cecae61feb8dacd348124ba3a2ffef"/></dir><dir name="Payment"><dir name="Info"><file name="Purchaseorder.php" hash="ccf3a1c41c21d1ffd315819be1808fec"/></dir></dir></dir><dir name="Helper"><file name="Api.php" hash="e8846c81d34c1025579151c7372492fb"/><file name="Cron.php" hash="cf6c9289006e4bdea116e90ba8ec8d10"/><file name="Data.php" hash="d66a6bf80a4d4cb86aa793ad10e4aef3"/></dir><dir name="Model"><file name="Config.php" hash="938e26ef034db15e8a3d977b1a665e25"/><dir name="Connector"><file name="Exception.php" hash="de1fa1b69e24fe7b976c03f1ed1ca7f7"/></dir><file name="Connector.php" hash="544000640f47a5e12482138b1d920ce8"/><dir name="Customer"><file name="Customer.php" hash="2cb9388279a880b8bd602f4b026c9162"/></dir><file name="File.php" hash="d5c9e6af9ca7c7c6013430327b2019df"/><file name="Import.php" hash="1e019c7a66e5c84c68b65c1bd97a3998"/><file name="Log.php" hash="29e1e489b6d125fe64d91693f987a502"/><dir name="Marketplace"><file name="Exception.php" hash="bd7ab8db94e241d022cd6e467e8596ec"/></dir><file name="Marketplace.php" hash="19c8254e80a459b7304a75dc84afd280"/><dir name="Mysql4"><dir name="Log"><file name="Collection.php" hash="22e087b5cfee173440877dd0714fee55"/></dir><file name="Log.php" hash="ab90ef25ea4f6369f713325b6ba247e5"/></dir><file name="Observer.php" hash="9936599d8144bc4bb32886e7a099a8b3"/><file name="Order.php" hash="fd722ee55aa18db7f0d84cd80f00547e"/><dir name="Payment"><dir name="Method"><file name="Lengow.php" hash="34c96c7a150ee18598301f57dbc707bc"/></dir></dir><dir name="Quote"><file name="Item.php" hash="21408439544f076502b636dd6003877d"/></dir><file name="Quote.php" hash="6014d07add187c806711815bae806f92"/><dir name="Shipping"><dir name="Carrier"><file name="Lengow.php" hash="8340d3cef16fc86306d626a71d2e9ebc"/></dir></dir><dir name="System"><dir name="Config"><dir name="Source"><dir name="Customer"><file name="Group.php" hash="640638dcee398949ec4d0c1e2731005d"/></dir><dir name="Shipping"><file name="Carrier.php" hash="f83fd1e7fb5c2bd50d2ba983e24b6240"/><file name="Method.php" hash="8df07e95712559dad4b37bde3acf9f77"/></dir></dir></dir></dir></dir><dir name="controllers"><dir name="Adminhtml"><dir name="Lengow"><file name="DebugController.php" hash="a0197d3783c806e97aed734378735014"/><file name="LogController.php" hash="6d643758cbd902fa32bc2f7468863655"/><file name="OrderController.php" hash="563070e0408429d0d788ca65fff83f4f"/></dir></dir><file name="ApiController.php" hash="3d62e46fd860b326f288c5869fbe3389"/></dir><dir name="etc"><file name="config.xml" hash="19d57bb45b5e6dcc18ab359bd9c818a3"/><file name="marketplaces.xml" hash="d71cd7ac07791fd82156243f2a573d83"/><file name="system.xml" hash="bd484e8b456802c5c894e52b4cbcd188"/><file name="wsdl.xml" hash="d299fecf68e9f795e26037be4f2115b3"/></dir><dir name="sql"><dir name="lengow_setup"><file name="mysql4-install-2.0.0.0.php" hash="6856dcca18117fb112e6523139fb47c5"/><file name="mysql4-upgrade-2.0.0.0-2.0.0.1.php" hash="92edfe3518259e1a11213cc80ccaeb34"/><file name="mysql4-upgrade-2.0.2-2.1.0.php" hash="187da13f6ae76378f1118bbf5acaf683"/></dir></dir></dir><dir name="Tracker"><dir name="Block"><dir name="Adminhtml"><dir name="System"><dir name="Config"><dir name="Check"><file name="Point.php" hash="de29cb19427434c1713d2dae9c97900a"/></dir><file name="Check.php" hash="877fd7a030feff2ad8bc561a3785be5b"/></dir></dir></dir><dir name="Tag"><file name="Capsule.php" hash="d2ed189be29fd76f6ceb0b8d68f21efe"/><file name="Simple.php" hash="ff8fe8fa9767b75de69f5f8e2dfa6ba1"/></dir><file name="Tracker.php" hash="3bdb94f577a831310f8f12f854739906"/></dir><dir name="Helper"><file name="Check.php" hash="01f7145b0963867f78c29ec53e5ea5b7"/><file name="Data.php" hash="e526694354fe760f266bf925e5e4ac39"/></dir><dir name="Model"><file name="Capsule.php" hash="55504d0b6398f5a88b5977bf54f5b54b"/><file name="Config.php" hash="7848ae5ddc1f2617effa39e27b3e838e"/><dir name="System"><dir name="Config"><dir name="Source"><file name="Identifiant.php" hash="51943c288cab9456c62a2130405b695b"/><file name="Tracker.php" hash="8fdc4f1d9f02300525aeb295e9cd3dfc"/></dir></dir></dir><file name="Tracker.php" hash="4c740aa3a311a93b8143a69fd1ea3221"/></dir><dir name="etc"><file name="config.xml" hash="67dc95e5e0b9434e4efafed5c3b21423"/><file name="plugins.xml" hash="e35408d7ea61c7ccc669cfb5b7bb8567"/><file name="system.xml" hash="ec32d45005f85f1bbc42ace04e1d82c6"/></dir></dir></dir></target><target name="magedesign"><dir name="adminhtml"><dir name="default"><dir name="default"><dir name="layout"><file name="lengow.xml" hash="359ec9ffc2b7f6785750ef0a760b7c6b"/></dir><dir name="template"><dir name="lengow"><dir name="check"><file name="point.phtml" hash="9791a2a673d45bb6db850ec802c63a71"/></dir><dir name="dashboard"><file name="charts.phtml" hash="51964c7bcace68d8f4ef23e314f07a8c"/></dir><dir name="debug"><file name="index.phtml" hash="23df3288336269a12024f13ed3ae0023"/></dir><dir name="export"><file name="product.phtml" hash="8c0c893621573c316bb7da14a3533224"/></dir><dir name="feed"><file name="grid.phtml" hash="b34e7f8ce18ce9605e88a5bc8b806442"/></dir><dir name="sales"><dir name="order"><dir name="tab"><file name="info.phtml" hash="fcaa52401ea83b17e52d0db2f8367b93"/></dir></dir><dir name="payment"><dir name="info"><file name="purchaseorder.phtml" hash="8e9e7a287ef57fe72023e28747fb0864"/></dir></dir></dir></dir></dir></dir></dir></dir><dir name="frontend"><dir name="base"><dir name="default"><dir name="layout"><file name="lengow.xml" hash="0e6a4eb11f6433d54474bfed8061d560"/></dir><dir name="template"><dir name="lengow"><dir name="tracker"><file name="simpletag.phtml" hash="3b73552b323d00bd053e1086e6f5ff45"/><file name="tag.phtml" hash="619f7bc6fe20c3dd6c1d82cdf12811b5"/><file name="tagcapsule.phtml" hash="2916e7693ef8ec9fcce5f5a8079d2beb"/></dir></dir></dir></dir></dir></dir></target><target name="magelocale"><dir name="fr_FR"><file name="Lengow_Connector.csv" hash="5e5fca3304dd740615344a6cb8ee47ed"/></dir></target><target name="mageetc"><dir name="modules"><file name="Lengow_Connector.xml" hash="34b39beecc725740ea1e0bc8d339287a"/></dir></target><target name="magemedia"><dir name="lengow"><file name="import.flag" hash="d41d8cd98f00b204e9800998ecf8427e"/></dir></target><target name="mageskin"><dir name="adminhtml"><dir name="default"><dir name="default"><dir name="lengow"><dir name="css"><file name="admin.css" hash="45e6eca21d130d11c1e6fda8dae35f3d"/></dir><dir name="js"><file name="charts.min.js" hash="6806368c6a0bf73a5236b452fd5c2332"/></dir></dir></dir></dir></dir><dir name="frontend"><dir name="base"><dir name="default"><dir name="lengow"><dir name="js"><file name="tracker.js" hash="6402a4fbbb81a3b0587ec8c4c375e0a0"/></dir></dir></dir></dir></dir></target></contents>
17
  <compatible/>
18
  <dependencies><required><php><min>5.2.0</min><max>6.0.0</max></php></required></dependencies>
19
  </package>