【问题标题】:Magento API v1- List prices for all products in one callMagento API v1- 一次性列出所有产品的价格
【发布时间】:2012-01-24 04:00:17
【问题描述】:

我有以下代码:

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

这将返回一个包含所有产品及其 sku、描述和数量的数组。 但是,我也需要得到价格吗?有没有办法得到它?

我也有这个工作,

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

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

【问题讨论】:

    标签: php magento


    【解决方案1】:

    没有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()
            );
    

    并在此处添加价格。

    【讨论】:

      【解决方案2】:

      加载集合:

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

      获取实际价格:

      $product->getPrice();
      

      获取特价:

      $product->getFinalPrice();
      

      【讨论】:

      • 当然,您应该首先从您的$items 变量中获取$productId
      • 这没有使用 API。不是我需要的。
      猜你喜欢
      • 2018-07-03
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多