Magento从特定类别获取名称,图像和描述的产品

Mic*_*ael 1 php magento

之前被问过,但不幸的是这个问题没有答案.

如何从特定类别获取名称,图像和描述的产品?

迈克尔

Luc*_*ops 8

$category = Mage::getModel('catalog/category')->load($your_category_id);
$collection = $category->getProductCollection();
$collection->addAttributeToSelect('name');
$collection->addAttributeToSelect('description');
$collection->addAttributeToSelect('image');
$products = $collection->getItems();
Run Code Online (Sandbox Code Playgroud)

不完全确定图像属性,如果失败,您可以始终为单个产品执行$product->load($product->getId())加载所有数据.

  • 嗯,例如:`foreach($ products as $ product){echo"name:{$ product-> getName()},description:{$ product-> getDescription()},image:{$ product-> getImage( )}";}`. (2认同)