2

Actually am getting my total amount of product in Observer of event

sales_order_invoice_save_after

Now I need to place this amount in a url and access the particular url and get back the response. How can be it done?

And also in this observer how can i get the product attribute values?

$observer->getEvent()->getInvoice()->getOrder() -> getData();

By the above code am getting the order details, but i need to get the product details.

Thanks

1

Your Observer function could look something like below.

$orderItems = $observer->getEvent()->getInvoice()->getOrder()->getAllItems();
 $ch = curl_init();
 $url = <YOUR URL >

foreach($orderItems as $item)
{
    $product = $item->getProduct();

        curl_setopt($ch, CURLOPT_URL, $url);
        curl_setopt($ch, CURLOPT_HEADER, TRUE);
        curl_setopt($ch, CURLOPT_NOBODY, TRUE); // remove body
        curl_setopt($ch, CURLOPT_RETURNTRANSFER, TRUE);
        $head = curl_exec($ch);
        $httpCode = curl_getinfo($ch, CURLINFO_HTTP_CODE);


}

curl_close($ch); 

Then do a curl request to the external website: READ here:

  • Thanks @Parassood. But when am trying with this code am getting error as Parse error: syntax error, unexpected T_STRING over here curl_setopt($ch, CURLOPT_URL, $url); – Bicky Aug 28 '14 at 12:29
  • Have you put in your own URL in $url? – Paras Sood Aug 28 '14 at 13:15
  • Thanks a lot @parassood the code is working properly, it was simple mistake from my side. – Bicky Aug 29 '14 at 5:36
  • Hello @parassood can you help me in getting the product custom attribute values. Am getting all other attribute values in $product = $item->getProduct(), but product custom attribute values are not getting, Thanks . – Bicky Aug 29 '14 at 6:13
  • Please post that as a separate question and I am sure someone will help you. – Paras Sood Aug 29 '14 at 12:30

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.