Skip to content

Commit bece526

Browse files
authored
Add "&" prefix to multiselect attributes in V1 and V2 Products API. (#38)
1 parent aa541c7 commit bece526

File tree

6 files changed

+15
-15
lines changed

6 files changed

+15
-15
lines changed
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
11
<?xml version="1.0"?>
22
<config xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="urn:magento:framework:Module/etc/module.xsd">
3-
<module name="Ometria_AbandonedCarts" setup_version="2.4.0"/>
3+
<module name="Ometria_AbandonedCarts" setup_version="2.5.0"/>
44
</config>

app/code/Ometria/Api/Controller/V1/Products.php

Lines changed: 6 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -262,16 +262,14 @@ protected function serializeItem($item)
262262
->addFieldToFilter('attribute_code', $attribute['attribute_code'])
263263
->getFirstItem();
264264

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

271269
$tmp['attributes'][] = [
272-
'type' => $attribute['attribute_code'],
273-
$key => $attribute['value'],
274-
'label' => $full_attribute->getFrontendLabel()
270+
'type' => $type,
271+
$valueIdx => $attribute['value'],
272+
'label' => $fullAttribute->getFrontendLabel()
275273
];
276274
}
277275

app/code/Ometria/Api/Controller/V2/Products.php

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -389,12 +389,14 @@ private function getAttributes(ProductInterface $product)
389389
continue;
390390
}
391391

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

394396
$attributes[] = [
395-
'type' => $attribute->getAttributeCode(),
397+
'type' => $type,
396398
$valueIdx => $attribute->getValue(),
397-
'label' => $attributeData['label']
399+
'label' => $attributeData['label']
398400
];
399401
}
400402

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
11
<?xml version="1.0"?>
22
<config xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="urn:magento:framework:Module/etc/module.xsd">
3-
<module name="Ometria_Api" setup_version="2.4.0"/>
3+
<module name="Ometria_Api" setup_version="2.5.0"/>
44
</config>
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
11
<?xml version="1.0"?>
22
<config xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="urn:magento:framework:Module/etc/module.xsd">
3-
<module name="Ometria_Core" setup_version="2.4.0"/>
3+
<module name="Ometria_Core" setup_version="2.5.0"/>
44
</config>

composer.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
{
22
"name": "ometria/magento2",
33
"type": "magento2-module",
4-
"version": "2.4.0",
4+
"version": "2.5.0",
55
"description": "Dev composer package for Ometria Extension",
66
"authors": [
77
{

0 commit comments

Comments
 (0)