IPHONE 模板块、Magento 使用Api将Sku添加到Url中 /Magento Free template iphone

来源:互联网 发布:传智播客java百度云盘 编辑:程序博客网 时间:2024/05/22 04:29
<p>使用Magento Api修改商品Url路径的测试程序,希望对大家理解Api有帮助.</p>主要目的是通过Api去将商品的sku编号加到商品Url的后面,批量来更新Url,代码如下<a target=_blank target="_blank" href="http://www.hellokeykey.com/tag/api/">http://www.hellokeykey.com/tag/api/</a><a target=_blank target="_blank" href="http://www.mage-world.com/mapple-iphone-magento-theme.html">http://www.mage-world.com/mapple-iphone-magento-theme.html</a><?php$proxy = new SoapClient('http://www.yourdomain.com/api/soap/?wsdl');$session = $proxy->login('username', 'abc1234'); //获取全部商品$products = $proxy->call($session, 'product.list');//print_r($products);echo count($products);$i = 0;foreach($products as $product){$i++;if($i>249 && $i<300){echo $product[sku]."-Start<br />";//获取商品url$product_one = $proxy->call($session, 'product.info', $product[sku]);//print_r($proxy->call($session, 'product.info', $product[sku]));$new_url = $product_one[url_path].'-'.strtolower($product[sku]);echo $proxy->call($session, 'catalog_product.update', array($product[sku], array('url_path'=> $new_url)));echo $proxy->call($session, 'catalog_product.update', array($product[sku], array('url_key'=> $new_url))); //print_r($proxy->call($session, 'product.info', $product[sku]));//echo $new_url;echo $product[sku]."-OK-".$i."<br />";}//break;} //获取商品sku//$proxy->call($session, 'product.info', 'sku');


0 0
原创粉丝点击