1

We have upgraded magento to 2.4.3-p1 and added new bundle product. On frontend when we access bundle product it show error Call to undefined method Magento\Catalog\Model\ResourceModel\Product\Flat::getLinkField()

<script type="text/x-magento-init">
    {
        "*": {
                "Magento_Catalog/js/product/view/provider": {
                    "data": Error: Call to undefined method Magento\Catalog\Model\ResourceModel\Product\Flat::getLinkField() in /chroot/home/3343sfdsadf/domain.com/html/vendor/magento/module-eav/Model/Entity/Collection/AbstractCollection.php:1066

it seems like magento added some new files and plugin for bundle product in magento 2.4.3-p1. Any help is appreciated!

1

Vendor\Module\etc\di.xml

<preference for="Magento\Bundle\Model\Product\SingleChoiceProvider" type="Vendor\Module\Model\Product\SingleChoiceProvider" />

Vendor\Module\Model\Product\SingleChoiceProvider.php

<?php
/**
 * Copyright © Magento, Inc. All rights reserved.
 * See COPYING.txt for license details.
 */
declare(strict_types=1);

namespace Vendor\Module\Model\Product;
use Magento\Catalog\Model\Product;
use Magento\Catalog\Model\Product\Type as BundleType;

class SingleChoiceProvider extends \Magento\Bundle\Model\Product\SingleChoiceProvider
{

    public function isSingleChoiceAvailable(Product $product) : bool
    {
        $result = false;
        if ($product->getTypeId() === BundleType::TYPE_BUNDLE) {
            $typeInstance = $product->getTypeInstance();
            $typeInstance->setStoreFilter($product->getStoreId(), $product);

            if ($typeInstance->hasRequiredOptions($product)) {
                $options = $typeInstance->getOptions($product);
                $isNoCustomizations = true;
                foreach ($options as $option) {
                    $optionId = $option->getId();
                    $required = $option->getRequired();
                    if ($isNoCustomizations && (int) $required === 1) {
                        $selectionsCollection = $typeInstance->getSelectionsCollection(
                            [$optionId],
                            $product
                        );
                        $selections = []; //$selectionsCollection->exportToArray();
                        if (count($selections) > 1) {
                            foreach ($selections as $selection) {
                                if ($isNoCustomizations) {
                                    $isNoCustomizations = (int)$selection['is_default'] === 1
                                        && (int)$selection['selection_can_change_qty'] === 0;
                                } else {
                                    break;
                                }
                            }
                        }
                    } else {
                        $isNoCustomizations = false;
                        break;
                    }
                }

                $result = $isNoCustomizations;
            }
        }
        return $result;
    }
}
1
  • Akashmalik did that fix it? We're experiencing similar issues after all bundle products since migrating from 1.9.3 to 2.4.3 Nov 15 at 16:50

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.