1

I want to call a date.phtml template in catalog/product/view.phtml but i have the error: Call to a member function getId() on null in ...PATH line 28 and this line there is : <?php $_optionId = $_option->getId() ?>

I called it like this:

<?php echo $this->getLayout()->createBlock('core/template')->setTemplate('catalog/product/view/options/type/date.phtml')->toHtml(); ?>
1

You block type is wrong

It should be

catalog/product_view_options_type_date from core/template

So change:

<?php echo $this->getLayout()->createBlock('core/template')->setTemplate('catalog/product/view/options/type/date.phtml')->toHtml(); ?>

to

<?php echo $this->getLayout()->createBlock('catalog/product_view_options_type_date')->setTemplate('catalog/product/view/options/type/date.phtml')->toHtml(); ?>
1
  • i tried this type before but i have the same problem errorFatal error: Call to a member function getId() on null in /var/www/html/app/design/frontend/{package}/{theme}/template/catalog/product/view/options/type/date.phtml on line 28 – PЯINCƏ Feb 21 '17 at 10:48

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.