1

I managed to create a custom attribute for a category using custom module and following 'sqlscript':

$installer = $this;
$installer->startSetup();
$attribute  = array(
    'type' => 'varchar',
    'label'=> 'Legacy Id',
    'input' => 'text',
    'global' => Mage_Catalog_Model_Resource_Eav_Attribute::SCOPE_GLOBAL,
    'visible' => true,
    'required' => false,
    'user_defined' => true,
    'default' => "",
    'group' => "General Information"
);
$installer->addAttribute('catalog_category', 'legacy_id', $attribute);
$installer->endSetup();

Attribute is visible and editable in admin section.

Now I want to read/update this attribute through SOAP API V2 in a asp.net/c# application, but I am not able to get to the custom attribute. When I use catalogCategoryAttributeList I get a list of all attributes including the one I created, however when I use method catalogCategoryInfo it shows only default attributes. I am not sure what parameter string[] attribute does. No matter what I put here, I always get the same result. And I assume that I need to use that method to get to the attributes of that category (according to magento API documentation on getting category info).

Code-snippet:

catalogAttributeEntity[] List = Service.catalogCategoryAttributeList(SessionKey);
catalogAttributeEntity LegacyIdAttr = List.Where(c => c.code == "legacy_id").FirstOrDefault();
Category = Service.catalogCategoryInfo(SessionKey, 5681, null, null);

I hope someone can put me in the right direction on how to get my custom attribute and possibly change it's value. Thanks in advance.

1

It seams that the API for categories does not work similar to the products. For the products you can get and set 'additional_attributes'.
In my opinion you need to extend the type definitions for the category methods to make your field behave just like the core fields.
Here are some details about how you can extend the type definitions The explanations are for extending types related to the products, but you can do the same for categories.
The main idea is to create an extension, add the file etc/wsdl.xml inside the extension (and wsi.xml if you use WSI Complience). In wsdl.xml add your missing attributes, and Magento will merge your file with the ones from the core.
You need to extend the following types catalogCategoryInfo, catalogCategoryEntityCreate

| improve this answer | |
  • Thank you @Marius, this did the job for added the attribute. I can see the created attribute through the api using c#, but I think I missed something else because the value is allways null. I can update the attribute in Magento admin, value gets saved into the database. Do you have ideas how to get/update the newly created attribute through the api? – excaliber Jul 4 '13 at 15:29
  • I honestly have no idea. Maybe it doesn't pass this validation: Mage_Catalog_Model_Api_Resource::_isAllowedAttribute called from Mage_Catalog_Model_Category_Api_V2::info(). – Marius Jul 4 '13 at 16:16

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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