From c40121432300eb15e64a95b8692adc31edc3dcd8 Mon Sep 17 00:00:00 2001 From: wucherpfennig Date: Wed, 5 Jul 2017 14:56:31 +0200 Subject: [PATCH 1/5] Update MappingCodeAttributeValues.php fix for numeric keys = "0" --- .../models/core/mapping/MappingCodeAttributeValues.php | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/modules/prestaneo/models/core/mapping/MappingCodeAttributeValues.php b/modules/prestaneo/models/core/mapping/MappingCodeAttributeValues.php index 7b78dd6..aa2e77b 100644 --- a/modules/prestaneo/models/core/mapping/MappingCodeAttributeValues.php +++ b/modules/prestaneo/models/core/mapping/MappingCodeAttributeValues.php @@ -24,8 +24,10 @@ class MappingCodeAttributeValues extends MappingCodeAbstract */ public static function getIdByCodeAndGroup($code, $attributeGroupCode) { - if (empty($code) || !$code || empty($attributeGroupCode) || !$attributeGroupCode) - return false; + if(!is_numeric($code)){ + if (empty($code) || !$code || empty($attributeGroupCode) || !$attributeGroupCode) + return false; + } $sql = 'SELECT `' . self::$definition['primary'] . '` FROM ' . _DB_PREFIX_ . self::$definition['table'] . ' @@ -35,4 +37,4 @@ public static function getIdByCodeAndGroup($code, $attributeGroupCode) return Db::getInstance()->getValue($sql); } -} \ No newline at end of file +} From 030d37f65e73784f51fdfa9433b4e0cf143e172b Mon Sep 17 00:00:00 2001 From: wucherpfennig Date: Wed, 5 Jul 2017 14:57:29 +0200 Subject: [PATCH 2/5] Update MappingCodeFeatureValues.php fix for numeric keys = "0" --- .../models/core/mapping/MappingCodeFeatureValues.php | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/modules/prestaneo/models/core/mapping/MappingCodeFeatureValues.php b/modules/prestaneo/models/core/mapping/MappingCodeFeatureValues.php index 3fbcb86..17b7361 100644 --- a/modules/prestaneo/models/core/mapping/MappingCodeFeatureValues.php +++ b/modules/prestaneo/models/core/mapping/MappingCodeFeatureValues.php @@ -24,8 +24,10 @@ class MappingCodeFeatureValues extends MappingCodeAbstract */ public static function getIdByCodeAndFeature($code, $featureCode) { - if (empty($code) || !$code || empty($featureCode) || !$featureCode) - return false; + if(!is_numeric($code)){ + if (empty($code) || !$code || empty($featureCode) || !$featureCode) + return false; + } $sql = 'SELECT `' . self::$definition['primary'] . '` FROM ' . _DB_PREFIX_ . self::$definition['table'] . ' @@ -35,4 +37,4 @@ public static function getIdByCodeAndFeature($code, $featureCode) return Db::getInstance()->getValue($sql); } -} \ No newline at end of file +} From 004f61d7d1c767a0e6e902cfcd90ff5c6c13b04a Mon Sep 17 00:00:00 2001 From: wucherpfennig Date: Wed, 5 Jul 2017 20:02:31 +0200 Subject: [PATCH 3/5] QUICK FIX, added stock update functionality Hard coded for field 'stock'... --- modules/prestaneo/models/import/product.php | 17 ++++++++++++++++- 1 file changed, 16 insertions(+), 1 deletion(-) diff --git a/modules/prestaneo/models/import/product.php b/modules/prestaneo/models/import/product.php index 2e4188d..348a692 100644 --- a/modules/prestaneo/models/import/product.php +++ b/modules/prestaneo/models/import/product.php @@ -188,6 +188,9 @@ public function process() $reference = $data[$referenceOffset]; $groupCode = $data[$this->_offsets['special']['groups']]; + // QUICK FIX: Helper for Stock Update + $dataKeyValue = array_combine($headers, $data); + $data['emptyValue'] = ''; $data['zeroValue'] = 0; @@ -368,6 +371,12 @@ public function process() //Product has been saved $processedProducts[$product->id] = $product; + // QUICK FIX: Save Stock for non Variant products + if (isset($dataKeyValue['stock'])) { + $quantity = ($dataKeyValue['stock']) ? $dataKeyValue['stock'] : $this->_quantityDefault; + StockAvailable::setQuantity($product->id, 0, $quantity, $defaultShopId); + } + // Save Features if ($this->_resetFeatures) { if (!$product->deleteFeatures()) { @@ -778,6 +787,12 @@ protected function addOrUpdateProductAttributeCombination(Product $product, $att $combination->setImages($images); $combination->update(); + + // QUICK FIX: Save Stock for non Variant products + if (isset($dataKeyValue['stock'])) { + $quantity = ($dataKeyValue['stock']) ? $dataKeyValue['stock'] : $this->_quantityDefault; + StockAvailable::setQuantity($product->id, $combination->id, $quantity); + } StockAvailable::setProductDependsOnStock($product->id, $product->depends_on_stock, null, $productAttributeId); StockAvailable::setProductOutOfStock($product->id, $product->out_of_stock, null, $productAttributeId); @@ -1012,4 +1027,4 @@ protected function _saveCustomFeature($product, $featureId, $featureCode, $value return true; } -} \ No newline at end of file +} From e8426c40cfc4cd4de755fe26afb21973bafbb4d6 Mon Sep 17 00:00:00 2001 From: wucherpfennig Date: Tue, 29 Aug 2017 09:49:41 +0200 Subject: [PATCH 4/5] Update category.php empty returns true with fields containing "0". see: http://php.net/manual/en/function.empty.php --- modules/prestaneo/models/import/category.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/modules/prestaneo/models/import/category.php b/modules/prestaneo/models/import/category.php index c6c7207..d832d26 100644 --- a/modules/prestaneo/models/import/category.php +++ b/modules/prestaneo/models/import/category.php @@ -142,7 +142,7 @@ public function process() $data[$this->_offsets['default']['id_shop_default']] = $contextShopId; } - if (empty($data[$this->_offsets['default']['active']])) { + if (!isset($data[$this->_offsets['default']['active']])) { $data[$this->_offsets['default']['active']] = 1; } @@ -424,4 +424,4 @@ protected function _reorderByCategoryId($categoryId, $shopId) return $return; } -} \ No newline at end of file +} From d702007c59b37ca0207666b5e74cc757c2d84e78 Mon Sep 17 00:00:00 2001 From: wucherpfennig Date: Wed, 6 Sep 2017 09:01:43 +0200 Subject: [PATCH 5/5] Revert "0.1.5 custom" --- README.md | 2 +- .../core/mapping/MappingCodeAttributeValues.php | 8 +++----- .../core/mapping/MappingCodeFeatureValues.php | 8 +++----- modules/prestaneo/models/import/product.php | 17 +---------------- 4 files changed, 8 insertions(+), 27 deletions(-) diff --git a/README.md b/README.md index b6bb3c6..dfaaec6 100644 --- a/README.md +++ b/README.md @@ -20,7 +20,7 @@ Prestaneo reads standard CSV files from the Akeneo exports in order to import da * **Multi-site**: Prestaneo is natively compatible with the “multi-store” and the “multi-language” features of Prestashop. ## Requirements -**Prestaneo** is designed to work on **Prestashop 1.5** & **Prestashop 1.6** based on generated CSV files from **Akeneo 1.3+** +**Prestaneo** is designed to work on **Prestashop 1.5+** based on generated CSV files from **Akeneo 1.3+** PHP : **PHP 5.3+** diff --git a/modules/prestaneo/models/core/mapping/MappingCodeAttributeValues.php b/modules/prestaneo/models/core/mapping/MappingCodeAttributeValues.php index aa2e77b..7b78dd6 100644 --- a/modules/prestaneo/models/core/mapping/MappingCodeAttributeValues.php +++ b/modules/prestaneo/models/core/mapping/MappingCodeAttributeValues.php @@ -24,10 +24,8 @@ class MappingCodeAttributeValues extends MappingCodeAbstract */ public static function getIdByCodeAndGroup($code, $attributeGroupCode) { - if(!is_numeric($code)){ - if (empty($code) || !$code || empty($attributeGroupCode) || !$attributeGroupCode) - return false; - } + if (empty($code) || !$code || empty($attributeGroupCode) || !$attributeGroupCode) + return false; $sql = 'SELECT `' . self::$definition['primary'] . '` FROM ' . _DB_PREFIX_ . self::$definition['table'] . ' @@ -37,4 +35,4 @@ public static function getIdByCodeAndGroup($code, $attributeGroupCode) return Db::getInstance()->getValue($sql); } -} +} \ No newline at end of file diff --git a/modules/prestaneo/models/core/mapping/MappingCodeFeatureValues.php b/modules/prestaneo/models/core/mapping/MappingCodeFeatureValues.php index 17b7361..3fbcb86 100644 --- a/modules/prestaneo/models/core/mapping/MappingCodeFeatureValues.php +++ b/modules/prestaneo/models/core/mapping/MappingCodeFeatureValues.php @@ -24,10 +24,8 @@ class MappingCodeFeatureValues extends MappingCodeAbstract */ public static function getIdByCodeAndFeature($code, $featureCode) { - if(!is_numeric($code)){ - if (empty($code) || !$code || empty($featureCode) || !$featureCode) - return false; - } + if (empty($code) || !$code || empty($featureCode) || !$featureCode) + return false; $sql = 'SELECT `' . self::$definition['primary'] . '` FROM ' . _DB_PREFIX_ . self::$definition['table'] . ' @@ -37,4 +35,4 @@ public static function getIdByCodeAndFeature($code, $featureCode) return Db::getInstance()->getValue($sql); } -} +} \ No newline at end of file diff --git a/modules/prestaneo/models/import/product.php b/modules/prestaneo/models/import/product.php index 348a692..2e4188d 100644 --- a/modules/prestaneo/models/import/product.php +++ b/modules/prestaneo/models/import/product.php @@ -188,9 +188,6 @@ public function process() $reference = $data[$referenceOffset]; $groupCode = $data[$this->_offsets['special']['groups']]; - // QUICK FIX: Helper for Stock Update - $dataKeyValue = array_combine($headers, $data); - $data['emptyValue'] = ''; $data['zeroValue'] = 0; @@ -371,12 +368,6 @@ public function process() //Product has been saved $processedProducts[$product->id] = $product; - // QUICK FIX: Save Stock for non Variant products - if (isset($dataKeyValue['stock'])) { - $quantity = ($dataKeyValue['stock']) ? $dataKeyValue['stock'] : $this->_quantityDefault; - StockAvailable::setQuantity($product->id, 0, $quantity, $defaultShopId); - } - // Save Features if ($this->_resetFeatures) { if (!$product->deleteFeatures()) { @@ -787,12 +778,6 @@ protected function addOrUpdateProductAttributeCombination(Product $product, $att $combination->setImages($images); $combination->update(); - - // QUICK FIX: Save Stock for non Variant products - if (isset($dataKeyValue['stock'])) { - $quantity = ($dataKeyValue['stock']) ? $dataKeyValue['stock'] : $this->_quantityDefault; - StockAvailable::setQuantity($product->id, $combination->id, $quantity); - } StockAvailable::setProductDependsOnStock($product->id, $product->depends_on_stock, null, $productAttributeId); StockAvailable::setProductOutOfStock($product->id, $product->out_of_stock, null, $productAttributeId); @@ -1027,4 +1012,4 @@ protected function _saveCustomFeature($product, $featureId, $featureCode, $value return true; } -} +} \ No newline at end of file