Magento 2.0 — Как получить значение параметров атрибута мультиселекта клиента

Я пытаюсь получить значение пользовательских параметров атрибута клиента в текущем магазине с момента сеанса клиента Magento 2.0 EE.

Теперь я получаю только идентификаторы опций:

$objectManager = \Magento\Framework\App\ObjectManager::getInstance();
$customerSession = $objectManager->get('Magento\Customer\Model\Session');
$customerRepository = $objectManager
->get('Magento\Customer\Api\CustomerRepositoryInterface');
$customer = $customerRepository->getById($customerSession->getCustomerId());
$attrValue = $customer->getCustomAttribute('attribute_code')->getValue();

var_dump($attrValue) is string(id1,id2,id3)

Как я могу получить текстовое значение веб-интерфейса этих параметров.

3

Решение

Я нашел решение, я не уверен, что это хорошая практика …:

        $objectManager = \Magento\Framework\App\ObjectManager::getInstance();
$customerSession = $objectManager->get('Magento\Customer\Model\Session');
$customerRepository = $objectManager
->get('Magento\Customer\Api\CustomerRepositoryInterface');
$customer = $customerRepository->getById($customerSession->getCustomerId());

$model = $objectManager->create('Magento\Eav\Model\ResourceModel\Entity\Attribute\Option\Collection');
$model->setIdFilter(explode(',',$customer->getCustomAttribute('attribute_code')->getValue()))
->setStoreFilter();

var_dump($model->toOptionArray());
1

Другие решения

Других решений пока нет …