0

Как можно вывести wishlist всех пользователей в magento2?

1

1 ответ 1

0

Вы можете использовать коллекцию вишлистов Magento\Wishlist\Model\ResourceModel\Wishlist\Collection без указания каких-либо фильтров, примерно следующим образом:

class WishListTest
{

    public function __construct(
        \Magento\Wishlist\Model\ResourceModel\Wishlist\CollectionFactory $wishListCollectionFactory
    ) {
        $this->wishListCollectionFactory = $wishListCollectionFactory;
    }

    public function getAllWishes()
    {
        /** @var \Magento\Wishlist\Model\ResourceModel\Wishlist\Collection $wishListCollection */
        $wishListCollection = $this->wishListCollectionFactory->create();
        /** @var \Magento\Wishlist\Model\Wishlist[] $items */
        $items = $wishListCollection->getItems();

        return $items;
    }
}

Через вишлист у вас будет доступ и к конкретным товарам внутри него.

Ваш ответ

By clicking “Отправить ответ”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Всё ещё ищете ответ? Посмотрите другие вопросы с метками или задайте свой вопрос.