8.4.3 Doctrine objects not array

Permalink
I have a table with prices which I reference from another table:
/**
     * One Product has many Price Rules
     * @ORM\OneToMany(targetEntity="Store\Product\ProductPrice",mappedBy="product",cascade={"persist"}))
     */
    protected $prices;
    public function getPrices()
    {
        return $this->prices;
    }
    public function __construct()
    {
        $this->prices = new ArrayCollection();
    }

but when I try to get the prices, the returned value is not an array:
if (is_array($product->getPrices())) { 
    \Log::addEntry(count($product->getPrices())); 
} else {\Log::addEntry('not array');}

and so no array is returned. Why is it not an array of objects?

If it's not an array of objects, how can I count the number of entries/rows?

linuxoid
 
linuxoid replied on at Permalink Reply
linuxoid
I got it. Should use
$product->getPrices()->toArray()