For a Magento instance, I'm trying to integrate a custom attribute legacy_id in the category listing. This will be used to match categories from a backend system with the Magento categories.

With this in place, inserting a new category, or updating an existing one, works perfectly using the API (catalog_category.create/update). Retrieving a single category also works perfectly, as the legacy_id property works just great on all CRUD operations.

However, what does not work is retrieving the category tree through the SOAP v2, with a call like this:

result = $proxy->catalogCategoryTree($session, 'category_root_id');

This will result in the following exception:

SOAP-ERROR: Encoding: object has no 'legacy_id' property in /var/www/vhosts/MAGENTO/docs/includes/src/Zend_Soap_Server.php on line 832

The question is: what can be the cause of this, e.g. catalog_category working but category_tree does not?

Or perhaps someone has some tips as on how I can produce more descriptive error messages for debugging?

  • Could you provide the actual code (as short as possible) you're using the call into the API? It seems like SOAP is complaining about a legacy_id property, but your example call includes none. Also, your example uses category_root_id instead of a parent ID. Commented Jul 30, 2013 at 7:05

1 Answer 1


The tree method returns objects of type catalogCategoryTree that looks like this:

<complexType name="catalogCategoryTree">
        <element name="category_id" type="xsd:int"/>
        <element name="parent_id" type="xsd:int"/>
        <element name="name" type="xsd:string"/>
        <element name="position" type="xsd:int"/>
        <element name="level" type="xsd:int"/>
        <element name="children" type="typens:ArrayOfCatalogCategoryEntities"/>

This one does not contain the field legacy_id. You can extend the api and add it. Here are some pointers on who to extend the wsdl.

Also take a look at the tree method in the category API, specially the last lines:

$collection = Mage::getModel('catalog/category')->getCollection()

$tree->addCollectionData($collection, true);
return $this->_nodeToArray($root);

Your attribute is not added to the collection. So you can override this method to add it.
Also the returned value is processed by the method _nodeToArray() that looks like this:

protected function _nodeToArray(Varien_Data_Tree_Node $node)
    // Only basic category data
    $result = array();
    $result['category_id'] = $node->getId();
    $result['parent_id']   = $node->getParentId();
    $result['name']        = $node->getName();
    $result['is_active']   = $node->getIsActive();
    $result['position']    = $node->getPosition();
    $result['level']       = $node->getLevel();
    $result['children']    = array();

    foreach ($node->getChildren() as $child) {
        $result['children'][] = $this->_nodeToArray($child);

    return $result;

You may need to override this also to include your attribute value in the result array.

  • 1
    Excellent answer, Marius. It's also required to override the class, but in a nutshell this is it. +1
    – Moriarty
    Commented Aug 27, 2013 at 8:40

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.