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.
Solved! Go to Solution.
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.
Hello @GoodLook ,
Please provide me below information then I will help to you.
--
If my answer is useful, please Accept as Solution & give Kudos
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 ?>
Hello @GoodLook ,
You have to perform two things for me.
<?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
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'); ?>
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
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.