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?

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.

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

Your Answer

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

Not the answer you're looking for? Browse other questions tagged or ask your own question.