2012-08-27 8 views
7

Magento SOAP API v2를 사용하여 구성 가능한 제품에 대한 모든 관련 제품을 얻으려고합니다. catalogProductLink 호출이 닫히지 만 구성 가능한 유형은 처리하지 않습니다. 연결된 제품 및 구성 가능한 유형 정보가 포함 된 다른 통화는 볼 수 없습니다. 다른 사람들이 어떻게이 문제를 해결 했습니까?Magento SOAP API2를 사용하여 구성 가능한 제품에 대한 관련 제품을 검색하는 방법은 무엇입니까?

Magento 버전 1.6과 SOAP API V2를 Java와 함께 사용하고 있습니다.

+0

을 당신이 원하는 것을 검색 할 핸들이 있어야합니다. 이 경우 사용자 지정된 API v2를 만들어야합니다. –

+0

조수아 마르셀 - 정교하게 만들어 주시겠습니까? 커스텀 API를 사용할 수 있다면 PHP 코드는 어떻게 생겼을까요? 위와 비슷한 Java API 클라이언트를 사용해 보았습니다. 관리 클라이언트에서 제품을 볼 수 있지만 '관련'과 '그룹화'둘 다 빈 목록을 반환합니다. – mikesalera

답변

1

이 솔루션을 자세히 살펴보면 원하는 결과를 얻으려면 API 모델 (Mage_Catalog_Model_Product_Api)을 재정의해야한다는 것을 알게되었습니다. (라인 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], 
    ); 
} 
+0

시도해 보셨습니까? 이 방법이 효과가 있습니까? – Muk

1
  • 폴더 응용 프로그램/코드를 생성/지역/마법사/카탈로그/모델/제품/링크
  • app/code/core/Mage/Catalog/Model/Product/Link/Api.php를이 폴더에 복사하고 편집하십시오. (난 단지 V1에 대한 변경을 완료했지만 나는 그것이 V2와 같이 쉽게 확신)
  • 은 다음

    if($type == "associated"){ 
        $product = $this->_initProduct($productId); 
        try 
        { 
         $result = Mage::getModel('catalog/product_type_configurable')->getUsedProducts(null,$product); 
        } 
        catch (Exception $e) 
        { 
         $this->_fault('data_invalid', Mage::helper('catalog')->__('The product is not configurable.')); 
        } 
    
    } 
    else 
    { 
        $typeId = $this->_getTypeId($type); 
    
        $product = $this->_initProduct($productId, $identifierType); 
    
        $link = $product->getLinkInstance() 
         ->setLinkTypeId($typeId); 
    
        $collection = $this->_initCollection($link, $product); 
    
        $result = array(); 
    
        foreach ($collection as $linkedProduct) { 
         $row = array(
          'product_id' => $linkedProduct->getId(), 
          'type'  => $linkedProduct->getTypeId(), 
          'set'  => $linkedProduct->getAttributeSetId(), 
          'sku'  => $linkedProduct->getSku() 
         ); 
    
         foreach ($link->getAttributes() as $attribute) { 
          $row[$attribute['code']] = $linkedProduct->getData($attribute['code']); 
         } 
    
         $result[] = $row; 
        } 
    } 
    return $result; 
    
  • 로 항목() 함수의 내용을 대체하면 다음과 같이 API를 호출 할 수 있습니다.

    $ client-> call ($ sessionId, 'product_link.list', array ('associated', $ id_of_your_configurable_product));

기본적으로 내 코드는 제공된 유형을 검사하고 있으며 관련이있는 경우 하위 제품을 반환합니다. 더 나은 방법이 있다고 확신하지만 Product Link API가 가장 관련성이 높은 곳이라고 생각했습니다.

즐기십시오!

(참고 :이 코드는 내 것이 아니, 난 그냥 적응하고 너희들을 도울 수있는 좋은 아이디어라고 생각했다) 지금까지 내가 그렇지 않은 젠토 커뮤니티 V1.6에 대해 알고

관련 문제