magento2 icon indicating copy to clipboard operation
magento2 copied to clipboard

Grouped product with tax throws exception with PHP 8.1

Open craig-bartlett opened this issue 2 years ago • 19 comments

Preconditions and environment

  • Magento 2.4.4
  • PHP 8.1 (though 8.0 is probably the same)
  • Tax applied (in my case a blanket 20% tax)

Steps to reproduce

  1. Create a simple product
  2. Create a grouped product and add the simple product to it, add the grouped product to a category
  3. Ensure tax will be applied (in my case, I added a new tax zone for the UK, all regions and zip codes, at a rate of 20%. I applied this to the Retail Customer class, and set all customer groups to use it)
  4. Set both options to "Including and Excluding Tax" under Store > Configuration > Sales > Tax > Price Display Settings
  5. Run bin/magento setup:upgrade (not entirely sure this is needed), bin/magento c:f and bin/magento index:reindex
  6. Navigate to the category the grouped product belongs to on frontend

Expected result

A list of products belonging to the category should be displayed.

Actual result

An exception is thrown:

main.CRITICAL: Exception: Deprecated Functionality: ucfirst(): Passing null to parameter #1 ($string) of type string is deprecated in /var/www/m24/vendor/magento/module-tax/Pricing/Render/Adjustment.php on line 188 in /var/www/m24/vendor/magento/framework/App/ErrorHandler.php:61 Stack trace: #0 [internal function]: Magento\Framework\App\ErrorHandler->handler() #1 /var/www/m24/vendor/magento/module-tax/Pricing/Render/Adjustment.php(188): ucfirst() #2 /var/www/m24/vendor/magento/module-tax/view/base/templates/pricing/adjustment.phtml(15): Magento\Tax\Pricing\Render\Adjustment->getDataPriceType() #3 /var/www/m24/vendor/magento/framework/View/TemplateEngine/Php.php(71): include('...') #4 /var/www/m24/vendor/magento/framework/View/Element/Template.php(263): Magento\Framework\View\TemplateEngine\Php->render() #5 /var/www/m24/vendor/magento/framework/View/Element/Template.php(293): Magento\Framework\View\Element\Template->fetchView() #6 /var/www/m24/vendor/magento/framework/View/Element/AbstractBlock.php(1095): Magento\Framework\View\Element\Template->_toHtml() #7 /var/www/m24/vendor/magento/framework/View/Element/AbstractBlock.php(1099): Magento\Framework\View\Element\AbstractBlock->Magento\Framework\View\Element\{closure}() #8 /var/www/m24/vendor/magento/framework/View/Element/AbstractBlock.php(660): Magento\Framework\View\Element\AbstractBlock->_loadCache() #9 /var/www/m24/vendor/magento/module-tax/Pricing/Render/Adjustment.php(64): Magento\Framework\View\Element\AbstractBlock->toHtml() #10 /var/www/m24/vendor/magento/framework/Pricing/Render/AbstractAdjustment.php(57): Magento\Tax\Pricing\Render\Adjustment->apply() #11 /var/www/m24/vendor/magento/framework/Pricing/Render/Amount.php(205): Magento\Framework\Pricing\Render\AbstractAdjustment->render() #12 /var/www/m24/vendor/magento/framework/Pricing/Render/Amount.php(176): Magento\Framework\Pricing\Render\Amount->getAdjustments() #13 /var/www/m24/vendor/magento/framework/View/Element/AbstractBlock.php(1095): Magento\Framework\Pricing\Render\Amount->_toHtml() #14 /var/www/m24/vendor/magento/framework/View/Element/AbstractBlock.php(1099): Magento\Framework\View\Element\AbstractBlock->Magento\Framework\View\Element\{closure}() #15 /var/www/m24/vendor/magento/framework/View/Element/AbstractBlock.php(660): Magento\Framework\View\Element\AbstractBlock->_loadCache() #16 /var/www/m24/vendor/magento/module-grouped-product/view/base/templates/product/price/final_price.phtml(30): Magento\Framework\View\Element\AbstractBlock->toHtml() #17 /var/www/m24/vendor/magento/framework/View/TemplateEngine/Php.php(71): include('...') #18 /var/www/m24/vendor/magento/framework/View/Element/Template.php(263): Magento\Framework\View\TemplateEngine\Php->render() #19 /var/www/m24/generated/code/Magento/Catalog/Pricing/Render/FinalPriceBox/Interceptor.php(194): Magento\Framework\View\Element\Template->fetchView() #20 /var/www/m24/vendor/magento/framework/View/Element/Template.php(293): Magento\Catalog\Pricing\Render\FinalPriceBox\Interceptor->fetchView() #21 /var/www/m24/vendor/magento/framework/Pricing/Render/PriceBox.php(69): Magento\Framework\View\Element\Template->_toHtml() #22 /var/www/m24/vendor/magento/module-catalog/Pricing/Render/FinalPriceBox.php(71): Magento\Framework\Pricing\Render\PriceBox->_toHtml() #23 /var/www/m24/vendor/magento/framework/View/Element/AbstractBlock.php(1095): Magento\Catalog\Pricing\Render\FinalPriceBox->_toHtml() #24 /var/www/m24/vendor/magento/framework/Cache/LockGuardedCacheLoader.php(136): Magento\Framework\View\Element\AbstractBlock->Magento\Framework\View\Element\{closure}() #25 /var/www/m24/vendor/magento/framework/View/Element/AbstractBlock.php(1117): Magento\Framework\Cache\LockGuardedCacheLoader->lockedLoadData() #26 /var/www/m24/vendor/magento/framework/View/Element/AbstractBlock.php(660): Magento\Framework\View\Element\AbstractBlock->_loadCache() #27 /var/www/m24/generated/code/Magento/Catalog/Pricing/Render/FinalPriceBox/Interceptor.php(410): Magento\Framework\View\Element\AbstractBlock->toHtml() #28 /var/www/m24/vendor/magento/framework/Pricing/Render.php(97): Magento\Catalog\Pricing\Render\FinalPriceBox\Interceptor->toHtml() #29 /var/www/m24/vendor/magento/module-catalog/Block/Product/ListProduct.php(411): Magento\Framework\Pricing\Render->render() #30 /var/www/m24/generated/code/Magento/Catalog/Block/Product/ListProduct/Interceptor.php(131): Magento\Catalog\Block\Product\ListProduct->getProductPrice() #31 /var/www/m24/vendor/magento/module-catalog/view/frontend/templates/product/list.phtml(77): Magento\Catalog\Block\Product\ListProduct\Interceptor->getProductPrice() #32 /var/www/m24/vendor/magento/framework/View/TemplateEngine/Php.php(71): include('...') #33 /var/www/m24/vendor/magento/framework/View/Element/Template.php(263): Magento\Framework\View\TemplateEngine\Php->render() #34 /var/www/m24/generated/code/Magento/Catalog/Block/Product/ListProduct/Interceptor.php(392): Magento\Framework\View\Element\Template->fetchView() #35 /var/www/m24/vendor/magento/framework/View/Element/Template.php(293): Magento\Catalog\Block\Product\ListProduct\Interceptor->fetchView() #36 /var/www/m24/vendor/magento/framework/View/Element/AbstractBlock.php(1095): Magento\Framework\View\Element\Template->_toHtml() #37 /var/www/m24/vendor/magento/framework/View/Element/AbstractBlock.php(1099): Magento\Framework\View\Element\AbstractBlock->Magento\Framework\View\Element\{closure}() #38 /var/www/m24/vendor/magento/framework/View/Element/AbstractBlock.php(660): Magento\Framework\View\Element\AbstractBlock->_loadCache() #39 /var/www/m24/generated/code/Magento/Catalog/Block/Product/ListProduct/Interceptor.php(617): Magento\Framework\View\Element\AbstractBlock->toHtml() #40 /var/www/m24/vendor/magento/framework/View/Layout.php(578): Magento\Catalog\Block\Product\ListProduct\Interceptor->toHtml() #41 /var/www/m24/vendor/magento/framework/View/Layout.php(555): Magento\Framework\View\Layout->_renderBlock() #42 /var/www/m24/generated/code/Magento/Framework/View/Layout/Interceptor.php(149): Magento\Framework\View\Layout->renderNonCachedElement() #43 /var/www/m24/vendor/magento/framework/View/Layout.php(510): Magento\Framework\View\Layout\Interceptor->renderNonCachedElement() #44 /var/www/m24/generated/code/Magento/Framework/View/Layout/Interceptor.php(140): Magento\Framework\View\Layout->renderElement() #45 /var/www/m24/vendor/magento/framework/View/Element/AbstractBlock.php(507): Magento\Framework\View\Layout\Interceptor->renderElement() #46 /var/www/m24/vendor/magento/module-catalog/Block/Category/View.php(100): Magento\Framework\View\Element\AbstractBlock->getChildHtml() #47 /var/www/m24/vendor/magento/module-catalog/view/frontend/templates/category/products.phtml(15): Magento\Catalog\Block\Category\View->getProductListHtml() #48 /var/www/m24/vendor/magento/framework/View/TemplateEngine/Php.php(71): include('...') #49 /var/www/m24/vendor/magento/framework/View/Element/Template.php(263): Magento\Framework\View\TemplateEngine\Php->render() #50 /var/www/m24/vendor/magento/framework/View/Element/Template.php(293): Magento\Framework\View\Element\Template->fetchView() #51 /var/www/m24/vendor/magento/framework/View/Element/AbstractBlock.php(1095): Magento\Framework\View\Element\Template->_toHtml() #52 /var/www/m24/vendor/magento/framework/View/Element/AbstractBlock.php(1099): Magento\Framework\View\Element\AbstractBlock->Magento\Framework\View\Element\{closure}() #53 /var/www/m24/vendor/magento/framework/View/Element/AbstractBlock.php(660): Magento\Framework\View\Element\AbstractBlock->_loadCache() #54 /var/www/m24/vendor/magento/framework/View/Layout.php(578): Magento\Framework\View\Element\AbstractBlock->toHtml() #55 /var/www/m24/vendor/magento/framework/View/Layout.php(555): Magento\Framework\View\Layout->_renderBlock() #56 /var/www/m24/generated/code/Magento/Framework/View/Layout/Interceptor.php(149): Magento\Framework\View\Layout->renderNonCachedElement() #57 /var/www/m24/vendor/magento/framework/View/Layout.php(510): Magento\Framework\View\Layout\Interceptor->renderNonCachedElement() #58 /var/www/m24/generated/code/Magento/Framework/View/Layout/Interceptor.php(140): Magento\Framework\View\Layout->renderElement() #59 /var/www/m24/vendor/magento/framework/View/Layout.php(606): Magento\Framework\View\Layout\Interceptor->renderElement() #60 /var/www/m24/vendor/magento/framework/View/Layout.php(557): Magento\Framework\View\Layout->_renderContainer() #61 /var/www/m24/generated/code/Magento/Framework/View/Layout/Interceptor.php(149): Magento\Framework\View\Layout->renderNonCachedElement() #62 /var/www/m24/vendor/magento/framework/View/Layout.php(510): Magento\Framework\View\Layout\Interceptor->renderNonCachedElement() #63 /var/www/m24/generated/code/Magento/Framework/View/Layout/Interceptor.php(140): Magento\Framework\View\Layout->renderElement() #64 /var/www/m24/vendor/magento/framework/View/Layout.php(606): Magento\Framework\View\Layout\Interceptor->renderElement() #65 /var/www/m24/vendor/magento/framework/View/Layout.php(557): Magento\Framework\View\Layout->_renderContainer() #66 /var/www/m24/generated/code/Magento/Framework/View/Layout/Interceptor.php(149): Magento\Framework\View\Layout->renderNonCachedElement() #67 /var/www/m24/vendor/magento/framework/View/Layout.php(510): Magento\Framework\View\Layout\Interceptor->renderNonCachedElement() #68 /var/www/m24/generated/code/Magento/Framework/View/Layout/Interceptor.php(140): Magento\Framework\View\Layout->renderElement() #69 /var/www/m24/vendor/magento/framework/View/Layout.php(606): Magento\Framework\View\Layout\Interceptor->renderElement() #70 /var/www/m24/vendor/magento/framework/View/Layout.php(557): Magento\Framework\View\Layout->_renderContainer() #71 /var/www/m24/generated/code/Magento/Framework/View/Layout/Interceptor.php(149): Magento\Framework\View\Layout->renderNonCachedElement() #72 /var/www/m24/vendor/magento/framework/View/Layout.php(510): Magento\Framework\View\Layout\Interceptor->renderNonCachedElement() #73 /var/www/m24/generated/code/Magento/Framework/View/Layout/Interceptor.php(140): Magento\Framework\View\Layout->renderElement() #74 /var/www/m24/vendor/magento/framework/View/Layout.php(606): Magento\Framework\View\Layout\Interceptor->renderElement() #75 /var/www/m24/vendor/magento/framework/View/Layout.php(557): Magento\Framework\View\Layout->_renderContainer() #76 /var/www/m24/generated/code/Magento/Framework/View/Layout/Interceptor.php(149): Magento\Framework\View\Layout->renderNonCachedElement() #77 /var/www/m24/vendor/magento/framework/View/Layout.php(510): Magento\Framework\View\Layout\Interceptor->renderNonCachedElement() #78 /var/www/m24/generated/code/Magento/Framework/View/Layout/Interceptor.php(140): Magento\Framework\View\Layout->renderElement() #79 /var/www/m24/vendor/magento/framework/View/Layout.php(606): Magento\Framework\View\Layout\Interceptor->renderElement() #80 /var/www/m24/vendor/magento/framework/View/Layout.php(557): Magento\Framework\View\Layout->_renderContainer() #81 /var/www/m24/generated/code/Magento/Framework/View/Layout/Interceptor.php(149): Magento\Framework\View\Layout->renderNonCachedElement() #82 /var/www/m24/vendor/magento/framework/View/Layout.php(510): Magento\Framework\View\Layout\Interceptor->renderNonCachedElement() #83 /var/www/m24/generated/code/Magento/Framework/View/Layout/Interceptor.php(140): Magento\Framework\View\Layout->renderElement() #84 /var/www/m24/vendor/magento/framework/View/Layout.php(606): Magento\Framework\View\Layout\Interceptor->renderElement() #85 /var/www/m24/vendor/magento/framework/View/Layout.php(557): Magento\Framework\View\Layout->_renderContainer() #86 /var/www/m24/generated/code/Magento/Framework/View/Layout/Interceptor.php(149): Magento\Framework\View\Layout->renderNonCachedElement() #87 /var/www/m24/vendor/magento/framework/View/Layout.php(510): Magento\Framework\View\Layout\Interceptor->renderNonCachedElement() #88 /var/www/m24/generated/code/Magento/Framework/View/Layout/Interceptor.php(140): Magento\Framework\View\Layout->renderElement() #89 /var/www/m24/vendor/magento/framework/View/Layout.php(975): Magento\Framework\View\Layout\Interceptor->renderElement() #90 /var/www/m24/vendor/magento/framework/Interception/Interceptor.php(58): Magento\Framework\View\Layout->getOutput() #91 /var/www/m24/vendor/magento/framework/Interception/Interceptor.php(138): Magento\Framework\View\Layout\Interceptor->___callParent() #92 /var/www/m24/vendor/magento/framework/Interception/Interceptor.php(153): Magento\Framework\View\Layout\Interceptor->Magento\Framework\Interception\{closure}() #93 /var/www/m24/generated/code/Magento/Framework/View/Layout/Interceptor.php(347): Magento\Framework\View\Layout\Interceptor->___callPlugins() #94 /var/www/m24/vendor/magento/framework/View/Result/Page.php(260): Magento\Framework\View\Layout\Interceptor->getOutput() #95 /var/www/m24/vendor/magento/framework/View/Result/Layout.php(171): Magento\Framework\View\Result\Page->render() #96 /var/www/m24/vendor/magento/framework/Interception/Interceptor.php(58): Magento\Framework\View\Result\Layout->renderResult() #97 /var/www/m24/vendor/magento/framework/Interception/Interceptor.php(138): Magento\Framework\View\Result\Page\Interceptor->___callParent() #98 /var/www/m24/vendor/magento/framework/Interception/Interceptor.php(153): Magento\Framework\View\Result\Page\Interceptor->Magento\Framework\Interception\{closure}() #99 /var/www/m24/generated/code/Magento/Framework/View/Result/Page/Interceptor.php(95): Magento\Framework\View\Result\Page\Interceptor->___callPlugins() #100 /var/www/m24/vendor/magento/framework/App/Http.php(120): Magento\Framework\View\Result\Page\Interceptor->renderResult() #101 /var/www/m24/generated/code/Magento/Framework/App/Http/Interceptor.php(23): Magento\Framework\App\Http->launch() #102 /var/www/m24/vendor/magento/framework/App/Bootstrap.php(264): Magento\Framework\App\Http\Interceptor->launch() #103 /var/www/m24/pub/index.php(30): Magento\Framework\App\Bootstrap->run() #104 {main} [] []

Additional information

For whatever reason the priceType returned by amountRender is null, which is not a valid parameter for ucfirst in PHP 8. I suspect this has something to do with how grouped products calculate their display price but haven't tracked it down yet.

vendor/magento/module-tax/Pricing/Render/Adjustment.php line 184:

public function getDataPriceType(): string { return $this->amountRender->getPriceType() === 'finalPrice' ? 'basePrice' : 'base' . ucfirst($this->amountRender->getPriceType()); }

Release note

No response

Triage and priority

  • [X] Severity: S0 - Affects critical data or functionality and leaves users without workaround.
  • [ ] Severity: S1 - Affects critical data or functionality and forces users to employ a workaround.
  • [ ] Severity: S2 - Affects non-critical data or functionality and forces users to employ a workaround.
  • [ ] Severity: S3 - Affects non-critical data or functionality and does not force users to employ a workaround.
  • [ ] Severity: S4 - Affects aesthetics, professional look and feel, “quality” or “usability”.

craig-bartlett avatar May 19 '22 10:05 craig-bartlett

Hi @craig-bartlett. Thank you for your report. To speed up processing of this issue, make sure that you provided the following information:

  • Summary of the issue
  • Information on your environment
  • Steps to reproduce
  • Expected and actual results

Make sure that the issue is reproducible on the vanilla Magento instance following Steps to reproduce. To deploy vanilla Magento instance on our environment, Add a comment to the issue:

@magento give me 2.4-develop instance - upcoming 2.4.x release

For more details, review the Magento Contributor Assistant documentation.

Add a comment to assign the issue: @magento I am working on this

To learn more about issue processing workflow, refer to the Code Contributions.


:warning: According to the Magento Contribution requirements, all issues must go through the Community Contributions Triage process. Community Contributions Triage is a public meeting.

:clock10: You can find the schedule on the Magento Community Calendar page.

:telephone_receiver: The triage of issues happens in the queue order. If you want to speed up the delivery of your contribution, join the Community Contributions Triage session to discuss the appropriate ticket.

:pencil2: Feel free to post questions/proposals/feedback related to the Community Contributions Triage process to the corresponding Slack Channel

m2-assistant[bot] avatar May 19 '22 10:05 m2-assistant[bot]

@magento give me 2.4-develop instance

craig-bartlett avatar May 19 '22 10:05 craig-bartlett

Hi @craig-bartlett. Thank you for your request. I'm working on Magento instance for you.

Hi @craig-bartlett, here is your Magento Instance: https://6eb68f34bcc5d34d09c14848a1879228.instances.magento-community.engineering Admin access: https://6eb68f34bcc5d34d09c14848a1879228.instances.magento-community.engineering/admin_f54e Login: e36ffb2a Password: 1be9859c089c

Doesn't seem to occur on the test instance - is it on PHP 8?

craig-bartlett avatar May 19 '22 10:05 craig-bartlett

Hi @engcom-Delta. Thank you for working on this issue. In order to make sure that issue has enough information and ready for development, please read and check the following instruction: :point_down:

  • [ ] 1. Verify that issue has all the required information. (Preconditions, Steps to reproduce, Expected result, Actual result).

    DetailsIf the issue has a valid description, the label Issue: Format is valid will be added to the issue automatically. Please, edit issue description if needed, until label Issue: Format is valid appears.

  • [ ] 2. Verify that issue has a meaningful description and provides enough information to reproduce the issue. If the report is valid, add Issue: Clear Description label to the issue by yourself.

  • [ ] 3. Add Component: XXXXX label(s) to the ticket, indicating the components it may be related to.

  • [ ] 4. Verify that the issue is reproducible on 2.4-develop branch

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

  • [ ] 5. Add label Issue: Confirmed once verification is complete.

  • [ ] 6. Make sure that automatic system confirms that report has been added to the backlog.

m2-assistant[bot] avatar May 19 '22 10:05 m2-assistant[bot]

Hi @craig-bartlett ,

We tried to reproduce the issue on Magento 2.4.4 instance & 2.4 develop instance, unfortunately issue is not reproducible. Pre-condtion:

Screenshot 2022-05-19 at 5 17 55 PM
  1. Create a simple product
Screenshot 2022-05-19 at 4 59 14 PM
  1. Create a grouped product and add the simple product to it, add the grouped product to a category
Screenshot 2022-05-19 at 5 04 54 PM
  1. Ensure tax will be applied (in my case, I added a new tax zone for the UK, all regions and zip codes, at a rate of 20%. I applied this to the Retail Customer class, and set all customer groups to use it) Set both options to "Including and Excluding Tax" under Store > Configuration > Sales > Tax > Price Display Settings
Screenshot 2022-05-19 at 5 17 55 PM Screenshot 2022-05-19 at 5 39 21 PM
  1. bin/magento index:reindex
Screenshot 2022-05-19 at 7 01 32 PM
  1. Navigate to the category the grouped product belongs to on frontend
Screenshot 2022-05-19 at 6 11 03 PM Screenshot 2022-05-19 at 6 12 59 PM

Actual Results: Products are getting displayed on Frontend without error .

Kindly correct me if my steps are wrong in reproducing the issue.

engcom-Delta avatar May 19 '22 13:05 engcom-Delta

Hi @engcom-Delta

Is this running PHP 8.1? From the error it looks like it's the deprecation added in 8.1 "Passing null to non-nullable internal function parameters is deprecated" from https://www.php.net/releases/8.1/en.php

Also the error occurs when viewing the category that the grouped product belongs to, not when viewing the product itself.

Thanks :)

craig-bartlett avatar May 19 '22 13:05 craig-bartlett

Hi @craig-bartlett , We have PHP 8.1 installed and we are using the same & We do not get any error when viewing the category that grouped belongs to it. please have a look and confirm us.

Screenshot 2022-05-20 at 10 09 10 PM Screenshot 2022-05-20 at 10 05 09 PM

engcom-Delta avatar May 20 '22 16:05 engcom-Delta

Hi @engcom-Delta

I'll refresh my environment and try to reproduce it again to make sure I didn't miss a step. In the meantime - did you set the tax rule to apply for all customers? Only your last screenshot doesn't show the incl. and excl. tax prices in the category view, even though the screenshot before shows that setting enabled.

Thanks again.

craig-bartlett avatar May 23 '22 07:05 craig-bartlett

Hi @engcom-Delta

I re-ran the full scenario from scratch and took screen shots along the way. I managed to reproduce the error.

  • First I created 2 simple products and 1 grouped product, all in the same category and set to in-stock. I assigned the two simple products to the grouped product. At this point they display fine.
Screenshot 2022-05-23 at 13 25 36
  • I then created the tax rates as before and ensured it applied to all customers.
Screenshot 2022-05-23 at 13 29 14 Screenshot 2022-05-23 at 13 28 23 Screenshot 2022-05-23 at 13 27 58
  • I changed the price settings to display catalog prices with and without tax.
Screenshot 2022-05-23 at 13 31 35
  • At this point I wanted to make sure it was a PHP 8.1 issue, so I left my machine running PHP 7.4. I ran setup:upgrade, cache:clear, cleared the generated/ folder, and ran a reindex. The page displayed as expected (note the "excl tax" price shows).
Screenshot 2022-05-23 at 13 37 24
  • Finally I swapped to PHP 8.1. I wiped generated/ again, ran setup:upgrade, cache:clear, and ran a full reindex. This resulted in the page displaying incorrectly.
Screenshot 2022-05-23 at 13 49 13

In system.log I found the same error from before.

Screenshot 2022-05-23 at 13 50 24

If I swap back to PHP 7.4 it works fine, so I'm 99% sure this is a PHP 8.1 issue. For whatever reason, ucfirst() is being provided null as its parameter which is not allowed in PHP 8.1. This occurs in Magento\Tax\Pricing\Render\Adjustment (https://github.com/magento/magento2/blob/2.4-develop/app/code/Magento/Tax/Pricing/Render/Adjustment.php#L184). I don't know why getPriceType() returns null yet, or if it's even normal.

I've forced it to work in my own environment by applying a plugin. The following plugin ensures that ucfirst() is not called on null. As I said, I'm not sure why getPriceType() is returning null yet in the first place, so if anyone else has this issue - use at your own risk:

     /**
     * @param Adjustment $subject
     * @param callable $proceed
     * @return string
     */
    public function aroundGetDataPriceType(Adjustment $subject, callable $proceed): String
    {
        $priceType = $subject->getAmountRender()->getPriceType();
        return $priceType === 'finalPrice'
                ? 'basePrice'
                : 'base' . ucfirst($priceType ?? "");
    }

craig-bartlett avatar May 23 '22 13:05 craig-bartlett

Hi @craig-bartlett ,

Thank you so much for sharing the detailed steps and it is reproducible on Magento 2.4.4 instance with PHP 8.1 . Hence marking the ticket issue is reproducible.

  1. created 2 simple products and 1 grouped product, all in the same category and set to in-stock. I assigned the two simple products to the grouped product. At this point they display fine.
Screenshot 2022-05-24 at 3 12 40 PM Screenshot 2022-05-24 at 5 35 51 PM
  1. then created the tax rates as before and ensured it applied to all customers.
Screenshot 2022-05-24 at 5 49 57 PM
  1. Tax rules
Screenshot 2022-05-24 at 6 00 37 PM
  1. Changed the price settings to display catalog prices with and without tax.
Screenshot 2022-05-24 at 6 11 20 PM
  1. I wiped generated/ again, ran setup:upgrade, cache:clear, and ran a full reindex. This resulted in the page displaying incorrectly.
Screenshot 2022-05-24 at 9 03 03 PM

Thanks

engcom-Delta avatar May 24 '22 15:05 engcom-Delta

:white_check_mark: Jira issue https://jira.corp.magento.com/browse/AC-3157 is successfully created for this GitHub issue.

github-jira-sync-bot avatar May 24 '22 15:05 github-jira-sync-bot

:white_check_mark: Confirmed by @engcom-Delta. Thank you for verifying the issue.
Issue Available: @engcom-Delta, You will be automatically unassigned. Contributors/Maintainers can claim this issue to continue. To reclaim and continue work, reassign the ticket to yourself.

m2-assistant[bot] avatar May 24 '22 15:05 m2-assistant[bot]

@magento i'm working on it.

Pranav-242 avatar May 31 '22 06:05 Pranav-242

The exact same error is thrown when you try to configure bundle products through the adminhtml.

Hexmage avatar Jul 12 '22 15:07 Hexmage

Workaround:

change vendor/magento/module-tax/Pricing/Render/Adjustment.php:188

From : 'base' . ucfirst($this->amountRender->getPriceType()); To : 'base' . ucfirst($this->amountRender->getPriceType() ?: '');

Hexmage avatar Jul 26 '22 15:07 Hexmage

Hi @Hexmage

Cheers - for a temporary solution my plugin above does the same. It could also be applied as a Composer patch until this is fixed in the core.

Thanks

craig-bartlett avatar Jul 26 '22 15:07 craig-bartlett

found my way here with the same issue on a Cloud 2.4.4 upgrade - is there a patch planned? @Pranav-242

pixiemediaweb avatar Aug 04 '22 23:08 pixiemediaweb

Hello,

As I can see this issue got fixed in the scope of the internal Jira ticket AC-3157 by the internal team Related commits: https://github.com/magento/magento2/search?q=AC-3157&type=commits

Based on the Jira ticket, the target version is 2.4.6.

Thanks

engcom-Hotel avatar Sep 07 '22 10:09 engcom-Hotel

Patch for Magento 2.4.5-p1 to use with vaimo/composer-patches;

@package magento/module-tax
@link https://github.com/magento/magento2/issues/35500
@level 0

diff --git Pricing/Render/Adjustment.php Pricing/Render/Adjustment.php
index 0e5c619..06f4e02 100644
--- Pricing/Render/Adjustment.php
+++ Pricing/Render/Adjustment.php
@@ -185,6 +185,6 @@ class Adjustment extends AbstractAdjustment
     {
         return $this->amountRender->getPriceType() === 'finalPrice'
             ? 'basePrice'
-            : 'base' . ucfirst($this->amountRender->getPriceType());
+            : 'base' . ucfirst($this->amountRender->getPriceType() ?? '');
     }
 }

peterjaap avatar Dec 09 '22 10:12 peterjaap