相关疑难解决方法(0)

Magento:在后端代码中以编程方式创建订单

我尝试在Magento(1.5.1.0)的后端创建一个订单.

这是一些代码:

        // Get the product id stored in the optionValue of the widget
        $productId = $order['customIdNumber'];

        // Load the product
        $product = Mage::getModel('catalog/product')->load($productId);

        // Check whether the product could be loaded
        if($product->getId())
        {
            // Get the customer model
            $customer = Mage::getModel('customer/customer');

            // Set the website id associated with the customer
            $customer->setWebsiteId(Mage::app()->getWebsite()->getId());

            // Try to load the customer by email
            $customer->loadByEmail($order['personAddresses'][0]['email']);

            // Check whether the customer not exists
            if(!$customer->getId())
            {
                // Create the customer
                $customer->setEmail($order['personAddresses'][0]['email']);
                $customer->setFirstname($order['personAddresses'][0]['firstName']);
                $customer->setLastname($order['personAddresses'][0]['lastName']);
                $customer->save();
            }

            // …
Run Code Online (Sandbox Code Playgroud)

php backend magento

6
推荐指数
1
解决办法
2万
查看次数

标签 统计

backend ×1

magento ×1

php ×1