Answer the question
In order to leave comments, you need to log in
How to combine output methods and sort methods?
Need it
foreach($product_collection->getAll() as $v){
//...
}
foreach($product_collection->getAll()->sortByName() as $v){
//...
}
$product_collection->getData()->sortByName()->getAllObj();
//или
$product_collection->sortByName()->getAll();
Answer the question
In order to leave comments, you need to log in
To call methods in a chain, you need to return $this from the method if the method is inside this class, or return some object (for example, return new SortClass()).
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(){});
}
}
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question