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

Display minimal configurable product special price cause Error : Call to undefined method ReflectionUnionType::getName() in /var/www/html/vendor/magento/framework/Interception/Code/Generator/Interceptor.php:216 #39719

Closed
Nolwennig-Jeulin opened this issue Mar 7, 2025 · 7 comments
Assignees
Labels
Issue: needs update Additional information is require, waiting for response Reported on 2.4.x Indicates original Magento version for the Issue report.

Comments

@Nolwennig-Jeulin
Copy link

In file src/app/code/Custom/Catalog/view/frontend/templates/product/list.phtml at line 303 I have call to <?= /* @noEscape */ $block->getProductPrice($product); ?>


This call use src/vendor/magento/module-catalog/Block/Product/ListProduct.php

/**
     * Get product price.
     *
     * @param Product $product
     * @return string
     */
    public function getProductPrice(Product $product)
    {
        $priceRender = $this->getPriceRender();

        $price = '';
        if ($priceRender) {
            $price = $priceRender->render(
                FinalPrice::PRICE_CODE,
                $product,
                [
                    'include_container' => true,
                    'display_minimal_price' => true,
                    'zone' => Render::ZONE_ITEM_LIST,
                    'list_category_page' => true
                ]
            );
        }

        return $price;
    }

src/app/code/Custom/ConfigurableProduct/view/frontend/templates/product/price/final_price.phtml

<?php if($block->hasSpecialPrice()): ?>
    <span class="old-price">
    <?= /* @noEscape */ $block->renderAmount(
        $block->getMinimalChildPriceAMount(),
        $block->getOldPriceArguments()
    ); ?>
    </span>
<?php endif;  ?>

$block is src/app/code/Custom/ConfigurableProduct/Pricing/Render/FinalPriceBox.php

In src/app/code/Custom/ConfigurableProduct/Pricing/Render/FinalPriceBox.php, I have :

<?php

/**
 * Class FinalPriceBox.
 *
 */

declare(strict_types=1);

namespace Custom\ConfigurableProduct\Pricing\Render;

use Custom\Catalog\Api\Pricing\Render\FinalPriceBoxEcoInterface;
use Custom\Catalog\Helper\Pricing\Render\EcoPriceHelper;
use Custom\Customer\Helper\StoreHelper;
use Magento\Catalog\Model\Product\Pricing\Renderer\SalableResolverInterface;
use Magento\Catalog\Pricing\Price\FinalPrice;
use Magento\Catalog\Pricing\Price\MinimalPriceCalculatorInterface;
use Magento\Catalog\Pricing\Price\RegularPrice;
use Magento\ConfigurableProduct\Pricing\Price\ConfigurableOptionsProviderInterface;
use Magento\ConfigurableProduct\Pricing\Render\FinalPriceBox as MagentoFinalPriceBox;
use Magento\Framework\Exception\NoSuchEntityException;
use Magento\Framework\Phrase;
use Magento\Framework\Pricing\Amount\Base;
use Magento\Framework\Pricing\Price\PriceInterface;
use Magento\Framework\Pricing\Render\RendererPool;
use Magento\Framework\Pricing\SaleableInterface;
use Magento\Framework\View\Element\Template\Context;
use Magento\Tax\Api\TaxCalculationInterface;

/**
 * Configurable product final price box.
 *
 * Custom\ConfigurableProduct\Pricing\Render
 */
class FinalPriceBox extends MagentoFinalPriceBox implements FinalPriceBoxEcoInterface
{
    /**
     * @var EcoPriceHelper
     */
    protected $ecoPriceHelper;

    /**
     * @var ConfigurableOptionsProviderInterface
     */
    private $configurableOptionsProvider;

    /**
     * @var \Magento\Tax\Api\TaxCalculationInterface
     */
    private $TaxCalculationInterface;

    /**
     * @var StoreHelper
     */
    protected $storeHelper;

    /**
     * Configurable product final price box block constructor.
     *
     * @param Context                              $context
     * @param SaleableInterface                    $saleableItem
     * @param PriceInterface                       $price
     * @param RendererPool                         $rendererPool
     * @param SalableResolverInterface             $salableResolver
     * @param MinimalPriceCalculatorInterface      $minimalPriceCalculator
     * @param ConfigurableOptionsProviderInterface $configurableOptionsProvider
     * @param EcoPriceHelper                       $ecoPriceHelper
     * @param TaxCalculationInterface              $TaxCalculationInterface
     * @param StoreHelper                          $storeHelper
     * @param array                                $data
     */
    public function __construct(
        Context $context,
        SaleableInterface $saleableItem,
        PriceInterface $price,
        RendererPool $rendererPool,
        SalableResolverInterface $salableResolver,
        MinimalPriceCalculatorInterface $minimalPriceCalculator,
        ConfigurableOptionsProviderInterface $configurableOptionsProvider,
        EcoPriceHelper $ecoPriceHelper,
        TaxCalculationInterface $TaxCalculationInterface,
        storeHelper $storeHelper,
        array $data = []
    ) {
        parent::__construct(
            $context,
            $saleableItem,
            $price,
            $rendererPool,
            $salableResolver,
            $minimalPriceCalculator,
            $configurableOptionsProvider,
            $data
        );

        $this->ecoPriceHelper = $ecoPriceHelper;
        $this->configurableOptionsProvider = $configurableOptionsProvider;
        $this->TaxCalculationInterface = $TaxCalculationInterface;
        $this->storeHelper = $storeHelper;
    }

    /**
     * @inheritDoc
     */
    public function isVisibleEcoPrice(): bool
    {
        return $this->ecoPriceHelper->isVisibleEcoPrice($this->saleableItem->getId(), $this->getZone());
    }

    /**
     * @inheritDoc
     *
     * @throws NoSuchEntityException
     */
    public function getEcoText(bool $oldPriceExists = false): Phrase
    {
        if ($oldPriceExists) {
            return $this->ecoPriceHelper->getEcoTextForOldPrice($this->saleableItem->getId());
        }

        return $this->ecoPriceHelper->getEcoText($this->saleableItem->getId());
    }

    /**
     * Returns true if it is TS store.
     *
     * @return bool
     */
    public function isTs(): bool
    {
        try {
            $result = $this->storeHelper->isTs();
        } catch (NoSuchEntityException $exception) {
            return false;
        }

        return $result;
    }

    /**
     * Returns old price arguments.
     *
     * @return array
     */
    public function getOldPriceArguments(): array
    {
        $idSuffix = $this->getIdSuffix() ?: '';
        $arguments = [
            'display_label'     => __('Instead of'),
            'price_id'          => $this->getPriceId('old-price-' . $idSuffix),
            'price_type'        => 'oldPrice',
            'include_container' => true,
        ];

        if (!$this->isTs()) {
            $arguments['skip_adjustments'] = true;
        }

        return $arguments;
    }

    /**
     * Return Minimal Child Price Amount
     *
     * @return Base|bool
     */
    public function getMinimalChildPriceAMount() : Base|bool
    {
        $prices = $this->getChildPrices();
        /** filter cheapest child product */
        $cheapestChildId = array_reduce(array_keys($prices), function ($prev, $id) use ($prices) {
            return ($prev === null || $prices[$id]['regular_price'] < $prices[$prev]['regular_price']) ? $id : $prev;
        }, null);

        /** Valid only if the cheapest child (which serves as call price) is on promotion */
        $regularPrice = $prices[$cheapestChildId][RegularPrice::PRICE_CODE];
        $finalPrice = $prices[$cheapestChildId][FinalPrice::PRICE_CODE];
        if ($finalPrice < $regularPrice) {
            $amount = new Base(
                $finalPrice,
                [
                    'tax' => ($finalPrice * $this->getTaxRate())
                ]
            );

            return $amount;
        }
        return false;
    }

    /**
     * Return [subproduct_sku => [regular_price, final_price]] for the current configurable parent product
     */
    private function getChildPrices(): array
    {
        $product = $this->getSaleableItem();
        $prices = [];

        foreach ($this->configurableOptionsProvider->getProducts($product) as $subProduct) {
            $regularPrice = $subProduct->getPriceInfo()->getPrice(RegularPrice::PRICE_CODE)->getValue();
            $finalPrice = $subProduct->getPriceInfo()->getPrice(FinalPrice::PRICE_CODE)->getValue();
            $prices[$subProduct->getSku()] =
                [
                    RegularPrice::PRICE_CODE => $regularPrice,
                    FinalPrice::PRICE_CODE => $finalPrice
                ];
        }
        return $prices;
    }

    /**
     * Return Tax Rate for the current product
     *
     * @return float
     */
    private function getTaxRate(): float
    {
        return $this->TaxCalculationInterface->getCalculatedRate(
            $this->getSaleableItem()->getTaxClassId()
        );
    }
}

In frontend https://custom.local/store_code/path/to/category/with/configurable-products.html (after setup:upgrade) I'm block by the error

 Error: Call to undefined method ReflectionUnionType::getName() in /var/www/html/vendor/magento/framework/Interception/Code/Generator/Interceptor.php:216
Stack trace:
#0 /var/www/html/vendor/magento/framework/Interception/Code/Generator/Interceptor.php(105): Magento\Framework\Interception\Code\Generator\Interceptor->getReturnTypeValue(Object(ReflectionMethod))
#1 /var/www/html/vendor/magento/framework/Interception/Code/Generator/Interceptor.php(76): Magento\Framework\Interception\Code\Generator\Interceptor->_getMethodInfo(Object(ReflectionMethod))
#2 /var/www/html/vendor/magento/framework/Code/Generator/EntityAbstract.php(228): Magento\Framework\Interception\Code\Generator\Interceptor->_getClassMethods()
#3 /var/www/html/vendor/magento/framework/Interception/Code/Generator/Interceptor.php(177): Magento\Framework\Code\Generator\EntityAbstract->_generateCode()
#4 /var/www/html/vendor/magento/framework/Code/Generator/EntityAbstract.php(108): Magento\Framework\Interception\Code\Generator\Interceptor->_generateCode()
#5 /var/www/html/vendor/magento/framework/Code/Generator.php(130): Magento\Framework\Code\Generator\EntityAbstract->generate()
#6 /var/www/html/vendor/magento/framework/Code/Generator/Autoloader.php(53): Magento\Framework\Code\Generator->generateClass('Custom\\Configur...')
#7 [internal function]: Magento\Framework\Code\Generator\Autoloader->load('Custom\\Configur...')
#8 /var/www/html/vendor/magento/framework/Code/Reader/ClassReader.php(34): ReflectionClass->__construct('Custom\\Configur...')
#9 /var/www/html/vendor/magento/framework/ObjectManager/Definition/Runtime.php(54): Magento\Framework\Code\Reader\ClassReader->getConstructor('Custom\\Configur...')
#10 /var/www/html/vendor/magento/framework/ObjectManager/Factory/Dynamic/Developer.php(48): Magento\Framework\ObjectManager\Definition\Runtime->getParameters('Custom\\Configur...')
#11 /var/www/html/vendor/magento/framework/ObjectManager/ObjectManager.php(56): Magento\Framework\ObjectManager\Factory\Dynamic\Developer->create('Custom\\Configur...', Array)
#12 /var/www/html/vendor/magento/framework/View/Element/BlockFactory.php(44): Magento\Framework\ObjectManager\ObjectManager->create('Custom\\Configur...', Array)
#13 /var/www/html/vendor/magento/framework/View/Layout/Generator/Block.php(272): Magento\Framework\View\Element\BlockFactory->createBlock('Custom\\Configur...', Array)
#14 /var/www/html/vendor/magento/framework/View/Layout/Generator/Block.php(252): Magento\Framework\View\Layout\Generator\Block->getBlockInstance('Custom\\Configur...', Array)
#15 /var/www/html/vendor/magento/framework/View/Layout.php(797): Magento\Framework\View\Layout\Generator\Block->createBlock('Custom\\Configur...', 'custom\\configur...', Array)
#16 /var/www/html/vendor/magento/framework/View/Layout.php(780): Magento\Framework\View\Layout->_createBlock('Custom\\Configur...', 'custom\\configur...', Array)
#17 /var/www/html/vendor/magento/framework/Interception/Interceptor.php(58): Magento\Framework\View\Layout->createBlock('Custom\\Configur...', 'custom\\configur...', Array)
#18 /var/www/html/vendor/magento/framework/Interception/Interceptor.php(138): Magento\Framework\View\Layout\Interceptor->___callParent('createBlock', Array)
#19 /var/www/html/vendor/magento/framework/Interception/Interceptor.php(153): Magento\Framework\View\Layout\Interceptor->Magento\Framework\Interception\{closure}('Custom\\Configur...', '', Array)
#20 /var/www/html/generated/code/Magento/Framework/View/Layout/Interceptor.php(248): Magento\Framework\View\Layout\Interceptor->___callPlugins('createBlock', Array, Array)
#21 /var/www/html/vendor/magento/framework/Pricing/Render/RendererPool.php(78): Magento\Framework\View\Layout\Interceptor->createBlock('Custom\\Configur...', '', Array)
#22 /var/www/html/vendor/magento/framework/Pricing/Render.php(96): Magento\Framework\Pricing\Render\RendererPool->createPriceRender('final_price', Object(Magento\Catalog\Model\Product\Interceptor), Array)
#23 /var/www/html/vendor/magento/module-catalog/Block/Product/ListProduct.php(411): Magento\Framework\Pricing\Render->render('final_price', Object(Magento\Catalog\Model\Product\Interceptor), Array)
#24 /var/www/html/generated/code/Magento/Catalog/Block/Product/ListProduct/Interceptor.php(131): Magento\Catalog\Block\Product\ListProduct->getProductPrice(Object(Magento\Catalog\Model\Product\Interceptor))
#25 /var/www/html/app/code/Custom/Catalog/view/frontend/templates/product/list.phtml(303): Magento\Catalog\Block\Product\ListProduct\Interceptor->getProductPrice(Object(Magento\Catalog\Model\Product\Interceptor))
#26 /var/www/html/vendor/magento/framework/View/TemplateEngine/Php.php(71): include('/var/www/html/a...')
#27 /var/www/html/vendor/magento/framework/Interception/Interceptor.php(58): Magento\Framework\View\TemplateEngine\Php->render(Object(Magento\Catalog\Block\Product\ListProduct\Interceptor), '/var/www/html/a...', Array)
#28 /var/www/html/vendor/magento/framework/Interception/Interceptor.php(138): Magento\Framework\View\TemplateEngine\Php\Interceptor->___callParent('render', Array)
#29 /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\ListProduct\Interceptor), '/var/www/html/a...', Array)
#30 /var/www/html/generated/code/Magento/Framework/View/TemplateEngine/Php/Interceptor.php(23): Magento\Framework\View\TemplateEngine\Php\Interceptor->___callPlugins('render', Array, Array)
#31 /var/www/html/vendor/magento/framework/View/Element/Template.php(263): Magento\Framework\View\TemplateEngine\Php\Interceptor->render(Object(Magento\Catalog\Block\Product\ListProduct\Interceptor), '/var/www/html/a...', Array)
#32 /var/www/html/generated/code/Magento/Catalog/Block/Product/ListProduct/Interceptor.php(392): Magento\Framework\View\Element\Template->fetchView('/var/www/html/a...')
#33 /var/www/html/vendor/magento/framework/View/Element/Template.php(293): Magento\Catalog\Block\Product\ListProduct\Interceptor->fetchView('/var/www/html/a...')
#34 /var/www/html/vendor/magento/framework/View/Element/AbstractBlock.php(1128): Magento\Framework\View\Element\Template->_toHtml()
#35 /var/www/html/vendor/magento/framework/View/Element/AbstractBlock.php(1132): Magento\Framework\View\Element\AbstractBlock->Magento\Framework\View\Element\{closure}()
#36 /var/www/html/vendor/magento/framework/View/Element/AbstractBlock.php(676): Magento\Framework\View\Element\AbstractBlock->_loadCache()
#37 /var/www/html/generated/code/Magento/Catalog/Block/Product/ListProduct/Interceptor.php(617): Magento\Framework\View\Element\AbstractBlock->toHtml()
#38 /var/www/html/vendor/magento/framework/View/Layout.php(578): Magento\Catalog\Block\Product\ListProduct\Interceptor->toHtml()
#39 /var/www/html/vendor/magento/framework/View/Layout.php(555): Magento\Framework\View\Layout->_renderBlock('category.produc...')
#40 /var/www/html/generated/code/Magento/Framework/View/Layout/Interceptor.php(149): Magento\Framework\View\Layout->renderNonCachedElement('category.produc...')
#41 /var/www/html/vendor/magento/framework/View/Layout.php(510): Magento\Framework\View\Layout\Interceptor->renderNonCachedElement('category.produc...')
#42 /var/www/html/generated/code/Magento/Framework/View/Layout/Interceptor.php(140): Magento\Framework\View\Layout->renderElement('category.produc...', true)
#43 /var/www/html/vendor/magento/framework/View/Element/AbstractBlock.php(523): Magento\Framework\View\Layout\Interceptor->renderElement('category.produc...', true)
#44 /var/www/html/vendor/magento/module-catalog/Block/Category/View.php(100): Magento\Framework\View\Element\AbstractBlock->getChildHtml('product_list')
#45 /var/www/html/vendor/magento/module-catalog/view/frontend/templates/category/products.phtml(15): Magento\Catalog\Block\Category\View->getProductListHtml()
#46 /var/www/html/vendor/magento/framework/View/TemplateEngine/Php.php(71): include('/var/www/html/v...')
#47 /var/www/html/vendor/magento/framework/Interception/Interceptor.php(58): Magento\Framework\View\TemplateEngine\Php->render(Object(Custom\Catalog\Block\Category\View), '/var/www/html/v...', Array)
#48 /var/www/html/vendor/magento/framework/Interception/Interceptor.php(138): Magento\Framework\View\TemplateEngine\Php\Interceptor->___callParent('render', Array)
#49 /var/www/html/vendor/magento/framework/Interception/Interceptor.php(153): Magento\Framework\View\TemplateEngine\Php\Interceptor->Magento\Framework\Interception\{closure}(Object(Custom\Catalog\Block\Category\View), '/var/www/html/v...', Array)
#50 /var/www/html/generated/code/Magento/Framework/View/TemplateEngine/Php/Interceptor.php(23): Magento\Framework\View\TemplateEngine\Php\Interceptor->___callPlugins('render', Array, Array)
#51 /var/www/html/vendor/magento/framework/View/Element/Template.php(263): Magento\Framework\View\TemplateEngine\Php\Interceptor->render(Object(Custom\Catalog\Block\Category\View), '/var/www/html/v...', Array)
#52 /var/www/html/vendor/magento/framework/View/Element/Template.php(293): Magento\Framework\View\Element\Template->fetchView('/var/www/html/v...')
#53 /var/www/html/vendor/magento/framework/View/Element/AbstractBlock.php(1128): Magento\Framework\View\Element\Template->_toHtml()
#54 /var/www/html/vendor/magento/framework/View/Element/AbstractBlock.php(1132): Magento\Framework\View\Element\AbstractBlock->Magento\Framework\View\Element\{closure}()
#55 /var/www/html/vendor/magento/framework/View/Element/AbstractBlock.php(676): Magento\Framework\View\Element\AbstractBlock->_loadCache()
#56 /var/www/html/vendor/magento/framework/View/Layout.php(578): Magento\Framework\View\Element\AbstractBlock->toHtml()
#57 /var/www/html/vendor/magento/framework/View/Layout.php(555): Magento\Framework\View\Layout->_renderBlock('category.produc...')
#58 /var/www/html/generated/code/Magento/Framework/View/Layout/Interceptor.php(149): Magento\Framework\View\Layout->renderNonCachedElement('category.produc...')
#59 /var/www/html/vendor/magento/framework/View/Layout.php(510): Magento\Framework\View\Layout\Interceptor->renderNonCachedElement('category.produc...')
#60 /var/www/html/generated/code/Magento/Framework/View/Layout/Interceptor.php(140): Magento\Framework\View\Layout->renderElement('category.produc...', false)
#61 /var/www/html/vendor/magento/framework/View/Layout.php(606): Magento\Framework\View\Layout\Interceptor->renderElement('category.produc...', false)
#62 /var/www/html/vendor/magento/framework/View/Layout.php(557): Magento\Framework\View\Layout->_renderContainer('content', false)
#63 /var/www/html/generated/code/Magento/Framework/View/Layout/Interceptor.php(149): Magento\Framework\View\Layout->renderNonCachedElement('content')
#64 /var/www/html/vendor/magento/framework/View/Layout.php(510): Magento\Framework\View\Layout\Interceptor->renderNonCachedElement('content')
#65 /var/www/html/generated/code/Magento/Framework/View/Layout/Interceptor.php(140): Magento\Framework\View\Layout->renderElement('content', false)
#66 /var/www/html/vendor/magento/framework/View/Layout.php(606): Magento\Framework\View\Layout\Interceptor->renderElement('content', false)
#67 /var/www/html/vendor/magento/framework/View/Layout.php(557): Magento\Framework\View\Layout->_renderContainer('main', false)
#68 /var/www/html/generated/code/Magento/Framework/View/Layout/Interceptor.php(149): Magento\Framework\View\Layout->renderNonCachedElement('main')
#69 /var/www/html/vendor/magento/framework/View/Layout.php(510): Magento\Framework\View\Layout\Interceptor->renderNonCachedElement('main')
#70 /var/www/html/generated/code/Magento/Framework/View/Layout/Interceptor.php(140): Magento\Framework\View\Layout->renderElement('main', false)
#71 /var/www/html/vendor/magento/framework/View/Layout.php(606): Magento\Framework\View\Layout\Interceptor->renderElement('main', false)
#72 /var/www/html/vendor/magento/framework/View/Layout.php(557): Magento\Framework\View\Layout->_renderContainer('columns', false)
#73 /var/www/html/generated/code/Magento/Framework/View/Layout/Interceptor.php(149): Magento\Framework\View\Layout->renderNonCachedElement('columns')
#74 /var/www/html/vendor/magento/framework/View/Layout.php(510): Magento\Framework\View\Layout\Interceptor->renderNonCachedElement('columns')
#75 /var/www/html/generated/code/Magento/Framework/View/Layout/Interceptor.php(140): Magento\Framework\View\Layout->renderElement('columns', false)
#76 /var/www/html/vendor/magento/framework/View/Layout.php(606): Magento\Framework\View\Layout\Interceptor->renderElement('columns', false)
#77 /var/www/html/vendor/magento/framework/View/Layout.php(557): Magento\Framework\View\Layout->_renderContainer('main.content', false)
#78 /var/www/html/generated/code/Magento/Framework/View/Layout/Interceptor.php(149): Magento\Framework\View\Layout->renderNonCachedElement('main.content')
#79 /var/www/html/vendor/magento/framework/View/Layout.php(510): Magento\Framework\View\Layout\Interceptor->renderNonCachedElement('main.content')
#80 /var/www/html/generated/code/Magento/Framework/View/Layout/Interceptor.php(140): Magento\Framework\View\Layout->renderElement('main.content', false)
#81 /var/www/html/vendor/magento/framework/View/Layout.php(606): Magento\Framework\View\Layout\Interceptor->renderElement('main.content', false)
#82 /var/www/html/vendor/magento/framework/View/Layout.php(557): Magento\Framework\View\Layout->_renderContainer('page.wrapper', false)
#83 /var/www/html/generated/code/Magento/Framework/View/Layout/Interceptor.php(149): Magento\Framework\View\Layout->renderNonCachedElement('page.wrapper')
#84 /var/www/html/vendor/magento/framework/View/Layout.php(510): Magento\Framework\View\Layout\Interceptor->renderNonCachedElement('page.wrapper')
#85 /var/www/html/generated/code/Magento/Framework/View/Layout/Interceptor.php(140): Magento\Framework\View\Layout->renderElement('page.wrapper', false)
#86 /var/www/html/vendor/magento/framework/View/Layout.php(606): Magento\Framework\View\Layout\Interceptor->renderElement('page.wrapper', false)
#87 /var/www/html/vendor/magento/framework/View/Layout.php(557): Magento\Framework\View\Layout->_renderContainer('root', false)
#88 /var/www/html/generated/code/Magento/Framework/View/Layout/Interceptor.php(149): Magento\Framework\View\Layout->renderNonCachedElement('root')
#89 /var/www/html/vendor/magento/framework/View/Layout.php(510): Magento\Framework\View\Layout\Interceptor->renderNonCachedElement('root')
#90 /var/www/html/generated/code/Magento/Framework/View/Layout/Interceptor.php(140): Magento\Framework\View\Layout->renderElement('root', true)
#91 /var/www/html/vendor/magento/framework/View/Layout.php(975): Magento\Framework\View\Layout\Interceptor->renderElement('root')
#92 /var/www/html/vendor/magento/framework/Interception/Interceptor.php(58): Magento\Framework\View\Layout->getOutput()
#93 /var/www/html/vendor/magento/framework/Interception/Interceptor.php(138): Magento\Framework\View\Layout\Interceptor->___callParent('getOutput', Array)
#94 /var/www/html/vendor/magento/framework/Interception/Interceptor.php(153): Magento\Framework\View\Layout\Interceptor->Magento\Framework\Interception\{closure}()
#95 /var/www/html/generated/code/Magento/Framework/View/Layout/Interceptor.php(347): Magento\Framework\View\Layout\Interceptor->___callPlugins('getOutput', Array, Array)
#96 /var/www/html/vendor/magento/framework/View/Result/Page.php(260): Magento\Framework\View\Layout\Interceptor->getOutput()
#97 /var/www/html/vendor/magento/framework/View/Result/Layout.php(171): Magento\Framework\View\Result\Page->render(Object(Magento\Framework\App\Response\Http\Interceptor))
#98 /var/www/html/vendor/magento/framework/Interception/Interceptor.php(58): Magento\Framework\View\Result\Layout->renderResult(Object(Magento\Framework\App\Response\Http\Interceptor))
#99 /var/www/html/vendor/magento/framework/Interception/Interceptor.php(138): Magento\Framework\View\Result\Page\Interceptor->___callParent('renderResult', Array)
#100 /var/www/html/vendor/magento/framework/Interception/Interceptor.php(153): Magento\Framework\View\Result\Page\Interceptor->Magento\Framework\Interception\{closure}(Object(Magento\Framework\App\Response\Http\Interceptor))
#101 /var/www/html/generated/code/Magento/Framework/View/Result/Page/Interceptor.php(95): Magento\Framework\View\Result\Page\Interceptor->___callPlugins('renderResult', Array, Array)
#102 /var/www/html/vendor/magento/framework/App/Http.php(120): Magento\Framework\View\Result\Page\Interceptor->renderResult(Object(Magento\Framework\App\Response\Http\Interceptor))
#103 /var/www/html/generated/code/Magento/Framework/App/Http/Interceptor.php(23): Magento\Framework\App\Http->launch()
#104 /var/www/html/vendor/magento/framework/App/Bootstrap.php(264): Magento\Framework\App\Http\Interceptor->launch()
#105 /var/www/html/pub/index.php(30): Magento\Framework\App\Bootstrap->run(Object(Magento\Framework\App\Http\Interceptor))
#106 {main}

The error is located in

$returnTypeValue .= ($returnType->getName() === 'self')

Copy link

m2-assistant bot commented Mar 7, 2025

Hi @Nolwennig-Jeulin. Thank you for your report.
To speed up processing of this issue, make sure that the issue is reproducible on the vanilla Magento instance following Steps to reproduce.


Join Magento Community Engineering Slack and ask your questions in #github channel.
⚠️ According to the Magento Contribution requirements, all issues must go through the Community Contributions Triage process. Community Contributions Triage is a public meeting.
🕙 You can find the schedule on the Magento Community Calendar page.
📞 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.

@engcom-Bravo engcom-Bravo self-assigned this Mar 10, 2025
Copy link

m2-assistant bot commented Mar 10, 2025

Hi @engcom-Bravo. 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: 👇

  • 1. Verify that issue has all the required information. (Preconditions, Steps to reproduce, Expected result, Actual result).
  • 2. Verify that issue has a meaningful description and provides enough information to reproduce the issue.
  • 3. Add Area: XXXXX label to the ticket, indicating the functional areas it may be related to.
  • 4. Verify that the issue is reproducible on 2.4-develop branch
    Details- 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.

@engcom-Bravo engcom-Bravo added the Reported on 2.4.x Indicates original Magento version for the Issue report. label Mar 10, 2025
@engcom-Bravo
Copy link
Contributor

Hi @Nolwennig-Jeulin,

Thank you for your reporting and collaboration.

To speed up the processing of this issue, please provide us with the following information:

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

Thanks.

@engcom-Bravo engcom-Bravo added the Issue: needs update Additional information is require, waiting for response label Mar 10, 2025
@github-project-automation github-project-automation bot moved this to Ready for Confirmation in Issue Confirmation and Triage Board Mar 10, 2025
@engcom-Bravo engcom-Bravo moved this from Ready for Confirmation to Needs Update in Issue Confirmation and Triage Board Mar 10, 2025
@bhennesAdv
Copy link

bhennesAdv commented Mar 11, 2025

@Nolwennig-Jeulin Hello,

I'm pretty sure that this error is due to the fact that you are using a Union type as a return type in your class :

[...]
public function getMinimalChildPriceAMount() : Base|bool  // <==== This is the error
// You might replace it with
public function getMinimalChildPriceAMount()  // <==== No return type
// Or with 
public function getMinimalChildPriceAMount() : ?Base  // <==== You need to return null instead of false
[...]

This error is caused by the interceptor generator not managing correctly Union Type return before the latest magento version.
You did not specify this but I'm assuming you are using Magento 2.4.5 or less as this issue was solved in magento 2.4.6.

You can take a look at this file if you want to apply patch to the core yourself but I'm pretty sure that removing the union typing is a better solution.
https://github.com/magento/magento2/blob/2.4-develop/lib/internal/Magento/Framework/GetReflectionMethodReturnTypeValueTrait.php

Anyway, this is not an issue on the current magento branch.
Kind Regards,
Baptiste

@engcom-Bravo I think the issue can be closed if @Nolwennig-Jeulin confirms the solution.

@Nolwennig-Jeulin
Copy link
Author

@bhennesAdv Hello,

Thank you very much for the answer

Yes I'm on 2.4.5

Your solution sounds like good. I check this out this week and I close afterwards

@bhennesAdv
Copy link

Hello @Nolwennig-Jeulin,

Could you confirm the resolution (and close the issue if so) ?

Kind Regards,
Baptiste

@Nolwennig-Jeulin
Copy link
Author

Hi Baptiste,

It's work like a charm.

Thank again

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Issue: needs update Additional information is require, waiting for response Reported on 2.4.x Indicates original Magento version for the Issue report.
Projects
None yet
Development

No branches or pull requests

3 participants