Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

$block->getProduct() in catalog product view template failed after upgrading from 2.3.0 to 2.3.1 #22036

Closed
Hailong opened this issue Mar 29, 2019 · 18 comments
Labels
Component: Catalog Event: dmcdindia1 Reproduced on 2.3.x The issue has been reproduced on latest 2.3 release Triage: Dev.Experience Issue related to Developer Experience and needs help with Triage to Confirm or Reject it

Comments

@Hailong
Copy link
Member

Hailong commented Mar 29, 2019

Preconditions (*)

  1. Magento 2.3.1
  2. Porto theme for Magento 2.3.x

Steps to reproduce (*)

  1. Install Magento 2.3.1
  2. Install Porto theme

Expected result (*)

  1. Product page renders with no problem

Actual result (*)

  1. Product page doesn't render

The problem is a new block class introduced in 2.3.1, while it doesn't provide the getProduct() method. It's not backward compatible. Created the pull request as well.

@magento-engcom-team magento-engcom-team added the Issue: Format is valid Gate 1 Passed. Automatic verification of issue format passed label Mar 29, 2019
@Hailong Hailong assigned Hailong and unassigned Hailong Mar 29, 2019
@Hailong
Copy link
Member Author

Hailong commented Mar 29, 2019

The PR#22034 request has been approved, but I'm not sure how to update the status of this bug.

@ghost ghost assigned Hailong Mar 29, 2019
@shikhamis11 shikhamis11 added Component: Catalog Issue: Confirmed Gate 3 Passed. Manual verification of the issue completed. Issue is confirmed Reproduced on 2.3.x The issue has been reproduced on latest 2.3 release Progress: PR Created Indicates that Pull Request has been created to fix issue labels Mar 29, 2019
@magento-engcom-team magento-engcom-team added the Issue: Ready for Work Gate 4. Acknowledged. Issue is added to backlog and ready for development label Mar 29, 2019
@magento-engcom-team
Copy link
Contributor

✅ Confirmed by @shikhamis11
Thank you for verifying the issue. Based on the provided information internal tickets MAGETWO-98977 were created

Issue Available: @shikhamis11, You will be automatically unassigned. Contributors/Maintainers can claim this issue to continue. To reclaim and continue work, reassign the ticket to yourself.

@Hailong Hailong removed their assignment Mar 29, 2019
@panteliskopsias
Copy link

Hello, same issue to me too. But i think that the error is at
at app/design/frontend/Smartwave/porto/Magento_Catalog/templates/product/view/details.phtml on line 18

$page_type = $_product->getData('product_page_type'); if(!$page_type) $page_type = isset($_config['product_page_type'])?$_config['product_page_type']:'';

@Hailong
Copy link
Member Author

Hailong commented Mar 30, 2019

Hi @panteliskopsias , if the $_product returned from Line 17 is NULL, then the null object reference error would be reported on Line 18. I'm not sure if that is the reason you see the error on Line 18.

@panteliskopsias
Copy link

Is it an easy way to fix it at details.phtml?

@Hailong
Copy link
Member Author

Hailong commented Mar 30, 2019

I got a fix at https://github.com/magento/magento2/pull/22034/files, please take a look.

@panteliskopsias
Copy link

i have seen it, but i have not
app/code/Magento/Catalog/Block/Product/View/Details.php

@Hailong
Copy link
Member Author

Hailong commented Mar 30, 2019

oh, it should be under the vendor directory if you installed it with composer.

@panteliskopsias
Copy link

Yes... i had installed it with composer.
The fix work!
Thank you!

@Hailong
Copy link
Member Author

Hailong commented Mar 30, 2019

Sounds good. I see a document about how to apply a patch, but I have not tried it yet. I installed my instance with a cloned repository which takes the fix.

@abhi-ranosys
Copy link

"I am working on this at #dmcdindia19”

@magento-engcom-team
Copy link
Contributor

@abhi-ranosys thank you for joining. Please accept team invitation here and self-assign the issue.

@abhi-ranosys
Copy link

I am working on this at #dmcdindia19

@m2-assistant
Copy link

m2-assistant bot commented May 4, 2019

Hi @abhi-ranosys. Thank you for working on this issue.
Looks like this issue is already verified and confirmed. But if you want to validate it one more time, please, go though the following instruction:

  • 1. Add/Edit Component: XXXXX label(s) to the ticket, indicating the components it may be related to.

  • 2. Verify that the issue is reproducible on 2.3-develop branch

    Details- Add the comment @magento-engcom-team give me 2.3-develop instance to deploy test instance on Magento infrastructure.
    - If the issue is reproducible on 2.3-develop branch, please, add the label Reproduced on 2.3.x.
    - If the issue is not reproducible, add your comment that issue is not reproducible and close the issue and stop verification process here!

  • 3. Verify that the issue is reproducible on 2.2-develop branch.

    Details- Add the comment @magento-engcom-team give me 2.2-develop instance to deploy test instance on Magento infrastructure.
    - If the issue is reproducible on 2.2-develop branch, please add the label Reproduced on 2.2.x

  • 4. If the issue is not relevant or is not reproducible any more, feel free to close it.

@abhisekumar
Copy link

abhisekumar commented May 22, 2019

oh, it should be under the vendor directory if you installed it with composer.

Yes its works .. Direct path will be
/vendor/magento/module-catalog/Block/Product/View

@ghost ghost unassigned abhi-ranosys Sep 27, 2019
@liquidia
Copy link

liquidia commented Nov 12, 2019

same issue when I try to fix it with given solution .. it gives me following error
`1 exception(s):
Exception #0 (Magento\Framework\Exception\RuntimeException): Type Error occurred when creating object: Magento\Catalog\Block\Product\View\Details\Interceptor
Exception #0 (Magento\Framework\Exception\RuntimeException): Type Error occurred when creating object: Magento\Catalog\Block\Product\View\Details\Interceptor

#1 Magento\Framework\ObjectManager\Factory\Dynamic\Developer->create() called at [vendor/magento/framework/ObjectManager/ObjectManager.php:56]
#2 Magento\Framework\ObjectManager\ObjectManager->create() called at [vendor/magento/framework/View/Element/BlockFactory.php:46]
#3 Magento\Framework\View\Element\BlockFactory->createBlock() called at [vendor/magento/framework/View/Layout/Generator/Block.php:268]
#4 Magento\Framework\View\Layout\Generator\Block->getBlockInstance() called at [vendor/magento/framework/View/Layout/Generator/Block.php:248]
#5 Magento\Framework\View\Layout\Generator\Block->createBlock() called at [vendor/magento/framework/View/Layout/Generator/Block.php:226]
#6 Magento\Framework\View\Layout\Generator\Block->generateBlock() called at [vendor/magento/framework/View/Layout/Generator/Block.php:134]
#7 Magento\Framework\View\Layout\Generator\Block->process() called at [vendor/magento/framework/View/Layout/GeneratorPool.php:81]
#8 Magento\Framework\View\Layout\GeneratorPool->process() called at [vendor/magento/framework/View/Layout.php:343]
#9 Magento\Framework\View\Layout->generateElements() called at [generated/code/Magento/Framework/View/Layout/Interceptor.php:89]
#10 Magento\Framework\View\Layout\Interceptor->generateElements() called at [vendor/magento/framework/View/Layout/Builder.php:129]
#11 Magento\Framework\View\Layout\Builder->generateLayoutBlocks() called at [vendor/magento/framework/View/Page/Builder.php:55]
#12 Magento\Framework\View\Page\Builder->generateLayoutBlocks() called at [vendor/magento/framework/View/Layout/Builder.php:65]
#13 Magento\Framework\View\Layout\Builder->build() called at [vendor/magento/framework/View/Page/Config.php:224]
#14 Magento\Framework\View\Page\Config->build() called at [vendor/magento/framework/View/Page/Config.php:237]
#15 Magento\Framework\View\Page\Config->publicBuild() called at [vendor/magento/framework/View/Result/Page.php:242]
#16 Magento\Framework\View\Result\Page->render() called at [vendor/magento/framework/View/Result/Layout.php:171]
#17 Magento\Framework\View\Result\Layout->renderResult() called at [vendor/magento/framework/Interception/Interceptor.php:58]
#18 Magento\Framework\View\Result\Page\Interceptor->___callParent() called at [vendor/magento/framework/Interception/Interceptor.php:138]
#19 Magento\Framework\View\Result\Page\Interceptor->Magento\Framework\Interception\{closure}() called at [vendor/magento/framework/Interception/Interceptor.php:153]
#20 Magento\Framework\View\Result\Page\Interceptor->___callPlugins() called at [generated/code/Magento/Framework/View/Result/Page/Interceptor.php:130]
#21 Magento\Framework\View\Result\Page\Interceptor->renderResult() called at [vendor/magento/framework/App/Http.php:141]
#22 Magento\Framework\App\Http->launch() called at [generated/code/Magento/Framework/App/Http/Interceptor.php:24]
#23 Magento\Framework\App\Http\Interceptor->launch() called at [vendor/magento/framework/App/Bootstrap.php:261]
#24 Magento\Framework\App\Bootstrap->run() called at [pub/index.php:40]
`

Any help?

@LiamTrioTech
Copy link

Think I'm seeing this issue on Magento 2.3.5 after upgrading from 2.2.0.

Fatal error: Uncaught Error: Call to a member function getSomeAttribute() on null in /var/www/html/app/design/frontend/Alothemes/default/Magento_Catalog/templates/product/view/details.phtml:15 Stack trace: #0 /var/www/html/vendor/magento/framework/View/TemplateEngine/Php.php(59): include() #1 /var/www/html/vendor/magento/framework/Interception/Interceptor.php(58): Magento\Framework\View\TemplateEngine\Php->render(Object(Magento\Catalog\Block\Product\View\Details\Interceptor), '/var/www/html/a...', Array) #2 /var/www/html/vendor/magento/framework/Interception/Interceptor.php(138): Magento\Framework\View\TemplateEngine\Php\Interceptor->___callParent('render', Array) #3 /var/www/html/vendor/magento/framework/Interception/Interceptor.php(153): Magento\Framework\View\TemplateEngine\Php\Interceptor->Magento\Framework\Interception\{closure}(Object(Magento\Catalog\Block\Product\View\Details\Interceptor), '/var/www/html/a...', Array) #4 /var/www/html/generated/code/Magento/Framework/View/TemplateEngine/Php/Interceptor.php(26): Magento\Fr in /var/www/html/app/design/frontend/Alothemes/default/Magento_Catalog/templates/product/view/details.phtml on line 15

$block->getProduct() is null.

Exception #0 (Magento\Framework\Exception\RuntimeException): Type Error occurred when creating object: Magento\Catalog\Block\Product\View\Details\Interceptor
bin/magento setup:upgrade
bin/magento setup:di:compile
bin/magento cache:flush
chown -R www-data:www-data .

Note: After applying the fix from https://github.com/magento/magento2/pull/22034/files it gives another error.
But after I run upgrade, di compile it fixes it.
Thanks very much.

Is there a patch for this that we can apply with composer or do I just have to upgrade to 2.4.x?

@sidolov sidolov added this to Ready for Grooming in Low Priority Backlog Sep 3, 2020
@m2-community-project m2-community-project bot removed Progress: PR Created Indicates that Pull Request has been created to fix issue Progress: ready for dev labels Sep 3, 2020
@sidolov sidolov added Reproduced on 2.4.x The issue has been reproduced on latest 2.4-develop branch and removed Reproduced on 2.4.x The issue has been reproduced on latest 2.4-develop branch labels Sep 4, 2020
@sidolov sidolov added this to Ready for Development in Low Priority Backlog Sep 24, 2020
@ghost ghost removed this from Ready for Dev in Community Backlog Oct 20, 2020
@ghost ghost removed this from Ready for Development in Low Priority Backlog Oct 20, 2020
@ghost ghost removed Issue: Format is valid Gate 1 Passed. Automatic verification of issue format passed Issue: Ready for Work Gate 4. Acknowledged. Issue is added to backlog and ready for development labels Oct 20, 2020
@sdzhepa sdzhepa added Triage: Dev.Experience Issue related to Developer Experience and needs help with Triage to Confirm or Reject it and removed Progress: ready for dev labels Oct 29, 2020
@gabrieldagama
Copy link
Contributor

We are sorry that you faced a backwards-incompatible change since that was released some time ago, any action now would create other problems. Closing this issue as there is not a real fix for it.

@m2-community-project m2-community-project bot removed the Issue: Confirmed Gate 3 Passed. Manual verification of the issue completed. Issue is confirmed label Nov 5, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Component: Catalog Event: dmcdindia1 Reproduced on 2.3.x The issue has been reproduced on latest 2.3 release Triage: Dev.Experience Issue related to Developer Experience and needs help with Triage to Confirm or Reject it
Projects
None yet
Development

No branches or pull requests