2012-01-24 16 views
2

我有下面的代码:Magento的API V1-列出所有产品的价格在一个呼叫

$filters = array('sku' => array('like'=>'%')); 
$items = $magConn->call($sessionID, 'product.list', array($filters)); 

这将返回所有的产品和他们的SKU,描述和数量的数组。 但是,我也需要得到价格?有没有办法得到这个呢?

我也得到了这个工作,

$properties = ($magConn->call($sessionID, 'product.info', $item['sku'])); 

将返回所有属性的一个产品。我有超过2000种产品,如果我希望今晚结束,这绝对不可行。 ;)

回答

2

没有办法没有magento源代码修改。你应该去\app\code\core\Mage\Catalog\Model\Product\Api.php,发现里面items()方法下一行:

 $result[] = array(// Basic product data 
      'product_id' => $product->getId(), 
      'sku'  => $product->getSku(), 
      'name'  => $product->getName(), 
      'set'  => $product->getAttributeSetId(), 
      'type'  => $product->getTypeId(), 
      'category_ids'  => $product->getCategoryIds() 
     ); 

这里添加价格。

0

负载集合:

$product = Mage::getModel('catalog/product')->load($productId); 

获取实际价格:

$product->getPrice(); 

获取特惠价:

$product->getFinalPrice(); 
+0

当然,你应该首先从你的'$ items'变量中获得'$ productId'。 –

+0

这不使用API​​。不是我所需要的。 – psyklopz

相关问题