php - warning : creating default object from empty value in cakephp -


i working on cakephp 3.2

i have function find product types if exists

if ($product['product_type'] != null) {    $getproducttype = $this->producttypes->find()      ->where(['title like' => '%'.$product['product_type'].'%'])      ->first();     debug($product['product_type']);   // not empty    debug($getproducttype);            // shows 'id' => 1 in array    debug($getproducttype->id);        // shows 1     if (!empty($getproducttype)) {       $p->product_type_id = $getproducttype->id;           // line 11       $p->subcategory_id = $getproducttype->subcategory_id;       $p->category_id = $getproducttype->category_id;        return $this->savenewbulkproduct($product, $p->category_id, $p->subcategory_id, $p->product_type_id);    } } 

but giving warning as

creating default object empty value on line 11 

edit 2 output of print_r($getproducttype)

app\model\entity\producttype object  (     [id] => 3     [category_id] => 1    .... ) 

i think no need declare $p , not set property , value in $p, can pass values of $getproducttype object mentioned below.

if ($product['product_type'] != null) {    $getproducttype = $this->producttypes->find()      ->where(['title like' => '%'.$product['product_type'].'%'])      ->first();    debug($product['product_type']);   // not empty    debug($getproducttype);            // shows 'id' => 1 in array    debug($getproducttype->id);        // shows 1    if (!empty($getproducttype)) {       return $this->savenewbulkproduct($product, $getproducttype->category_id,  $getproducttype->subcategory_id, $getproducttype->id);    } } 

Comments

Popular posts from this blog

mysql - Dreamhost PyCharm Django Python 3 Launching a Site -

java - Sending SMS with SMSLib and Web Services -

java - How to resolve The method toString() in the type Object is not applicable for the arguments (InputStream) -