通过Magento API批量更新产品和税类

Posted

tags:

篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了通过Magento API批量更新产品和税类相关的知识,希望对你有一定的参考价值。

  1. This script will change the Tax-Class of ALL your products in the $storeId!!<br />
  2. Be careful to use!<br /><br />
  3.  
  4. <pre>
  5. <?php
  6. $host = 'me.com';
  7. $proxy = new SoapClient('http://'.$host.'/index.php/api/soap/?wsdl=1');
  8.  
  9. // Can be added in Magento-Admin -> Web Services
  10. $apiUser = '***';
  11. $apiKey = '***';
  12.  
  13. // the id of the store, which products you want to update
  14. $storeId = 0;
  15.  
  16. // the new TaxId, which you want to assign to ALL products
  17. $newTaxId = 2;
  18.  
  19. try {
  20.  
  21. $sessionId = $proxy->login($apiUser, $apiKey);
  22. $productList = $proxy->call($sessionId, 'product.list', array());
  23.  
  24. foreach ($productList as $product):
  25. $productInfo = $proxy->call($sessionId, 'product.info', array($product['product_id'], $storeId));
  26. print_r($productInfo);
  27.  
  28. // just to be sure: check if the product belongs to the store which i want to update
  29. if (in_array($storeId, $productInfo['websites']))
  30. $proxy->call($sessionId, 'product.update', array($product['product_id'], array('tax_class_id' => $newTaxId), $storeId));
  31.  
  32. echo '<br /><br /><hr /><br /><br />';
  33. endforeach;
  34.  
  35. } catch (Exception $e) {
  36. echo "==> Error: ".$e->getMessage();
  37. exit();
  38. }
  39. ?>
  40. </pre>

以上是关于通过Magento API批量更新产品和税类的主要内容,如果未能解决你的问题,请参考以下文章

批量产品在Magento中编辑

批量删除Magento 1.4的产品+

如何实现Magento产品批量导入

Magento:通过 API 删除产品后更新购物车总数

[转]解决Magento批量导入带图片的商品的问题

ODOO通过XMLRPC批量更新产品在手数量