1

我需要一种在 magento 中导入订单的方法。

在 mangeto 网站上找到这个并让它工作。我现在遇到的问题是我需要更改产品价格。这是可能的吗?(无法找到真正的谷歌)

 //$proxy = new SoapClient('');
 $proxy = new SoapClient('');
 $sessionId = $proxy->login('');
 var_dump($sessionId);
 // Create a quote, get quote identifier
 $shoppingCartId = $proxy->call( $sessionId, 'cart.create', array( '0' ) );
 var_dump($shoppingCartId);

 // Set customer, for example guest
 $customerAsGuest = array(
"firstname" => "testFirstname",
"lastname" => "testLastName",
"email" => "",
"website_id" => "0",
"store_id" => "0",
"mode" => "guest",
"gender" => "male"
 );
 $resultCustomerSet = $proxy->call($sessionId, 'cart_customer.set', array( $shoppingCartId,      $customerAsGuest) );

 // Set customer addresses, for example guest's addresses
 $arrAddresses = array(
array(
    "mode" => "shipping",
    "firstname" => "testFirstname",
    "lastname" => "testLastname",
    "company" => "testCompany",
    "street" => "testStreet",
    "city" => "testCity",
    "region" => "testRegion",
    "postcode" => "testPostcode",
    "country_id" => "NL",
    "telephone" => "0123456789",
    "fax" => "0123456789",
    "is_default_shipping" => 0,
    "is_default_billing" => 0
),
array(
    "mode" => "billing",
    "firstname" => "testFirstname",
    "lastname" => "testLastname",
    "company" => "testCompany",
    "street" => "testStreet",
    "city" => "testCity",
    "region" => "testRegion",
    "postcode" => "testPostcode",
    "country_id" => "NL",
    "telephone" => "0123456789",
    "fax" => "0123456789",
    "is_default_shipping" => 0,
    "is_default_billing" => 0
     )
 );
 $resultCustomerAddresses = $proxy->call($sessionId, "cart_customer.addresses",      array($shoppingCartId, $arrAddresses));

 // add products into shopping cart
 /*$arrProducts = array(
array(
    "product_id" => "1",
    "qty" => 2
),
array(
    "sku" => "testSKU",
    "quantity" => 4
)
 );*/

 $arrProducts = array(
array(
    "product_id" => "16021",
    "qty" => 2
),
array(
    "sku" => "P0014685",
    "quantity" => 4
)
 );
 $resultCartProductAdd = $proxy->call($sessionId, "cart_product.add", array($shoppingCartId,      $arrProducts));
 /*
 // update product in shopping cart
 $arrProducts = array(
array(
    "product_id" => "1",
    "qty" => 5
),
 );
 $resultCartProductUpdate = $proxy->call($sessionId, "cart_product.update",      array($shoppingCartId, $arrProducts));

 // remove products from shopping cart, for example by SKU
 $arrProducts = array(
array(
    "sku" => "testSKU"
     ),
 );
 $resultCartProductRemove = $proxy->call($sessionId, "cart_product.remove",           array($shoppingCartId, $arrProducts));
 */
 // get list of products
 echo"<br/>Artikelen<br/>";
 $shoppingCartProducts = $proxy->call($sessionId, "cart_product.list",      array($shoppingCartId));
 print_r( $shoppingCartProducts );
 //echo"<br/>Verzendmethode<br/>";
 // get list of shipping methods
 $resultShippingMethods = $proxy->call($sessionId, "cart_shipping.list", array($shoppingCartId));
 //print_r( $resultShippingMethods );

 // set shipping method
 $randShippingMethodIndex = rand(1, count($resultShippingMethods) );
 $shippingMethod = $resultShippingMethods[$randShippingMethodIndex]["PostNL gratis"];
 //$resultShippingMethod = $proxy->call($sessionId, "cart_shipping.method", array($shoppingCartId, $shippingMethod));
 $resultShippingMethod = $proxy->call($sessionId, "cart_shipping.method", array($shoppingCartId, 'freeshipping_freeshipping'));


 // get list of payment methods
 $resultPaymentMethods = $proxy->call($sessionId, "cart_payment.list",      array($shoppingCartId));
 //print_r($resultPaymentMethods);

 // set payment method
 $paymentMethod = array(
"method" => "checkmo"
 );
 $resultPaymentMethod = $proxy->call($sessionId, "cart_payment.method",      array($shoppingCartId, $paymentMethod));
 /*
 // add coupon
 $couponCode = "aCouponCode";
 $resultCartCouponRemove = $proxy->call($sessionId, "cart_coupon.add",      array($shoppingCartId, $couponCode));

 // remove coupon
      $resultCartCouponRemove = $proxy->call($sessionId, "cart_coupon.remove",      array($shoppingCartId));
 */
 // get total prices
 $shoppingCartTotals = $proxy->call($sessionId, "cart.totals", array($shoppingCartId));
 print_r( $shoppingCartTotals );

 // get full information about shopping cart
 $shoppingCartInfo = $proxy->call($sessionId, "cart.info", array($shoppingCartId));
 print_r( $shoppingCartInfo );
 /*
 // get list of licenses
 $shoppingCartLicenses = $proxy->call($sessionId, "cart.licenseAgreement",           array($shoppingCartId));
 print_r( $shoppingCartLicences );

 // check if license is existed
 $licenseForOrderCreation = null;
 if (count($shoppingCartLicenses)) {
$licenseForOrderCreation = array();
foreach ($shoppingCartLicenses as $license) {
    $licenseForOrderCreation[] = $license['agreement_id'];
}
 }
 */
 // create order
 $resultOrderCreation = $proxy->call($sessionId,"cart.order",array($shoppingCartId,      null, $licenseForOrderCreation));
4

0 回答 0