【发布时间】:2015-05-27 04:36:15
【问题描述】:
我是 magento 的新手,并且正在制作它的移动应用程序,因为我正在使用 REST API。但是在产品列表 API 中,我想添加至少一个产品图片,这样应用就不会花费太多时间来加载。
我看到一个类似的question
对于提供以下解决方案的SOAP API:
public function assignedProducts($categoryId, $store = null)
{
$category = $this->_initCategory($categoryId);
$storeId = $this->_getStoreId($store);
$collection = $category->setStoreId($storeId)->getProductCollection()
->addAttributeToSelect(array('brand','image','price','description','short_description','name'));
($storeId == 0)? $collection->addOrder('position', 'asc') : $collection->setOrder('position', 'asc');
$result = array();
$type = 'image';
foreach ($collection as $product) {
$result[] = array(
'product_id' => $product->getId(),
'type' => $product->getTypeId(),
'set' => $product->getAttributeSetId(),
'sku' => $product->getSku(),
'position' => $product->getCatIndexPosition(),
'brand' => $product->getData('brand'),
'price' => $product->getData('price'),
'name' => $product->getData('name'),
'description' => $product->getData('description'),
'short_description' => $product->getData('short_description'),
'image_url' => $product-> getImageUrl()
);
}
return $result;
}
但我找不到任何关于 REST API 的信息。我试图在app/code/core/Mage/Catalog/Model/Api2/Product/Rest.php 类的protected function _retrieveCollection() 中做某事,但没有成功。
【问题讨论】:
标签: php api rest magento magento-1.9