如何通过使用此代码获取特定产品的所有图像,我只能获取特定产品的单个图像。。
请帮助我是新来的。
<?php
// Get products in category
require_once('../app/Mage.php');//Path to Magento umask(0);
if(isset($_GET["categoryId"])){
$categoryId=$_GET["categoryId"];
$proxy = new SoapClient('http://www.prashant.com/index.php/api/v2_soap/?wsdl'); // TODO : change url
$sessionId = $proxy->login('prash', 'prashant123@'); // TODO : change login and pwd if necessary
$products= $proxy->catalogCategoryAssignedProducts($sessionId,$categoryId);
$itemDetails=array();
Mage::app();
foreach ($products as $item) {
$product2 = Mage::getModel('catalog/product')->load($item->product_id);
$productMediaConfig = Mage::getModel('catalog/product_media_config');
$baseImageUrl = $productMediaConfig->getMediaUrl($product2->getImage());
$price2=0;
$price2=$product2->getFinalPrice();
if($price2==0){
$price2=$product2->getPrice();
}
$desc=$product2->getDescription();
if($desc==""){
$desc="blank";
}
$baseImageUrl = $productMediaConfig->getMediaUrl($product2->getImage());
if($baseImageUrl=="http://www.prashant.com/media/catalog/product/"){
$baseImageUrl="http://www.prashant.com/customApi/icon.png";
}
//"desc"=>$desc,
$statusp=$product2->getStatus();
$statusen= Mage_Catalog_Model_Product_Status::STATUS_ENABLED;
if($statusp==$statusen){
$itemDetails[]=array(
"productId"=>$item->product_id,
"name"=>$product2->getName(),
"price"=>$product2->getPrice(),
"spprice"=>$price2,
"desc"=>$desc,
"imageurl"=>$baseImageUrl,
);
}
}
//return array of products
//echo "<pre>";
//print_r($itemDetails);
//echo "</pre>";
echo json_encode($itemDetails);
exit();
}else{
echo "error";
exit();
}
?>