当前位置: 代码迷 >> Web前端 >> 用Webservice接口导入产品归类
  详细解决方案

用Webservice接口导入产品归类

热度:365   发布时间:2012-10-30 16:13:36.0
用Webservice接口导入产品分类
<?php
set_time_limit(0);
$proxy = new SoapClient('http://localhost/magento/index.php/api/soap/?wsdl');
$sessionId = $proxy->login('crazy', 'abcdef');
$allCategories = $proxy->call($sessionId, 'category.tree'); // Get all categories.
$selectedCategory = $allCategories['children'][0]; // Get the fisrt categories as parent category
// insert test
$newCategoryId = $proxy->call(
   $sessionId,
   'category.create',
   array(
         $selectedCategory['category_id'],
         array('name'=>'New Category Through Soap')
   )
);
// update test.
$newData = array('is_active'=>1);
$proxy->call($sessionId, 'category.update', array($newCategoryId, $newData, 'default'));
?>


上面的代码可以示例了如何导入导出Categories.
$proxy = new SoapClient('http://localhost/magento/index.php/api/soap/?wsdl');

指向你的magento soap服务的位置
$sessionId = $proxy->login('crazy', 'abcdef');

指定授权的用户名和密码。此用户名和密码是在后台的System->Webservice下事先配置好的
  相关解决方案