2

I need to change some data in request before reorder in backend with observer. But I'm constantly failing in changing request params. There are two entities of the request, one in core create controller and one in observer. Seems they are not connected at all.

My question: Can I possibly change any data on adminhtml_sales_order_create_process_data_before to make influence on order creation process, or better step aside from observer and rewrite controller function?

public function checkPonAndIponData($observer)
{
    $request = $observer->getEvent()->getRequest()->getParams();

    if(isset($request['order']['quote'])) {
        $data['purchase_order_number'] = isset($request['order']['quote']['purchase_order_number'])?:null;
        $data['internal_purchase_order_number'] = isset($request['order']['quote']['internal_purchase_order_number'])?:null;
        foreach($data as $key => $array) {
            if(isset($array['check'])) {
                $data[$key] = isset($array['old'])?:null;
            } else {
                $data[$key] = isset($array['new'])?:null;
            }
            $request['order']['quote'][$key] = $data[$key];
        }
    }

    $observer->getEvent()->getRequest()->setParams($request);
    return $observer;
}
1

Ok, it was my fault. I was working with params data, while function, which dispatched the event, used post data This is two separated arrays... And lead has looked at my code, and advised me to use more js oriented path to solution. So observer has no use in this.

| improve this answer | |

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.