나는 제품을 만들고 그에게 조합 (색상 / 크기)을 지정하려고합니다.
그러나 첫 번째 조합 만 성공적으로 추가되었습니다! 그런 다음 내부 서버 오류 (500)가 표시됩니다.
그게 내가 사용하는 것입니다.
$combination =
'<?xml version="1.0" encoding="utf-8"?>
<prestashop>
<combination>
<id xmlns=""></id>
<id_product xmlns="">'.$id.'</id_product>
<quantity xmlns="">' . $quantity . '</quantity>
<supplier_reference xmlns="">Inditex</supplier_reference>
<price xmlns="">' . $price . '</price>
<wholesale_price xmlns="">' . $price . '</wholesale_price>
<minimal_quantity xmlns="">1</minimal_quantity>
<default_on xmlns="">1</default_on>
<associations xmlns="">
<product_option_values xmlns="">
<product_option_value><id>'.$color_id.'</id></product_option_value>
<product_option_value><id>'.$size_id.'</id></product_option_value>
</product_option_values>
</associations>
</combination>
</prestashop>';
$response = curlCall($url . '/api/combinations/products/'.$id, $combination, 'POST', $api_key);
$load_string = simplexml_load_string($response);
$combination_id = $load_string->combination->id;
해당 코드는 제품에 조합이없는 경우에만 제대로 작동합니다. (color_id 및 size_id가 확인되었으며 동일한 ID를 사용하지 않습니다)
저를 구 해주세요 :)
다른 방법을 사용하면 잘 작동합니다.
$webService = new PrestaShopWebservice($url, $api_key, FALSE);
$xml = $webService->get(array('url' => $url .'/api/combinations?schema=blank'));
$resources = $xml->children()->children();
$resources->id_product = $ps_product_id;
$resources->wholesale_price = $wholesale_price;
$resources->price = $price;
$resources->unit_price_impact = $unit_price_impact;
$resources->minimal_quantity = $minimal_quantity;
$resources->quantity = $quantity;
$resources->weight = $weight;
$resources->associations->product_option_values->product_option_value[0]->id = $color_id;
$resources->associations->product_option_values->product_option_value[1]->id = $size_id;
$request = $xml->asXML();
//This is a function that curl request to specific URL using method (POST)
$response = ps_curl($url . '/api/combinations', $request, 'POST', $api_key);
$xml_load = simplexml_load_string($response);
$id = $xml_load->combination->id;
이 기사는 인터넷에서 수집됩니다. 재 인쇄 할 때 출처를 알려주십시오.
침해가 발생한 경우 연락 주시기 바랍니다[email protected] 삭제
몇 마디 만하겠습니다