首页 文章

以编程方式将产品添加到magento admin的销售报价中

提问于
浏览
0

我根据客户需要( created new grid and disabled search grid )在销售订单创建页面下定制了 search product grid .

我在 "Items Ordered “阻止之后成功创建了新的网格 .

当我单击自定义网格的 "Add product(s) To Item" 按钮时,我在自定义控制器文件中获得了所选产品的产品ID和数量 .

我试图添加这些产品引用,没有任何改变 . 我不知道,如何在“订购项目”块下的自定义网格中添加这些选定的产品 .

我已尝试使用以下代码添加引用的产品 .

$customer_id = 26; // set this to the ID of the customer.
     $customerObj = Mage::getModel('customer/customer')->load($customer_id);
     $quoteObj=Mage::getModel('sales/quote')->assignCustomer($customerObj);
     $quoteObj = $quoteObj->setStoreId(Mage::app()->getStore()->getId());
     $productModel=Mage::getModel('catalog/product');
     $productObj = $productModel->load($_id);
     $quoteItem = Mage::getModel('sales/quote_item')->setProduct($productObj);
     $quoteItem->setQty($qty);
     $quoteObj->addItem($quoteItem);
     $quoteObj->collectTotals();
     $quoteObj->save();

I'm not sure, That block containing quote products or else

有任何想法,如何将所选产品添加到销售订单创建页面中的 "Items Ordered" 块 .

热切期待您的回复!

1 回答

  • 0

    经过长时间的狩猎,我找到了解决方案 .

    只需将products数组传递给productGridAddSelected()方法,如下所示

    order.productGridAddSelected(products);

    产品阵列必须像

    products[product_id]= quantity;

相关问题