Skip to content

Commit

Permalink
Merge remote-tracking branch 'origin/release/104.3.11'
Browse files Browse the repository at this point in the history
  • Loading branch information
magentix committed Sep 10, 2024
2 parents a7c064f + fffceb0 commit d5c3997
Show file tree
Hide file tree
Showing 4 changed files with 48 additions and 3 deletions.
4 changes: 4 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -499,3 +499,7 @@

### Version 104.3.10 :
* AMC-479: Reset product UUID when URL has been updated

### Version 104.3.11 :
* PGTO-398: keep the swatch option if exists
* AMC-483: Single store mode feature
4 changes: 4 additions & 0 deletions Helper/Store.php
Original file line number Diff line number Diff line change
Expand Up @@ -111,6 +111,10 @@ public function getStores($arrayKey = 'store_id')
continue;
}

if ($this->storeManager->isSingleStoreMode() && (int)$websiteId !== 0) {
continue;
}

/** @var string $currency */
$currency = $website->getBaseCurrencyCode();
/** @var string[] $siblings */
Expand Down
41 changes: 39 additions & 2 deletions Job/Option.php
Original file line number Diff line number Diff line change
Expand Up @@ -554,11 +554,12 @@ public function insertSwatchOption(): void
$dataToInsert = [];

foreach ($swatchesAttributesData as $swatchesAttributeData) {
$optionTypeAndValue = $this->getTypeAndValue($swatchesAttributes, $swatchesAttributeData);
$dataToInsert[] = [
'option_id' => $swatchesAttributeData['option_id'],
'store_id' => $swatchesAttributeData['store_id'],
'type' => ($swatchesAttributes[$swatchesAttributeData['attribute']] === Swatch::SWATCH_TYPE_TEXTUAL_ATTRIBUTE_FRONTEND_INPUT) ? Swatch::SWATCH_TYPE_TEXTUAL : Swatch::SWATCH_TYPE_EMPTY,
'value' => ($swatchesAttributes[$swatchesAttributeData['attribute']] === Swatch::SWATCH_TYPE_TEXTUAL_ATTRIBUTE_FRONTEND_INPUT) ? $swatchesAttributeData['value'] : null,
'type' => $optionTypeAndValue['type'],
'value' => $optionTypeAndValue['value'],
];
}

Expand All @@ -575,6 +576,42 @@ public function insertSwatchOption(): void
}
}

/**
* Dispatch logic for getting type / value for each type of swatch option
*/
public function getTypeAndValue(array $swatchesAttributes, array $swatchesAttributeData): array
{
// If swatch attribute is a textual swatch returning textual data
if ($swatchesAttributes[$swatchesAttributeData['attribute']] === Swatch::SWATCH_TYPE_TEXTUAL_ATTRIBUTE_FRONTEND_INPUT) {
return [
'type' => Swatch::SWATCH_TYPE_TEXTUAL,
'value' => $swatchesAttributeData['value'],
];
}

// Keep the current data for visual swatch
/** @var AdapterInterface $connection */
$connection = $this->entitiesHelper->getConnection();
$current = $connection->fetchRow(
$connection->select()
->from($this->entitiesHelper->getTable('eav_attribute_option_swatch'), ['value', 'type'])
->where('store_id = ?', $swatchesAttributeData['store_id'])
->where('option_id = ?', $swatchesAttributeData['option_id'])
->limit(1)
);
if (!empty($current)) {
return [
'type' => $current['type'],
'value' => $current['value'],
];
}

// Init default data
return [
'type' => Swatch::SWATCH_TYPE_EMPTY,
'value' => null,
];
}

/**
* Drop temporary table
Expand Down
2 changes: 1 addition & 1 deletion composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
"nyholm/psr7": "^1.5"
},
"type": "magento2-module",
"version": "104.3.10",
"version": "104.3.11",
"license": [
"OSL-3.0",
"AFL-3.0"
Expand Down

0 comments on commit d5c3997

Please sign in to comment.