I am working on CakePHP 3.2
I have this function to 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']); // this is not empty
debug($getProductType); // this shows 'id' => 1 in array
debug($getProductType->id); // this 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 this is giving warning as
Creating default object from empty value on line 11
Edit 2 Output of
print_r($getProductType)
App\Model\Entity\ProductType Object
(
[id] => 3
[category_id] => 1
....
)