【问题标题】:How to filter product list by category and brand in Magento soap api如何在 Magento soap api 中按类别和品牌过滤产品列表
【发布时间】:2013-12-22 18:53:47
【问题描述】:

我正在将 Magento soap API 用于移动应用,我需要在我的应用中获取特定类别下的产品,并且还按品牌过滤。

可以通过调用catalog_category.assignedProducts 来获取分配到某个类别的产品,但此方法不允许通过其他属性进行过滤。

另一方面,我们有 catalog_product.list 方法可以按属性过滤产品,但我认为它不能按类别过滤产品。

有没有办法同时按类别和品牌(属性)过滤产品?

【问题讨论】:

    标签: php magento soap soap-client


    【解决方案1】:

    我最终使用 foreach 方法手动过滤 catalog_category.assignedProducts 方法的结果,如下所示:

    $products = $client->call($session, 'catalog_category.assignedProducts',$categoryId);
    if($brandId!=null && $brandId>0)
    {
        $result=array();
        foreach ($products as $product) {
            if($product['brand']==$brandId)
                array_push($result,$product);
        }
    }
    else{
        $result=$products;
    }
    

    【讨论】:

      猜你喜欢
      • 2015-09-23
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多