Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix image combinations #12

Open
wants to merge 4 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -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'] . '
Expand All @@ -35,4 +37,4 @@ public static function getIdByCodeAndGroup($code, $attributeGroupCode)

return Db::getInstance()->getValue($sql);
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -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'] . '
Expand All @@ -35,4 +37,4 @@ public static function getIdByCodeAndFeature($code, $featureCode)

return Db::getInstance()->getValue($sql);
}
}
}
19 changes: 17 additions & 2 deletions modules/prestaneo/models/import/product.php
Original file line number Diff line number Diff line change
Expand Up @@ -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;

Expand Down Expand Up @@ -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()) {
Expand Down Expand Up @@ -610,7 +619,7 @@ public function process()
$addedImages[] = $image->id;
}
}
unlink($imagePath);
//unlink($imagePath);
$isCover = false;
}
if (!empty($addedImages) && _PS_MODE_DEV_) {
Expand Down Expand Up @@ -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);
Expand Down Expand Up @@ -1012,4 +1027,4 @@ protected function _saveCustomFeature($product, $featureId, $featureCode, $value

return true;
}
}
}