From 269c649220e540da59e44d7b0b7e3ee5872f2fd7 Mon Sep 17 00:00:00 2001 From: BadPixxel Date: Mon, 12 Jun 2023 11:25:39 +0200 Subject: [PATCH] Fix: Empty Stocks Writing --- grumphp.yml | 2 +- modules/splashsync/splashsync.php | 2 +- modules/splashsync/src/Objects/Product.php | 2 +- .../splashsync/src/Objects/Product/StockTrait.php | 14 +++++++------- 4 files changed, 10 insertions(+), 10 deletions(-) diff --git a/grumphp.yml b/grumphp.yml index 8f891988..8d018421 100644 --- a/grumphp.yml +++ b/grumphp.yml @@ -37,7 +37,7 @@ parameters: # For Building Splash Module mod-src: '/modules/splashsync' mod-target: '/splashsync/' - mod-file: "splashsync.2.8.0" + mod-file: "splashsync.2.8.1" # For Building Splash Manifest yml-enable: false diff --git a/modules/splashsync/splashsync.php b/modules/splashsync/splashsync.php index 6a8f5b48..3fffbff3 100644 --- a/modules/splashsync/splashsync.php +++ b/modules/splashsync/splashsync.php @@ -74,7 +74,7 @@ public function __construct() // Init Module Main Information Fields $this->name = 'splashsync'; $this->tab = 'administration'; - $this->version = '2.8.0'; + $this->version = '2.8.1'; $this->author = 'SplashSync'; $this->need_instance = 0; $this->ps_versions_compliancy = array('min' => '1.7', 'max' => '8.99.99'); diff --git a/modules/splashsync/src/Objects/Product.php b/modules/splashsync/src/Objects/Product.php index c84cbbf0..fc54feb9 100644 --- a/modules/splashsync/src/Objects/Product.php +++ b/modules/splashsync/src/Objects/Product.php @@ -166,7 +166,7 @@ public function __construct() * Check if Source Product Catalog Mode is Active * * In this mode: - * - ALL Products Textual Informations are Read Only + * - ALL Products Textual Information are Read Only * - BUT External can create Products with minimal Infos (SKU, Name) * * @return bool diff --git a/modules/splashsync/src/Objects/Product/StockTrait.php b/modules/splashsync/src/Objects/Product/StockTrait.php index b14fadd1..b7a6004b 100644 --- a/modules/splashsync/src/Objects/Product/StockTrait.php +++ b/modules/splashsync/src/Objects/Product/StockTrait.php @@ -166,14 +166,14 @@ protected function getStockLocationFields(string $key, string $fieldName) /** * Write Given Fields * - * @param string $fieldName Field Identifier / Name - * @param int $fieldData Field Data + * @param string $fieldName Field Identifier / Name + * @param null|int $fieldData Field Data * * @throws PrestaShopException * * @return void */ - protected function setStockFields(string $fieldName, int $fieldData) + protected function setStockFields(string $fieldName, ?int $fieldData): void { //====================================================================// // WRITE Field @@ -193,7 +193,7 @@ protected function setStockFields(string $fieldName, int $fieldData) StockAvailable::setQuantity( $this->ProductId, (int) $this->AttributeId, - $fieldData, + (int) $fieldData, // @phpstan-ignore-next-line Shop::getContextShopID(true), (bool) Shop::getContextShopID(true) @@ -205,12 +205,12 @@ protected function setStockFields(string $fieldName, int $fieldData) //====================================================================// // Minimum Order Quantity case 'minimal_quantity': - if (Validate::isUnsignedInt($fieldData)) { + if (Validate::isUnsignedInt((int) $fieldData)) { if ($this->AttributeId) { - $this->setSimple($fieldName, $fieldData, "Attribute"); + $this->setSimple($fieldName, (int) $fieldData, "Attribute"); $this->addMsfUpdateFields("Attribute", "minimal_quantity"); } else { - $this->setSimple($fieldName, $fieldData); + $this->setSimple($fieldName, (int) $fieldData); $this->addMsfUpdateFields("Product", "minimal_quantity"); } }