0

We created a module to allow backorder per store view rather than default.

This module works in Magento 2.3.3 but I tried to implement this to a Magneto 2.3.6 installation also. However, I get this error while di:compile.

enter image description here

and here is the code that the error is referring to:

<?php

namespace KraftMedia\Backorder\Plugin\Model\ResourceModel\Attribute;

use Magento\CatalogInventory\Model\ResourceModel\Stock\Status;
use Magento\ConfigurableProduct\Model\ResourceModel\Attribute\OptionSelectBuilderInterface;
use Magento\ConfigurableProduct\Plugin\Model\ResourceModel\Attribute\InStockOptionSelectBuilder as CoreBuilder;
use Magento\Framework\DB\Select;

class InStockOptionSelectBuilder extends CoreBuilder
{
    /**
     * @var \Magento\CatalogInventory\Model\Configuration
     */
    private $configuration;

    public function __construct(
        \Magento\CatalogInventory\Model\Configuration $configuration,
        Status $stockStatusResource
    ) {
        $this->configuration = $configuration;

        parent::__construct($stockStatusResource);
    }

    /**
     * Add stock status filter to select, only if backorders is disabled
     *
     * @param OptionSelectBuilderInterface $subject
     * @param Select $select
     * @return Select
     *
     * @SuppressWarnings(PHPMD.UnusedFormalParameter)
     */
    public function afterGetSelect(OptionSelectBuilderInterface $subject, Select $select)
    {
        if ($this->configuration->getBackorders()) {
            return $select;
        }

        return parent::afterGetSelect($subject, $select);
    }
}
2
  • Would you mind copying and pasting the code instead of using screenshots? That would allow us to test/modify your code more easily.
    – joeybab3
    Jul 12 at 21:50
  • Hi, I've just added the text now. thank you Jul 12 at 22:21

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.