2014-06-12 3 views
5

Magento SOAP API v1로 주문을 만들고 번들 제품을 장바구니에 추가 할 때 문제가 있습니다. 간단한 제품으로 올바르게 주문할 수는 있지만 번들 제품을 추가하는 것에 대해 혼란 스럽습니다.Magento Soap API 번들 제품을 장바구니에 추가

// The Products Array with Bundle 
$products = array(
     array(
      "product_id" => "38914", 
      "qty" => "1", 
      "bundle_option" => array(
       "18194" => "20360", 
      ), 
      "related_product" => null, 
      "bundle_qty" => array("20360" => "1"), 
      "options" => array(
       "0" => array(
        "key" => "3328", 
        "value" => "4494", 
       ), 
       "1" => array(
        "key" => "3329", 
        "value" => null, 
       ), 
       "2" => array(
        "key" => "3339", 
        "value" => null, 
       ), 

      ) 
     ) 
    ); 

// Get an API session 
$client = new \SoapClient('magentoinstallation/index.php/api/soap/?wsdl'); 
$session = $client->login('user', 'password'); 

//Create the Cart 
$cart = $client->call($session, 'cart.create'); 

// add the products 
$resultCartProductsAdd = $client->call($session, "cart_product.add", array( $cart, $products)); 

나는 여러 가지 형식과 점점 오류

Selected required options are not available 

Please specify product option(s). 

어떤 도움이나 제안이 크게 감사하겠습니다을 시도했습니다.

+1

보십시오 변화 "옵션"위에서 설명한 방법을 여기에 "bundle_option"http://inchoo.net/ecommerce/magento/programatically-add-bundle -product-to-cart-n-magento/PHP API 메소드가 있지만 배열이 비슷해야합니다. –

답변

6

SOAP를 통해 번들 제품을 장바구니에 추가하는 방법을 알았습니다.

키 내의 값 bundle_option은 옵션 (번들/선택 사항) (제품 ID 제외) 모델의 ID 여야합니다. 키는 옵션에 대한 ID 여야합니다

$products = array(
    array(
     "product_id" => "38914", 
     "qty" => "1", 
     "bundle_option" => array(
      "18194" => "20360", // <-- THE VALUE MUST BE THE ID OF THE CORRESPONDING "bundle/selection" MODEL, INSTEAD OF THE PRODUCT'S ID 
     ), 
// ... 
); 

는 또한 번들 수량의 키가 bundle_option_qty 대신 bundle_qty해야한다 (나는 당신의 예에서 이미 맞습니다 가정).

번들로 제공되는 제품의 가용성은 공정을 저해 할 수 있으므로 제품이 판매 가능하도록하십시오.


나는 내 대답을 시도하고 인식하는 중요한 점을 발견

$client = new \SoapClient('magentoinstallation/index.php/api/soap/?wsdl'); 
$session = $client->login('testuser', 'password'); 

$products = array(
    array(
     "product_id" => 158, 
     "qty"   => "1", 
     "bundle_option" => array(
      1    => 2, // 1 is the option id, 2 is the bundle/selection id 
     ), 
    ) 
); 

$cart = $client->call($session, 'cart.create', array('default')); 
$resultCartProductsAdd = $client->call($session, "cart_product.add", array($cart, $products)); 

젠토의 샘플 데이터와이 조각으로 성공적으로 시도했다.

그냥합니다 (API 사양을 확인하시기 바랍니다 자세한 내용 : http://www.magentocommerce.com/api/soap/checkout/cart/cart.create.html를)

$cart = $client->call($session, 'cart.create', array('default'));

대신

$cart = $client->call($session, 'cart.create');

의 사용 상점 ;-)

을 선택

이 변경 후에는 어떤 번들 제품을 추가하는 간단했다,

+0

이봐, 고마워, 빨리 시험해 보겠다! bundle_option_qty 요구 사항에 대해 알지 못했습니다. – adamS

+0

@adamS : 위의 설명과 같이 상점을 선택하여 내 게시물을 업데이트했습니다. – bukart

+0

감사합니다. 이것은 나를 위해 지금 일한다. – adamS

관련 문제