我使用Magento标准API SOAP来创建类别和子类别。如何使用API SOAP在Magento中创建子类别?
这里是我使用插入类代码:
$client = new SoapClient('http://magentohost/api/soap/?wsdl');
$session = $client->login('apiUser', 'apiKey');
$result = $client->call($session, 'catalog_category.create', array(2, array(
'name' => 'Category name',
'is_active' => 1,
'position' => 1,
'available_sort_by' => 'position',
'custom_design' => null,
'custom_apply_to_products' => null,
'custom_design_from' => null,
'custom_design_to' => null,
'custom_layout_update' => null,
'default_sort_by' => 'position',
'description' => 'Category description',
'display_mode' => null,
'is_anchor' => 0,
'landing_page' => null,
'meta_description' => 'Category meta description',
'meta_keywords' => 'Category meta keywords',
'meta_title' => 'Category meta title',
'page_layout' => 'two_columns_left',
'url_key' => 'url-key',
'include_in_menu' => 1,
)));
胡麻这里一切正常,并取得成功,但我真的很迷惑怎样把子类别的我已经创建的类别。我试过使用catalog_category.move但没有结果。
你们有没有经历过这个诡计?谢谢
必须设置为子cateogory路径像' '路径'=> 1/2 /'。 – Zaheerabbas
好的,这是一个好主意,但它不让我首先声明entity_id,在这种情况下magento创建不是我,我试图插入实体id像'entity_id'=> $ some_value_comes_form_DB和它不允许我这样做,如果可能的话,我可以声明我的路径为'path'=>'1/2/$ somevalue_from_DB/$ other_value'。问题是我从另一个数据库调用创建这些类别,并且他们有自己的Keys和id,这些必须声明。任何想法? – DanielDake
是的,当然你可以设置你自己的实体ID。我最近在这种情况下工作,并获得成功与我自己的id创建类别。我只是把我的代码作为答案below.Please检查它可能会给一些想法创建类别根据您的要求。 – Zaheerabbas