cancel
Showing results for 
Search instead for 
Did you mean: 

NOT showing correct data <?php echo $_helper->productAttribute($_product, $_product->

SOLVED

NOT showing correct data <?php echo $_helper->productAttribute($_product, $_product->

I want to show a custom attribute "eti_verpakt" but data is not showing correct

 

this works for SKU

<?php echo $_helper->productAttribute($_product, $_product->getSku(), 'SKU'); ?>

not working for custom attribute

<?php echo $_helper->productAttribute($_product, $_product->geteti_verpakt(), 'verpakt per'); ?>

is show

a number "15" where there should be "100"

a number "16" where it should be "1000"

a number "846 " where it should be "300"

 

there are only 8 values in the drop own of this attribute possible.

"15" is not a value in the drop down list of the attribute.

1 ACCEPTED SOLUTION

Accepted Solutions

Re: NOT showing correct data <?php echo $_helper->productAttribute($_product, $_product->

above setup did not work.

after looking around I found easy solution.

 

$attr = $_product->getResource()->getAttribute('your_attribute_code')->getFrontend()->getValue($_product);

thanks for the answers.

View solution in original post

6 REPLIES 6

Re: NOT showing correct data <?php echo $_helper->productAttribute($_product, $_product->

Hello @GoodLook ,

 

Please provide me below information then I will help to you.

  • Is it product attribute? 
  • Where do you want to display this code?

--

If my answer is useful, please Accept as Solution & give Kudos

Re: NOT showing correct data <?php echo $_helper->productAttribute($_product, $_product->

stores/attributes/product/

attribute code: eti_verpakt

Visible on Catalog Pages on Storefront: YES

I would like it below SKU (SKU is showing correct)
on the list.phtml

 

<?php // start gdl add ?>
<?php if ($block->getMode() == 'grid') { ?>
<div style="text-align:center;color:#323365;">
<b><?php echo $_helper->productAttribute($_product, $_product->getSku(), 'SKU'); ?></b>
<?php echo $_helper->productAttribute($_product, $_product->geteti_verpakt(), 'verpakt per'); ?>
</div>
<?php } else { ?>
<i><?php echo $_helper->productAttribute($_product, $_product->getSku(), 'SKU'); ?></i>
<?php } ?>

<?php // einde gdl add ?>

Re: NOT showing correct data <?php echo $_helper->productAttribute($_product, $_product->

Hello @GoodLook ,

 

You have to perform two things for me.

  1. In Magento back end under STORES->Attributes->Product. Set the values of “Visible on Product View Page on Front-end” and “Used in Product Listing” options under storefront Properties to "Yes" while creating the attribute to display it in Product list and view pages and reindex all indexes.
  2. You have change this link in your code
    <?php echo $_helper->productAttribute($_product, $_product->getVerpaktPer(), 'verpakt per'); ?>

Let me know if you still get an issue.

 

--

If my answer is useful, please Accept as Solution & give Kudos

Re: NOT showing correct data <?php echo $_helper->productAttribute($_product, $_product->

The above was already set correct.

now when I dive deeper and look into mysql table:

eav_attribute_option_value

The value shown is the option_id

value_is, option_id, store_id, value

5515 15 0 100

 

<?php echo $_helper->productAttribute($_product, $_product->geteti_verpakt(), 'verpakt per'); ?>

results in option_id: 15

 

this should be value: 100

 

I tryed same adding color and here also option_id is result.

<?php echo $_helper->productAttribute($_product, $_product->getcolor(), 'Color'); ?>

Re: NOT showing correct data <?php echo $_helper->productAttribute($_product, $_product->

Hello @GoodLook ,

 

We are almost get option value

<?php echo $attribute_option_id = $_helper->productAttribute($_product, $_product->geteti_verpakt(), 'verpakt per'); ?>


Then create just an empty instance of the product and set some attributes to it.

 

$product = Mage::getModel('catalog/product')
    ->setStoreId($storeId)
    ->setData('my_attribute', $attribute_option_id);//the result from above

$text = $product->getAttributeText('my_attribute');

 

--
If my answer is useful, please Accept as Solution & give Kudos

 

Re: NOT showing correct data <?php echo $_helper->productAttribute($_product, $_product->

above setup did not work.

after looking around I found easy solution.

 

$attr = $_product->getResource()->getAttribute('your_attribute_code')->getFrontend()->getValue($_product);

thanks for the answers.