foreach($product_collection->getAll() as $v){
//...
}
foreach($product_collection->getAll()->sortByName() as $v){
//...
}
$product_collection->getData()->sortByName()->getAllObj();
//или
$product_collection->sortByName()->getAll();
public function getAll()
{
// code
return new ArrayCollection($posts);
}
...
class ArrayCollection
{
private $collection;
public function __construct($collection)
{
$this->collection = $collection;
}
public function sortByName()
{
return array_filter($this->collection, function(){});
}
}