I have made an relation between an Product en its child images. An normal one-to-many association.
With the following code i get the child images in an object:
$product->getImages();
The I want to walk through the images to modify something, I do this with:
foreach ($product->getImages() as $Image) {
// do something
}
Only the images have an field called seq what is an number that represents the order of the images. How can I order the object related to the seq number?
Thanks!
You have to use annotation @orderBy for this. Please use something like
<?php
/** @Entity **/
class Product
{
/**
* @OneToMany(targetEntity="Image")
* @OrderBy({"seq" = "ASC"})
**/
private $images;
}
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With