⚠ In case you've missed it, we have migrated to our new website, with a brand new forum. For more details about the migration you can read our blog post for website migration. This is an archived forum. ⚠

  •     

profile picture

callback_before_update and Amazon API



alinr

alinr
  • profile picture
  • Member

Posted 11 December 2014 - 14:02 PM

Hi everybody,

 

GC saved me a lot of time, I love it a lot. 

Now I have a problem with callback_before_update and the amazon api. I searched a lot via google and in this forum, but I didn't find any solutions.

 

I have in my database table two rows with amazon values: price_new and price_old. I want to receive this values via the amazon api. 

 

For this I have created a function:

public function getAmazonInformation($post_array,$primary_key)
    {
        $amazonerg = $this->amazon_api->getItemByEan($post_array['ean_code']);
        $price_new =  $amazonerg->Items->Item->OfferSummary->LowestNewPrice->FormattedPrice;
        $price_used = $amazonerg->Items->Item->OfferSummary->LowestUsedPrice->FormattedPrice;


        $post_array["price_amazon_new"] = $price_new;
        $post_array["price_amazon_used"] = $price_used;

        return $post_array;
    }

My CRUD Function looks like:

public function item()
    {
        $crud = new grocery_CRUD();
       
        $crud->set_theme('datatables');
        $crud->set_table('item');
        $crud->set_subject('Item');

        $crud->columns('main_media','model','price','filter','power_watt','noise_level');

        $crud->set_relation('manufacturer_id','manufacturer','name');
        
        $crud->set_field_upload('main_media','assets/uploads/');
        $crud->callback_before_update(array($this, 'getAmazonInformation'));

        $crud->callback_after_upload(array($this,'thumbnailer'));

        $crud->unset_texteditor('teaser');
        $crud->unset_read();

        $output = $crud->render();
        $this->_example_output($output);
    }

It doesn't works and I dont know why. When I call the function getAmazonInformation direct, everything works fine. The values are right, but via the callback function nothing happens and the values aren't available.

 

Thank you for your support!

 


Amit Shah

Amit Shah
  • profile picture
  • Member

Posted 12 December 2014 - 06:13 AM

well a way to debug the same will be - print out the values returned .. and die instead of returning the controll back.. this will cause an error and the procedure will break up. ..

use firefox / firebug to monitor the url call and the response generated.. if there is any error / issue it will show..

see if this helps u..