1

We are using Magento Marketplace

My Controller

if(count($trackingcol)==0){
    $trackingcol=Mage::getModel('mpshippingmanager/tracking')->getCollection()
    ->addFieldtoFilter('order_id',array('eq'=>$orderid))
    ->addFieldtoFilter('tracking_number',array('eq'=>'canceled'));
    $order = Mage::getModel('sales/order')->load($orderid);
        if(count($trackingcol)==0){
            $product_order_id = $order->getIncrementId();
            $order->setStatus('complete');
            $order->save();
        }else{
            $order->cancel();
            $order->save();
        }

.phtml

<?php if(count($shipping_coll)): ?>
<?php if($item_status=="Ordered"): ?>
    <a href="<?php echo $this->getUrl('mpshippingmanager/shipping/cancelorder',array('id'=>$mageorderid))?>">
      <button class="button wk_mp_btn" style="flaot:none" title="<?php echo $helper->__('Cancel Order') ?>" type="button" id="save_butn" >
      <span><span><?php echo $helper->__('Cancel Order') ?></span></span>
      </button>
    </a>
<?php endif;  ?>
<?php endif; ?>
<?php if($item_status=="Ordered"||$item_status=="Invoiced"){?>
    <button class="button wk_mp_btn" style="flaot:none" title="<?php echo $helper->__('Save Tracking Number') ?>" type="submit" id="save_butn" >
    <span><span><?php echo $helper->__('Save Tracking Number') ?></span></span>
    </button>
<?php } ?>

It's for front end While clicking this button status will be changed front end as well as back end also

How to add a more button called shipement if i click status also need to change shipped

My Custom Status is test

Cancel order Controller

public function cancelorderAction(){
            try{
                $orderid=$this->getRequest()->getParam('id');
                $partnerid=Mage::getSingleton('customer/session')->getCustomer()->getId();
                $collection = Mage::getModel('marketplace/saleslist')->getCollection()
                                ->addFieldToFilter('mageproownerid', array('eq' => $partnerid))
                                ->addFieldToFilter('mageorderid', array('eq' => $orderid));
                $flag=false;
                foreach($collection as $saleproduct){
                    $saleproduct->setCpprostatus(2);
                    $saleproduct->save();
                    $trackingcoll = Mage::getModel('mpshippingmanager/tracking')->getCollection()
                                ->addFieldToFilter('order_id',array('eq'=>$orderid))
                                ->addFieldToFilter('seller_id',array('eq'=>$partnerid));
                    foreach($trackingcoll as $tracking){
                            $tracking->setTrackingNumber('canceled');
                            $tracking->setCarrierName('canceled');
                            $tracking->save();  
                            $flag=true;
                    }

                }
                $trackingcol=Mage::getModel('mpshippingmanager/tracking')->getCollection()
                                    ->addFieldtoFilter('order_id',array('eq'=>$orderid))
                                    ->addFieldtoFilter('tracking_number',array('eq'=>''));  
                if(count($trackingcol)==0){
                        $trackingcol=Mage::getModel('mpshippingmanager/tracking')->getCollection()
                                    ->addFieldtoFilter('order_id',array('eq'=>$orderid))
                                    ->addFieldtoFilter('tracking_number',array('eq'=>'canceled'));
                        if(count($trackingcol)==0){
                            $order = Mage::getModel('sales/order')->load($orderid);
                            $product_order_id = $order->getIncrementId();
                            $order->setStatus('complete');
                            $order->save();
                        }else{
                            $order = Mage::getModel('sales/order')->load($orderid);
                            $order->cancel();
                            $order->save();
                        }   
                    }
                if($flag==true){
                    Mage::getSingleton('core/session')->addSuccess('Order Cancled successfully..');
                }else{
                    Mage::getSingleton('core/session')->addError('You are not permitted for cancel this order..');
                }
            }catch(Exception $e){
                Mage::getSingleton('core/session')->addError($e->getMessage());
            }
            $this->_redirect('mpshippingmanager/shipping/invoice/id/'.$orderid);
        }
2
  • add cancelorder method too for better understanding Dec 15 '15 at 10:04
  • Check my updated question
    – Magento 2
    Dec 15 '15 at 10:05
1

html for status test

   <?php if($item_status=="Ordered"): ?>
    <a href="<?php echo $this->getUrl('mpshippingmanager/shipping/testorder',array('id'=>$mageorderid))?>">
      <button class="button wk_mp_btn" style="flaot:none" title="<?php echo $helper->__('Cancel Order') ?>" type="button" id="save_butn" >
      <span><span><?php echo $helper->__('Cancel Order') ?></span></span>
      </button>
    </a>
<?php endif;  ?>

method

public function testorderAction()
      {
           $id = $this->getRequest()->getParam('id');

            $order = Mage::getModel('sales/order')->loadByIncrementId($id);
            $order->setData('state', 'test');
         $order->setStatus('test');
         $history = $order->addStatusHistoryComment('', false);
         $history->setIsCustomerNotified(false);
         $order->save(); 
                $this->_getSession()->addSuccess(
                    $this->__('The order state has been changed.')
                );
                $this->_redirectReferer();


     }
31
  • it showing error Fatal error: Call to a member function getMethodInstance() on a non-object in
    – Magento 2
    Dec 15 '15 at 13:56
  • Did you add method in controller Dec 15 '15 at 14:02
  • yes i added in controller file
    – Magento 2
    Dec 15 '15 at 15:07
  • 1
    Thanks for your help it's working fine +1 up vote for me
    – Magento 2
    Dec 15 '15 at 18:06
  • 1
    Comments are not for extended discussion; this conversation has been moved to chat.
    – philwinkle
    Dec 15 '15 at 18:12

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.