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 +} 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 +} diff --git a/modules/prestaneo/models/import/product.php b/modules/prestaneo/models/import/product.php index 2e4188d..96efa73 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()) { @@ -610,7 +619,7 @@ public function process() $addedImages[] = $image->id; } } - unlink($imagePath); + //unlink($imagePath); $isCover = false; } if (!empty($addedImages) && _PS_MODE_DEV_) { @@ -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 +}