如何使用Magento SOAP API2检索可配置产品的关联产品?

Mon*_*ten 7 java soap magento

我正在尝试使用Magento SOAP API v2获取可配置产品的所有相关产品.catalogProductLink调用看起来很接近,但不处理可配置类型.我没有看到任何其他调用包含产品的关联产品和可配置类型信息.其他人如何解决这个问题?

我正在使用Magento 1.6版和带有Java的SOAP API V2.

Mar*_*nLA 1

我更深入地研究了这个解决方案,并意识到您可能需要重写 API 模型 (Mage_Catalog_Model_Product_Api) 才能实现您正在寻找的结果。

在 items 函数中(大约第 90 行),您可以执行以下操作:

foreach ($collection as $product) {
    $childProductIds = Mage::getModel('catalog/product_type_configurable')->getChildrenIds($product->getId());
    $result[] = array(
        'product_id' => $product->getId(),
        'sku'        => $product->getSku(),
        'name'       => $product->getName(),
        'set'        => $product->getAttributeSetId(),
        'type'       => $product->getTypeId(),
        'category_ids' => $product->getCategoryIds(),
        'website_ids'  => $product->getWebsiteIds(),
        'children'  => $childProductIds[0],
    );
}
Run Code Online (Sandbox Code Playgroud)