0

On magento 1.9, I could achieve this with this code

<a href="<?php echo strtolower ($manufacturerName = $_product->getAttributeText('manufacturer')) ?>.html"><?php echo $_product->getAttributeText('manufacturer') ?></a>

but don't know how to do for Magento2.

Can anybody help me?

1

Please make sure that you have assigned "manufacture" attribute to appropriate Attribute Set.

Also, select manufacture for the product as well.

You can get attribute text by using below code.

echo $_product->getAttributeText('manufacturer');

if $_product doesn't work for you then try below code to get product data.

$_product = $this->getProduct();

OR

$_product = $block->getProduct();

Accept if this answer is helpful to you.

  • this only gives manufacturer name output. – rtk0407 Feb 1 '17 at 10:46
  • for manufacturer individual page(.html), you'll have to use some paid plugins. I dont think so magento 1 or 2 provides default functionality like as you wanted. – Abhishek Panchal Feb 1 '17 at 18:18
  • the link I posted could achieve what I wanted, without paid plugin. – rtk0407 Feb 1 '17 at 19:26
0

Actually the code I used for 1.9 was working for Magento2 as well. I used firstly in a phtml file in which

$_product = $block->getProduct();

this was not given. That is why it didn't work.

So to get the linked manufacturer name on product page, you can use this code.

<a href="<?php echo strtolower ($manufacturerName = $_product->getAttributeText('manufacturer')) ?>.html"><?php echo $_product->getAttributeText('manufacturer') ?></a>

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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