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

Manoj Deswal
  • 5,785
  • 25
  • 27
  • 50
Bicky
  • 33
  • 2

1 Answers1

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:

Paras Sood
  • 2,540
  • 1
  • 14
  • 23
  • 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 05: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 06:13
  • Please post that as a separate question and I am sure someone will help you. – Paras Sood Aug 29 '14 at 12:30