Skip to content

Commit

Permalink
Add "&" prefix to multiselect attributes in V1 and V2 Products API. (#38
Browse files Browse the repository at this point in the history
)
  • Loading branch information
chris-pook authored Mar 22, 2022
1 parent aa541c7 commit bece526
Show file tree
Hide file tree
Showing 6 changed files with 15 additions and 15 deletions.
2 changes: 1 addition & 1 deletion app/code/Ometria/AbandonedCarts/etc/module.xml
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
<?xml version="1.0"?>
<config xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="urn:magento:framework:Module/etc/module.xsd">
<module name="Ometria_AbandonedCarts" setup_version="2.4.0"/>
<module name="Ometria_AbandonedCarts" setup_version="2.5.0"/>
</config>
14 changes: 6 additions & 8 deletions app/code/Ometria/Api/Controller/V1/Products.php
Original file line number Diff line number Diff line change
Expand Up @@ -262,16 +262,14 @@ protected function serializeItem($item)
->addFieldToFilter('attribute_code', $attribute['attribute_code'])
->getFirstItem();

$key = 'value';

if (in_array($full_attribute->getFrontendInput(), ['select', 'multiselect'])) {
$key = 'id';
}
$inputType = $fullAttribute->getFrontendInput();
$type = $inputType == 'multiselect' ? '&' . $attribute['attribute_code'] : $attribute['attribute_code'];
$valueIdx = in_array($inputType, ['select', 'multiselect']) ? 'id' : 'value';

$tmp['attributes'][] = [
'type' => $attribute['attribute_code'],
$key => $attribute['value'],
'label' => $full_attribute->getFrontendLabel()
'type' => $type,
$valueIdx => $attribute['value'],
'label' => $fullAttribute->getFrontendLabel()
];
}

Expand Down
8 changes: 5 additions & 3 deletions app/code/Ometria/Api/Controller/V2/Products.php
Original file line number Diff line number Diff line change
Expand Up @@ -389,12 +389,14 @@ private function getAttributes(ProductInterface $product)
continue;
}

$valueIdx = in_array($attributeData['input'], ['select', 'multiselect']) ? 'id' : 'value';
$inputType = $attributeData['input'];
$type = $inputType == 'multiselect' ? '&' . $attribute->getAttributeCode() : $attribute->getAttributeCode();
$valueIdx = in_array($inputType, ['select', 'multiselect']) ? 'id' : 'value';

$attributes[] = [
'type' => $attribute->getAttributeCode(),
'type' => $type,
$valueIdx => $attribute->getValue(),
'label' => $attributeData['label']
'label' => $attributeData['label']
];
}

Expand Down
2 changes: 1 addition & 1 deletion app/code/Ometria/Api/etc/module.xml
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
<?xml version="1.0"?>
<config xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="urn:magento:framework:Module/etc/module.xsd">
<module name="Ometria_Api" setup_version="2.4.0"/>
<module name="Ometria_Api" setup_version="2.5.0"/>
</config>
2 changes: 1 addition & 1 deletion app/code/Ometria/Core/etc/module.xml
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
<?xml version="1.0"?>
<config xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="urn:magento:framework:Module/etc/module.xsd">
<module name="Ometria_Core" setup_version="2.4.0"/>
<module name="Ometria_Core" setup_version="2.5.0"/>
</config>
2 changes: 1 addition & 1 deletion composer.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"name": "ometria/magento2",
"type": "magento2-module",
"version": "2.4.0",
"version": "2.5.0",
"description": "Dev composer package for Ometria Extension",
"authors": [
{
Expand Down

0 comments on commit bece526

Please sign in to comment.