array(2) {
[0]=>
object(Shop\Entity\Category)#250 (3) {
["id":protected]=>
int(13)
["parentId":protected]=>
string(1) "1"
["category":protected]=>
string(24) "Однополюсные"
}
[1]=>
object(Shop\Entity\Category)#276 (3) {
["id":protected]=>
int(14)
["parentId":protected]=>
string(1) "1"
["category":protected]=>
string(24) "Двухполюсные"
}
}
$arr[0]->getId();
foreach ($arr as $category) {
print $category->getId();
}
$categoryId = $this->params()->fromRoute('id', -1);
$cat = $this->entityManager->getRepository(Category::class)
->ChildrenCategory($categoryId); var_dump($cat);
if ($cat == null) {
$queries = $this->entityManager->getRepository(Products::class)
->getProductsById($categoryId);
} else {
foreach ($cat as $c){
$queries = $this->entityManager->getRepository(Products::class)
->getProductsById($c->getId());
}
$queries = array();
foreach ($cat as $c){
$newqueries = $this->entityManager->getRepository(Products::class)
->getProductsById($c->getId());
$queries = array_merge($queries, $newqueries);
}
Warning: array_merge(): Argument #2 is not an array in C:\xampp\htdocs\zblog.local\module\Shop\src\Controller\CategoryController.php on line 54
Warning: array_merge(): Argument #1 is not an array in C:\xampp\htdocs\zblog.local\module\Shop\src\Controller\CategoryController.php on line 54
$newqueries = $this->entityManager->getRepository(Products::class)
->getProductsById($c->getId());
if (empty($newqueries)) $newqueries = array();
if (!is_array($newqueries)) $newqueries = array($newqueries);
$queries = array_merge($queries, $newqueries);