I want to go through all options of attributes configured for filtering and output the label of the Admin Store View. I only managed to get the Default Store View (store_id 1) label with the following code:
$coll = $this->_objectManager->create(\Magento\Catalog\Model\ResourceModel\Product\Attribute\Collection::class);
$coll->addIsFilterableFilter();
$layeredNavAttributes = $coll->load()->getItems();
foreach ($layeredNavAttributes AS $attr) {
$options = $attr->getSource()->getAllOptions();
foreach ($options AS $option) {
echo $option['label'];
}
}
How can I get the labels of the Admin Store View (store_id 0) instead?
Best Answer
After some more trying, I came to the answer myself. Just call the
setStoreId()
method on each attribute. So the code to get the Admin labels looks like this: