From e789c2547d69beb650754eaca10663c1816cecd6 Mon Sep 17 00:00:00 2001 From: Dario Leunig Date: Tue, 20 Jun 2023 11:25:02 +0200 Subject: [PATCH] bump version 2.4.9 --- Api/CalculatorInterface.php | 30 ---------------- CHANGELOG.md | 3 ++ Model/Calculator.php | 28 --------------- Model/Entity/Attribute/OptionManagement.php | 38 +++++++++++++++++++-- composer.json | 2 +- 5 files changed, 40 insertions(+), 61 deletions(-) delete mode 100644 Api/CalculatorInterface.php delete mode 100644 Model/Calculator.php diff --git a/Api/CalculatorInterface.php b/Api/CalculatorInterface.php deleted file mode 100644 index b953676..0000000 --- a/Api/CalculatorInterface.php +++ /dev/null @@ -1,30 +0,0 @@ -getSource()->getOptionId($label) !== null) { + + $optionIdByLabel = $this->getOptionIdByLabel($attribute->getSource(), $label); + if ($optionIdByLabel !== null) { throw new InputException( __( 'Admin store attribute option label "%1" is already exists.', @@ -70,6 +71,39 @@ public function add($entityType, $attributeCode, $option) return $this->retrieveOptionId($attribute, $option); } + /** + * Get option id by label + * + * @param $attribute + * @param string $label + * @return null|string + */ + public function getOptionIdByLabel($attribute, $label) + { + foreach ($attribute->getAllOptions() as $option) { + if ($this->mbStrcasecmp($option['label'], $label) == 0) { + return $option['value']; + } + } + return null; + } + + /** + * Multibyte support strcasecmp function version. + * + * @param string $str1 + * @param string $str2 + * @return int + */ + private function mbStrcasecmp($str1, $str2) + { + $encoding = mb_internal_encoding(); + return strcmp( + mb_strtoupper($str1, $encoding), + mb_strtoupper($str2, $encoding) + ); + } + /** * Save attribute option * diff --git a/composer.json b/composer.json index 68a6dff..ded40c7 100644 --- a/composer.json +++ b/composer.json @@ -1,7 +1,7 @@ { "name" : "cobbyio/cobby-connector-magento2", "description" : "This extension for Magento 2 provides a direct integration of the cobby management methods to your Magento 2 shop.", - "version" : "2.4.8", + "version" : "2.4.9", "type" : "magento2-module", "require": { "magento/framework": "^102.0|^103.0|^104.0",