如何扩展 Magento API catalog_product.list 以包含更多产品信息 XML-RPC [英] How to extend Magento API catalog_product.list to include more product information XML-RPC

查看:39
本文介绍了如何扩展 Magento API catalog_product.list 以包含更多产品信息 XML-RPC的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

好的,这是我的情况.

我们将 Magento Store 用作服装店 iPad 应用程序的在线目录.

We are using Magento Store as a online catalog for an iPad App for a Clothing store.

有多个类别和几百种产品.

There are multiple categories and a few hundred products.

通过使用 XML-RPC 为我们提供的所有标准 API 调用,我们已经设法让我们的 iPad 应用程序正常运行.

From all the standard api calls available to us using XML-RPC we have managed to get our nice iPad application working.

加载类别列表确实需要很长时间.这样做的原因是 catalog_product.list 只返回有关产品的基本信息,例如id 和 sku.因此,我们必须为列表中的每个产品建立新的连接,以获取我们需要的其他信息.例如名称、价格、拇指图像.为 100 个产品建立新的 XML-RPC 连接非常耗时.目前超过 30 秒.当然,在第一次加载后,我们可以将这些信息本地存储在 ipad 中,但它的重要性在于第一次加载也很快.

It does how ever take way to long to load category listings. The reason for this is the catalog_product.list only returns basic information about a product e.g. id and sku. So we then have to make a new connection for every product on our list to get the other information we need. e.g. Name, Price, Thumb Images . Making a new XML-RPC connection for say 100 products is very time consuming. more than 30 seconds currently. Naturally after the first load we could store this info locally in the ipad but its importan the first load is fast as well.

当前方法的样本返回:catelog_product.list

Sample Return of current method: catelog_product.list

position = "";
    "product_id" = 805;
    set = 4;
    sku = 1901252;
    type = simple;
},
    {
    position = "";
    "product_id" = 807;
    set = 4;
    sku = 2143405;
    type = simple;
},

问题 1)

有没有办法用现有的标准 Magento API 解决这个问题?

Is there a way to solve this problem with the existing standard Magento API?

问题 2)

如果没有,那么我需要在哪里更新 catalog_product.list 方法,以便它包含我们需要的额外信息.

If not then where do I need to be looking to update the catalog_product.list method so it includes the extra info we need.

注意:我对 PHP 非常熟悉,但我对 Magento 的确切结构及其框架不是很熟悉.

Note: I'm pretty familiar with PHP but I'm not very familar with the exact structure of Magento and its framework.

任何帮助将不胜感激.

推荐答案

进入\app\code\core\Mage\Catalog\Model\Product\Api.php,找到items方法并查看在下一段代码(我的 CE 1.6 中的第 80 行)

Go to \app\code\core\Mage\Catalog\Model\Product\Api.php, find items method and look at next piece of code (line 80 in my CE 1.6)

        $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()
        );

在此处添加所需的属性,甚至编写 $result[] = $product->getData(); 以获取所有标准属性.如果您需要一些自定义属性,请查看代码

Add needed attributes here or even write $result[] = $product->getData(); to fetch all standard attributes. If you need some custom attribute there, look at the code

    $collection = Mage::getModel('catalog/product')->getCollection()
        ->addStoreFilter($this->_getStoreId($store))
        ->addAttributeToSelect('name');

上面(我的 CE 1.6 中的第 58 行)并添加行 ->addAttributeToSelect('<your_attribute_code>').

above (line 58 in my CE 1.6) and add line ->addAttributeToSelect('<your_attribute_code>').

这篇关于如何扩展 Magento API catalog_product.list 以包含更多产品信息 XML-RPC的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆