Skip to content

Commit

Permalink
MAGE-1145: check if a price config has been set before trying to use it
Browse files Browse the repository at this point in the history
  • Loading branch information
damcou committed Nov 26, 2024
1 parent e162a63 commit 5e86d68
Showing 1 changed file with 9 additions and 7 deletions.
16 changes: 9 additions & 7 deletions Controller/Adminhtml/Landingpage/Save.php
Original file line number Diff line number Diff line change
Expand Up @@ -107,13 +107,15 @@ public function execute()
$data['configuration'] = $data['algolia_configuration'];
if ($this->configHelper->isCustomerGroupsEnabled($data['store_id'])) {
$configuration = json_decode($data['algolia_configuration'], true);
$priceConfig = $configuration['price'.$data['price_key']];
$customerGroups = $this->customerGroupCollectionFactory->create();
$store = $this->storeManager->getStore($data['store_id']);
$baseCurrencyCode = $store->getBaseCurrencyCode();
foreach ($customerGroups as $group) {
$groupId = (int) $group->getData('customer_group_id');
$configuration['price.'.$baseCurrencyCode.'.group_'.$groupId] = $priceConfig;
if (isset($configuration['price'.$data['price_key']])) {
$priceConfig = $configuration['price'.$data['price_key']];
$customerGroups = $this->customerGroupCollectionFactory->create();
$store = $this->storeManager->getStore($data['store_id']);
$baseCurrencyCode = $store->getBaseCurrencyCode();
foreach ($customerGroups as $group) {
$groupId = (int) $group->getData('customer_group_id');
$configuration['price.'.$baseCurrencyCode.'.group_'.$groupId] = $priceConfig;
}
}
$data['configuration'] = json_encode($configuration);
}
Expand Down

0 comments on commit 5e86d68

Please sign in to comment.