I have an array of Product IDs and want to get the product information by calling the Product class. I have tried adding it in a foreach loop and get a fatal error saying Object of class Product could not be converted to string. This is what I have tried.
$productIDs = Db::getInstance()->executeS("SELECT id_product FROM wtop_product ORDER BY position ASC");
$products = '';
foreach($productIDs as $productID)
{
$products .= new Product($productID['id_product'], false, '1');
}
Since this ouputs an error obviously it is not the correct way to handle this situation. What i'm not sure of is how to pass the array of product IDs to the new Product call and get an output of each of those products.
$products[] = ...to create an array of objects, rather than gluing them together as strings.new Productreturn a string? If so implement a __toString function(new Product(...))->toString();?