【发布时间】:2012-03-23 18:46:48
【问题描述】:
我正在尝试使用 SOAP 从 magento API 获取最新产品(最多 20 个),我只需要图像和产品链接,因为它们正在另一个站点上显示。
我正在使用下面的代码来做到这一点:
$client = new SoapClient('http://magentohost/api/soap/?wsdl');
$session = $client->login('username', 'password');
$apicalls = array();
$i = 0;
$ii = 0;
$filters = array('sku' => array('neq'=>''));
$products = $client->call($session, 'catalog_product.list',array($filters));
foreach ($products as $product){
$apicalls[$i] = array('catalog_product_attribute_media.list', $product['product_id']);
$i++;
$apicalls[$i] = array('catalog_product.info', $product['product_id']);
$i++;
}
$productinfo = $client->multiCall($session, $apicalls);
但是上面的代码没有显示图像,有什么想法吗?
感谢您的帮助
【问题讨论】:
-
“显示”到底是什么意思?你得到了什么结果?
-
显示为获取具有相应产品链接的图像数组。有关示例输出,请转到此处pastebin.com/MetxheuP
-
您的 SOAP 错误是“访问被拒绝”。看起来您使用的凭据不正确。您确定您是 API 用户而不是普通用户吗?你做了一个有权限做这些事情的卷吗?
-
有一个专供magento开发人员使用的SO站点magento.stackexchange.com