Skip to content

Commit

Permalink
Merge pull request #9 from cobbyio/develop
Browse files Browse the repository at this point in the history
bump version 2.4.9
  • Loading branch information
dimajanzen authored Jun 20, 2023
2 parents ae36868 + e789c25 commit 1fe706b
Show file tree
Hide file tree
Showing 5 changed files with 40 additions and 61 deletions.
30 changes: 0 additions & 30 deletions Api/CalculatorInterface.php

This file was deleted.

3 changes: 3 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,8 @@
# CHANGE LOG

## 2.4.9
- Bugfix | Improved error message for show duplicate attributes options

## 2.4.8
- Bugfix | DEV-72 replaced deprecated ZendHttpClient with CurlClient

Expand Down
28 changes: 0 additions & 28 deletions Model/Calculator.php

This file was deleted.

38 changes: 36 additions & 2 deletions Model/Entity/Attribute/OptionManagement.php
Original file line number Diff line number Diff line change
Expand Up @@ -54,8 +54,9 @@ public function add($entityType, $attributeCode, $option)
if (!isset($label) && strlen($label) == 0) {
throw new InputException(__('The attribute option label is empty. Enter the value and try again.'));
}

if ($attribute->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.',
Expand All @@ -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
*
Expand Down
2 changes: 1 addition & 1 deletion composer.json
Original file line number Diff line number Diff line change
@@ -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",
Expand Down

0 comments on commit 1fe706b

Please sign in to comment.