0

I am using Marketplace in My Website i used to delete product from order

public function deleteproductAction()
{
    $order_id = $this->getRequest()->getParam('order_id');
    $product_id = $this->getRequest()->getParam('product_id');

     $_order = Mage::getModel('sales/order')->load($order_id);
     $items = $_order->getAllItems();
     $updateQty = 0;
     foreach ($items as $item){
        $base_grand_total = $_order->getBaseGrandTotal();
        $base_subtotal = $_order->getBaseSubtotal();
        $base_tva = $_order->getBaseTaxAmount();
        $grand_total = $_order->getGrandTotal();

        $subtotal = $_order->getSubtotal();
        $tva = $_order->getTaxAmount();

        $base_subtotal_incl_tax = $_order->getBaseSubtotalInclTax();

        $subtotal_incl_tax = $_order->getSubtotalInclTax();

        $total_item_count = $_order->getTotalItemCount();


        if($item->getProductId()==$product_id){
            $marketplaceSales = Mage::getModel('marketplace/saleslist')->getCollection()
                ->addFieldToFilter('mageproid',$product_id) 
                ->addFieldToFilter('mageorderid',$_order->getId()); 

            $item_price = $item->getPrice();
            $item_tva = $item->getTaxAmount();
            $item->delete();
            $updateQty =  $updateQty+1;
            if($id = $marketplaceSales->getFirstItem()->getAutoid()) {
                $saleslist = Mage::getModel('marketplace/saleslist')->load($id);
                $saleslist->delete();
            }

            $_order->setBaseGrandTotal($base_grand_total-$item_price-$item_tva);
            $_order->setBaseSubtotal($base_subtotal-$item_price);
            $_order->setBaseTaxAmount($base_tva-$item_tva);
            $_order->setGrandTotal($grand_total-$item_price-$item_tva);
            $_order->setSubtotal($subtotal-$item_price);
            $_order->setTaxAmount($tva-$item_tva);
            $_order->setBaseSubtotalInclTax($base_subtotal_incl_tax-$item_price);
            $_order->setSubtotalInclTax($subtotal_incl_tax-$item_price);
            $_order->setTotalItemCount(count($items)-1);
            $_order->save();
        }     
        }

    $orderModel = Mage::getModel('sales/order')->load($_order->getId());
    $orderModel->setTotalQtyOrdered($orderModel->getTotalQtyOrdered()-$updateQty);
    $orderModel->setBaseTotalQtyOrdered($orderModel->getBaseTotalQtyOrdered()-$updateQty);
    $orderModel->save();

Mage::getSingleton('adminhtml/session')
                           ->addSuccess('Order Updated Successfully');
        $this->_redirect('adminhtml/sales_order/view', array('order_id' => $_order->getId()));
}

Let us Assume I have 1 order that order contain 2 Seller Product assume Seller A & Seller B I delete Seller B product after that i go to Seller A Dashboard i try to process order but i can't process because that seller B order id Store Some where how to find that in Database there is no table i cross checked.

  • Possible duplicate of Delete particular product in order – Amit Bera Jan 26 '16 at 15:09
  • @AmitBera it's partially work but this different question – Magento 2 Jan 26 '16 at 15:12
  • did you check this marketplace/saleslist table i think they have the seller id and product id. – Qaisar Satti Jan 27 '16 at 5:35
  • i checked marketplace/saleslist this it's have count 1 only but one more table is there that didn't reduced amount and qty – Magento 2 Jan 27 '16 at 5:43
  • sales_flat_quote in this table didn't reduce order count and amount – Magento 2 Jan 27 '16 at 5:55

Your Answer

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

Browse other questions tagged or ask your own question.