Product SKU:HGCL
product name:Earring03
product image url:http://example.com/media/catalog/product/cache/1/image/265x/9df78eab33525d08d6e5fb8d27136e95/0/0/0003_3.jpg
Gallery images not showing the full paths, only image names, i want to display full path.
/0/0/0003_3.jpg
/v/c/vcm_s_kf_repr_658x790_28.jpg
<pre>
<?php
$product_collection = Mage::getModel('catalog/category')->load($categoryId)->getProductCollection();
foreach($product_collection as $product) {
$product_id = $product->getId();
$full_product = Mage::getModel('catalog/product')->load($product_id);
$product_sku = $full_product->getSku();
$product_name = $full_product->getName();
$product_url = $full_product->getProductUrl();
$product_image_url = $full_product->getImageUrl();
$product_image_url_gallery = $full_product->getMediaGallery();
echo "Product SKU:".$product_sku; echo "<br/>";
echo "product name:".$product_name; echo "<br/>";
echo "product image url:".$product_image_url; echo "<br/>";
for($i=0;$i<count($product_image_url_gallery);$i++)
{
echo $product_image_url_gallery['images'][$i]['file']; echo "<br/>";
}
echo "-------------------------------------------------------"; echo "<br/>";
}
?>
</pre>
答案 0 :(得分:0)
以下是使用网址获取所有图库图片的更新代码:
$categories = Mage::helper('catalog/category')->getStoreCategories();
foreach($categories as $category) {
$categoryId = $category->getId();
$product_collection = Mage::getModel('catalog/category')->load($categoryId)->getProductCollection();
foreach($product_collection as $product) {
$product_id = $product->getId();
$full_product = Mage::getModel('catalog/product')->load($product_id);
$product_sku = $full_product->getSku();
$product_name = $full_product->getName();
$product_url = $full_product->getProductUrl();
$product_image_url = $full_product->getImageUrl();
$product_image_url_gallery = $full_product->getMediaGalleryImages();
echo "Product SKU:".$product_sku; echo "<br/>";
echo "product name:".$product_name; echo "<br/>";
echo "product image url:".$product_image_url; echo "<br/>";
foreach ($product_image_url_gallery as $image) {
echo Mage::helper('catalog/image')->init($full_product, 'image', $image->getFile()).'<br>';
}
echo "-------------------------------------------------------"; echo "<br/>";
}
}
希望这有帮助!!