Welcome Guest, Not a member yet? Register   Sign In
problem with prestashop web service integration in custom codeigniter app
#1

[eluser]Unknown[/eluser]
Currently I am working on prestashop integration via web services in custom codeigniter app. Problem is I am not able to store prestashop product id in to database.

if($this->db->insert('items',$item_data))
{
$item_data['item_id']=$this->db->insert_id();
$presta_item_id = $this->Prestashop->save_product($item_data);

echo json_encode(array('presta_item_id' => $presta_item_id, 'item_id' => $item_data['item_id']));

//this returns {"presta_item_id":{},"item_id":1839} in firebug. It is here just for
//debuging purpose


log_message('error', $presta_item_id);
log_message('error', $item_data['item_id']);

//in log file
//ERROR - 2013-02-12 04:36:27 --> 7254
//ERROR - 2013-02-12 04:36:27 --> 1838

//following if block is not being executed as $presta_item_id is empty
//but from log file it is evident that $presta_item_id is not empty and
// it matches correctly with the product id in prestashop


if($presta_item_id)
{
$this->db->where('item_id', $item_data['item_id']);
$this->db->update('items', array('presta_item_id' => $presta_item_id));
}

return true;
}
#2

[eluser]Unknown[/eluser]
Ok, the problem was, $presta_item_id was a simpleXmlElement object........simple (string) casting did the job.

$presta_item_id = (string)$this->Prestashop->save_product($item_data);




Theme © iAndrew 2016 - Forum software by © MyBB