douguxun6866 2019-01-27 04:18
浏览 42

有没有快速的方法只能将catalog_product.info的价格字段作为Magento-1.9 SOAP中的产品列表?

I am getting a list of the products using catalog_product.list. It takes less than a second to get that for about 700 products. Then I am looping through each product using catalog_product.info to get values like the price. But it takes a very long time ~180 sec. Is there a better way to do it?

I am outputting the products as csv, xml, and json with only field "sku", "name", "price" and "short_description". I got sku and name from catalog_product.list. I couldn't find any way of retrieving price and short_description so I looped through the products to get info using catalog_product.info (catalog_product.info for 1 product takes about 2 secs.) Here is the api website https://devdocs.magento.com/guides/m1x/api/soap/catalog/catalogProduct/catalog_product.list.html

$products  = $client->call($sessionId, "catalog_product.list");
echo "<pre>";
print_r($products);

$cleanProducts=[];
// foreach($products as $product){
for($i=0; $i<5; $i++){
        $product=$products[$i];
        $catalogProductReturnEntity = $client->call($sessionId, 'catalog_product.info', $product['product_id']  );

        $cleanProduct = [];
        $cleanProduct['sku']=$product['sku'];
        $cleanProduct['name']=$product['name'];
        // $cleanProduct['price'] = $catalogProductReturnEntity['price'];
        // $cleanProduct['short_description'] = $catalogProductReturnEntity['short_description'];

        $fields  = [ 'price', 'short_description'];
        foreach($fields as $field){
            if(isset($catalogProductReturnEntity[$field])!=null){
                $cleanProduct[$field] = $catalogProductReturnEntity[$field];
            }
        }
        $cleanProducts[] = $cleanProduct;
}

echo "<pre>";
print_r($cleanProducts);

It doesn't make sense for API to take this long. Have anyone found the quickest way to do this? I haven't use Module: Mage_Catalog as this is just an assessment test. And I am limited to use Magento-1.9 and SOAPv1. Let me know if there are any return contents that give more information in a list.

The first array is from Info from catalog_product.list The second array is from Info from catalog_product.info The third array is generated from the code.

My Question is: Is there a shortcut on Magento SOAP to get 3rd array without going through 1st and 2nd step?

Info from catalog_product.list Info from catalog_product.info Desired info

  • 写回答

0条回答 默认 最新

    报告相同问题?

    悬赏问题

    • ¥15 c语言怎么用printf(“\b \b”)与getch()实现黑框里写入与删除?
    • ¥20 怎么用dlib库的算法识别小麦病虫害
    • ¥15 华为ensp模拟器中S5700交换机在配置过程中老是反复重启
    • ¥15 java写代码遇到问题,求帮助
    • ¥15 uniapp uview http 如何实现统一的请求异常信息提示?
    • ¥15 有了解d3和topogram.js库的吗?有偿请教
    • ¥100 任意维数的K均值聚类
    • ¥15 stamps做sbas-insar,时序沉降图怎么画
    • ¥15 买了个传感器,根据商家发的代码和步骤使用但是代码报错了不会改,有没有人可以看看
    • ¥15 关于#Java#的问题,如何解决?