2

I have created a custom block in my module to show the quantity of each product in list.phtml file. I modify in my custom template list.phtml with the code below

<?php
$myBlock= $block->getLayout()>createBlock('MyCompany\Helloworld\Block\Display');
echo $myBlock->getMyCustomMethod();
?>

but nothing appears and it also destroys the appearance. It only shows one product without any customization.

What am I doing wrong?

  • add your block file as well. – Yogesh Nov 16 '17 at 4:52
0

Use this code to show the quantity of each product in list.phtml file -

$objectManager = \Magento\Framework\App\ObjectManager::getInstance(); 
$myBlock =$objectManager->create('MyCompany\Helloworld\Block\Display');   
echo $myBlock->getMyCustomMethod();
  • Still nothing. My block does not appear and it ruins the appearance. – Christin Nov 18 '17 at 14:37

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.