Is it possible to extend the Magento XML-RPC API To Retrieve a list of attributes used in layered navigation, or is this a limitation of this API?
1 Answer
New API can be introduced. Take \Mage_Catalog_Model_Product_Attribute_Api::items()
as a starting point.
It returns the following:
...
result[] = array(
'attribute_id' => $attribute->getId(),
'code' => $attribute->getAttributeCode(),
'type' => $attribute->getFrontendInput(),
'required' => $attribute->getIsRequired(),
'scope' => $scope
);
...
Modify this code to check if current attribute is filterable and return value of this field:
...
if ($attribute->getIsFilterable()) {
$result[] = array(
'attribute_id' => $attribute->getId(),
'code' => $attribute->getAttributeCode(),
'type' => $attribute->getFrontendInput(),
'required' => $attribute->getIsRequired(),
'is_filterable' => $attribute->getIsFilterable(),
'scope' => $scope
);
}
...
You can check how to add new custom API in this answer. To enable XML RPC only api.xml and Api.php files should be created (no wsdl.xml or V2.php needed).
Then perform request to your new API like you would to product attributes list API.
-
Unbelievable - I didn't realise Magento could be so simple - thank you!– dpdentonCommented Nov 13, 2015 at 13:48