1

I am working magento payment gateway

$product_model = Mage::getModel('catalog/product');
$code = Mage::app()->getStore()->getCode();
$product_id = $product_model->getIdBySku('billmate_faktura_'.$code);
$_product = Mage::getModel('catalog/product')->load($product_id);

$price = $_product->getPrice();
$orderItem = Mage::getModel('sales/quote_item')
    ->setStoreId($storeId)
    ->setProduct($_product)
    ->setQuoteItemId(0)
    ->setQuoteParentItemId(NULL)
    ->setProductId($product_id)
    ->setProductType($_product->getTypeId())
    ->setQtyBackordered(NULL)
    ->setTotalQtyOrdered(1)
    ->setQtyOrdered(1)
    ->setQty(1)
    ->setName($_product->getName())
    ->setSku($_product->getSku())
    ->setPrice($price)
    ->setBasePrice($price)
    ->setOriginalPrice($price)
    ->setRowTotal($price)
    ->setBaseRowTotal($price);
    $quote->addItem($orderItem);

    $quote->save();

When i complete order. i can't see this product in admin order detail page. please tell me if i did something wrong.

This is not working actually i am try to add this product for invoice fee purpose but when i complete order then my fee product not added anywhere.

  • Fee's should not be products. It should be, you know - a fee. You can add a custom payment fee collector for when $quote->collectTotals() runs. – Christoffer Bubach Oct 14 '15 at 19:54
2

You still need to define a payment method, and service the order.

EDIT: As per comment:

$quote = Mage::getModel('sales/quote')->setStoreId(Mage::app()->getStore('default')->getId());
$customer = Mage::getModel('customer/customer')
    ->setWebsiteId(1) // your website ID
    ->loadByEmail($email); //valid customer email address
$quote->assignCustomer($customer);
$product_info = array('qty'=>1);
$quote->addProduct($product, new Varien_Object($product_info));
$quote->getPayment()->importData(array('method'=>$payment)); //your payment method
$quote->collectTotals();
$quote->reserveOrderId();
$quote->setIsActive(0);
$quote->save();
$service = Mage::getModel('sales/service_quote', $quote);
$service->submitAll();
$order = $service->getOrder();
$order->save();
  • There's a comprehensive guide on programatically creating orders overe here: inchoo.net/ecommerce/magento/… – Moose Feb 6 '14 at 14:06
  • this is not working actually i am try to add this product for invoice fee purpose but when i complete order then my fee product not added anywhere – Vikrant Roy Feb 6 '14 at 14:23
  • Did you have a look at the guide on inchoo.net? – Moose Feb 6 '14 at 14:23
  • yes read this tutorial but not works for me – Vikrant Roy Feb 6 '14 at 15:00
  • I've updated the answer, give that a shot and let me know if you're still having issues. This works for me. Otherwise check system.log for an error message. – Moose Feb 6 '14 at 15:27

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.