i want to get list of category and subcategory (name of category) in magento , i use this API : catalogCategoryInfo (SOAP V2) . i try to get Names of direct child categories but it return id of direct child ! my question is how can i get name of category child ?
API Link
Magento – magento : get list of category with api
apicategorycategory-treePHP
Related Solutions
This seams like a bug or something that was overlooked.
Let me take it step by step.
First take a look at the definition of the catalogCategoryInfo
operation from the wsdl.xml
file inside the Mage_Catalog
module
<operation name="catalogCategoryInfo">
<documentation>Retrieve hierarchical tree of categories.</documentation>
<input message="typens:catalogCategoryInfoRequest"/>
<output message="typens:catalogCategoryInfoResponse"/>
</operation>
You will see that the response has the type catalogCategoryInfoResponse
.
This one looks like this:
<message name="catalogCategoryInfoResponse">
<part name="info" type="typens:catalogCategoryInfo"/>
</message>
This means that it will return one object of type catalogCategoryInfo
. This one is:
<complexType name="catalogCategoryInfo">
<all>
<element name="category_id" type="xsd:string"/>
<element name="is_active" type="xsd:int"/>
<element name="position" type="xsd:string"/>
<element name="level" type="xsd:string"/>
<element name="parent_id" type="xsd:string"/>
<element name="all_children" type="xsd:string"/>
<element name="children" type="xsd:string"/>
<element name="created_at" type="xsd:string" minOccurs="0"/>
<element name="updated_at" type="xsd:string" minOccurs="0"/>
<element name="name" type="xsd:string" minOccurs="0"/>
<element name="url_key" type="xsd:string" minOccurs="0"/>
<element name="description" type="xsd:string" minOccurs="0"/>
<element name="meta_title" type="xsd:string" minOccurs="0"/>
<element name="meta_keywords" type="xsd:string" minOccurs="0"/>
<element name="meta_description" type="xsd:string" minOccurs="0"/>
<element name="path" type="xsd:string" minOccurs="0"/>
<element name="url_path" type="xsd:string" minOccurs="0"/>
<element name="children_count" type="xsd:int" minOccurs="0"/>
<element name="display_mode" type="xsd:string" minOccurs="0"/>
<element name="is_anchor" type="xsd:int" minOccurs="0"/>
<element name="available_sort_by" type="typens:ArrayOfString" minOccurs="0"/>
<element name="custom_design" type="xsd:string" minOccurs="0"/>
<element name="custom_design_apply" type="xsd:string" minOccurs="0"/>
<element name="custom_design_from" type="xsd:string" minOccurs="0"/>
<element name="custom_design_to" type="xsd:string" minOccurs="0"/>
<element name="page_layout" type="xsd:string" minOccurs="0"/>
<element name="custom_layout_update" type="xsd:string" minOccurs="0"/>
<element name="default_sort_by" type="xsd:string" minOccurs="0"/>
<element name="landing_page" type="xsd:int" minOccurs="0"/>
</all>
</complexType>
As you can see there is not image
or thumbnail
element among the ones returned.
I don't know if this is a bug or a feature or someone simple overlooked it.
But here is what you can do. You can create your own module that will add the image attribute in the list of returned values from the method call.
Follow this example. It is for extending the product response, but it works the same for categories.
The idea is to take advantage of the fact that all the wsdl.xml
files from all modules are merged into one big one. You can create your own, and following the same xpath as in the wsdl file for the catalog, add a new attribute to the response.
Try this, you have to assign the value different category name based on different store Id's
$allStores = Mage::app()->getStores();
$parentCategory = Mage::getModel('catalog/category')->load(5);
$parentCategoryId = $parentCategory->getId();
$category = Mage::getModel('catalog/category')->load(8); // The ID of the category you want to copy.
$copy = clone $category;
$copy->setId(null);
foreach ($allStores as $_eachStoreId => $val)
{
$storecategory = Mage::getModel('catalog/category')->setStoreId($_eachStoreId)->load(8);// The ID of the category you want to copy.
$copy->setStoreId($_eachStoreId);
$copy->setName($storecategory->getName());
$copy->save();
}
$copy->move($parentCategoryId);
Best Answer
catalogCategoryInfo
method returns full information about one category. But ids are the only information about its child categories.Try to use
catalogCategoryTree
method instead. It will return you category information tree, with all children names.