For a Magento 1.7.0.2 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?
Best Answer
The
tree
method returns objects of typecatalogCategoryTree
that looks like this: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 thewsdl
.Also take a look at the
tree
method in the category API, specially the last lines: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:You may need to override this also to include your attribute value in the result array.