3

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?

Ashish Jagnani
6,3047 gold badges36 silver badges71 bronze badges
asked Nov 12, 2015 at 23:34

1 Answer 1

1

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.

answered Nov 13, 2015 at 10:58
1
  • Unbelievable - I didn't realise Magento could be so simple - thank you! Commented Nov 13, 2015 at 13:48

Your Answer

Draft saved
Draft discarded

Sign up or log in

Sign up using Google
Sign up using Email and Password

Post as a guest

Required, but never shown

Post as a guest

Required, but never shown

By clicking "Post Your Answer", you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.