<?php declare(strict_types=1);
namespace Mrpix\CmsFeed\Services;
use Shopware\Core\Framework\Context;
use Shopware\Core\Framework\DataAbstractionLayer\EntityRepositoryInterface;
use Shopware\Core\Framework\DataAbstractionLayer\Search\Criteria;
use Shopware\Core\Framework\DataAbstractionLayer\Search\Sorting\FieldSorting;
class StickyMenu
{
protected EntityRepositoryInterface $stickyMenuRepository;
public function __construct(EntityRepositoryInterface $stickyMenuRepository)
{
$this->stickyMenuRepository = $stickyMenuRepository;
}
public function getStickyMenuEntires(?Context $context = null): array
{
$context = $context === null ? Context::createDefaultContext() : $context;
$criteria = new Criteria();
$criteria->addSorting(new FieldSorting('position'));
return $this->stickyMenuRepository->search($criteria, $context)->getElements();
}
}