Currently via below code I can get in list.phtml

From this I get brand name dropdown value in list.phtml correct:

<div class="brand-name"> <?php 
            $optionText = '';
            $attr = $_product->getResource()->getAttribute('brand');

            if ($attr->usesSource()) {
               $optionText = $attr->getSource()->getOptionText($_product->getBrand());
            <?php if($optionText){ ?>
                 <?php echo "" . $optionText . "<br>"; ?>
            <?php } ?></div>

via this code I get text subname in list.phtml

<div class="subname">
                        <?php /* @escapeNotVerified */ echo $_product->getResource()->getAttribute('subname')->getFrontend()->getValue($_product); ?><?php /* @escapeNotVerified */ echo __('<br /><br />') ?></div>

Now I try also display this attributes in custom slider:


But When I put this code then sliders dissapper. I try add variable to this file:

$_productCollection = $block->getLoadedProductCollection();
$_helper = $this->helper('Magento\Catalog\Helper\Output');
$objectManager = \Magento\Framework\App\ObjectManager::getInstance();
$productModel = $objectManager->get('Magento\Catalog\Model\Product');

But still no work. Can anyone help me?

This file mageplaza slider file: https://github.com/mageplaza/magento-2-product-slider/blob/2.4/view/frontend/templates/productslider.phtml

1 Answer 1


Try with this below code inside foreach in that file :

<?php /* @escapeNotVerified */ echo $_item->getResource()->getAttribute('subname')->getFrontend()->getValue($_item); ?>
  • 1
    great we got it! Could you please help us as well, can we similarly get the value from the dropdown? (this is first code in our topic with brand name) - can you help us rewrite it?
    – Sylvester
    Dec 1, 2021 at 19:30
  • Try with pass dropdown attribute code instead of subname. Dec 2, 2021 at 4:08
  • have you do some customs? If Yes can you Please share for me your contact details ? I have one question.
    – Sylvester
    Dec 2, 2021 at 20:59

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.