skip to Main Content

I am trying to retrieve the text value for the manufacturer attribute. It is a dropdown field. I tried this:

$manufacturerName = $_product->getAttributeText('manufacturer');
$manufacturerId = $_product->getManufacturer();

$manufacturerName should display “BrandName“, but it always displays 1 even if I change the manufacturer. The $manufacturerId changes when I change the manufacturer.

I don’t understand why the manufacturer name is not displayed correctly. Any ideas?

2

Answers


  1. I think you can check on this code:

    $manufacturerName  = $_product->getAttributeText('manufacturer');
    $manufacturerId  = $_product->getResource()->getAttribute('manufacturer')->setStoreId(0)->getFrontend()->getValue($_product);
    

    https://magento.stackexchange.com/questions/62220/getattributetext-use-default-value-regardless-what-store-view-the-user-is-on

    Login or Signup to reply.
  2. /** @var MagentoCatalogModelProduct $product */
    $product->getAttributeText('attributeCode');
    

    Worked for me.

    Login or Signup to reply.
Please signup or login to give your own answer.
Back To Top
Search