我想使用Bigcommerce PHP库获取产品图片。我该怎么做?
$products=Bigcommerce::getProducts();
foreach($products as $product) {
echo $product->name;
echo $product->price;
}//here i retrieve price and name of products
答案 0 :(得分:1)
以下代码将为您提供产品图片......
$products=Bigcommerce::getProducts();
foreach($products as $product) {
echo $product->name;
echo $product->price;
echo $product->images[0]->image_file
}
该行
echo $product->images[0]->image_file
将为您提供特定产品的第一张图片。为了获得多个图像,您需要遍历列表。要获取确切的URL,只需在image_file的开头附加store_url / product_images即可。所以确切的网址变为
'https://store_url/product_images/'.$product->images[0]->image_file
请务必将“store_url”替换为商店链接。
如果您需要任何其他帮助,请与我们联系。
干杯:)
答案 1 :(得分:0)
从代码中看,getProductImages似乎尚未实现。我添加了一个快速补丁。如果尚未合并(https://github.com/bigcommerce/bigcommerce-api-php/pull/61)
,请使用此拉取请求代码看起来像这样 -
$images = Bigcommerce::getProductsImages(243);
print_r($images)