Timeline for Magento 2 get product attribute value without objectManager
Current License: CC BY-SA 4.0
11 events
when toggle format | what | by | license | comment | |
---|---|---|---|---|---|
Feb 26, 2020 at 11:16 | comment | added | JGeer | Thanks a lot! That works perfect. Only 1 question left, how can I get the sorting of the related products from the backend? So that the foreach is loading the products with the right sorting? | |
Feb 26, 2020 at 11:11 | comment | added | Pankaj Pareek | I have updated the code. Can you please check | |
Feb 26, 2020 at 11:10 | history | edited | Pankaj Pareek | CC BY-SA 4.0 |
added 25 characters in body
|
Feb 26, 2020 at 10:12 | comment | added | JGeer |
As addition, when loading echo $_product->getName(); we do get the unique value of the specific product. So that works well. But for example <?php echo $block->getProductPrice($_product);?> also displays the value of the first one.
|
|
Feb 26, 2020 at 10:10 | comment | added | JGeer |
It seems not working 100% well. The foreach is not working when loading the echo $_product->getData('my_attribute_value'); . It only loads the value of the first product and displays that value for all other products as well. What are we missing here?
|
|
Feb 26, 2020 at 8:52 | vote | accept | JGeer | ||
Feb 26, 2020 at 10:17 | |||||
Feb 26, 2020 at 8:52 | comment | added | JGeer |
Thanks a lot, was something small as adding a ; after the return $_product . I edit your answer, so that we have the correct code! :)
|
|
Feb 26, 2020 at 8:52 | history | edited | JGeer | CC BY-SA 4.0 |
added 1 character in body
|
Feb 26, 2020 at 8:43 | comment | added | Pankaj Pareek | By uncomment ini_set('display_errors', 1); from bootstrap.php file .. you can see error instead of blank page | |
Feb 26, 2020 at 8:37 | comment | added | JGeer | Thanks a lot for your help. But it seems that something is wrong in the code. I get a blank page when editing the helper data. Are we missing something? | |
Feb 26, 2020 at 4:44 | history | answered | Pankaj Pareek | CC BY-SA 4.0 |