From c40121432300eb15e64a95b8692adc31edc3dcd8 Mon Sep 17 00:00:00 2001 From: wucherpfennig Date: Wed, 5 Jul 2017 14:56:31 +0200 Subject: [PATCH 1/4] 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/4] 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/4] 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 30ab6cfd45ae1531a2a3c3ca89063ba5ad1e26d1 Mon Sep 17 00:00:00 2001 From: wucherpfennig Date: Mon, 24 Jul 2017 11:53:54 +0200 Subject: [PATCH 4/4] Update product.php Combinations with multiple Images will be reset to only one image #11 --- modules/prestaneo/models/import/product.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/modules/prestaneo/models/import/product.php b/modules/prestaneo/models/import/product.php index 348a692..96efa73 100644 --- a/modules/prestaneo/models/import/product.php +++ b/modules/prestaneo/models/import/product.php @@ -619,7 +619,7 @@ public function process() $addedImages[] = $image->id; } } - unlink($imagePath); + //unlink($imagePath); $isCover = false; } if (!empty($addedImages) && _PS_MODE_DEV_) {