Skip to content

Magento 2 Plugin around Shipping collectRates infinyte loader

When I added __construct whatever I get an infinite loader.

public function __construct(ResultFactory $res){
$this->anotherVariable = $res;
}
my

<?php

namespace VendorModulePlugin;

use MagentoFrameworkAppConfigScopeConfigInterface;

class MyShippingPlugin
{
    private $anotherVariable;

    public function __construct(ScopeConfigInterface $res){
        $this->anotherVariable = $res;
    }

    public function aroundCollectRates(
        MagentoShippingModelShipping $subject,
        Closure $proceed,
        MagentoQuoteModelQuoteAddressRateRequest $request
    ) {
        return $proceed($request);
    }
}

my di.xml

<?xml version="1.0"?>
<config xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="urn:magento:framework:ObjectManager/etc/config.xsd">
    <type name="MagentoShippingModelShipping">
        <plugin name="vendor_module_shipping_plugin"
                type="VendorModulePluginMyShippingPlugin"
                sortOrder="10"
    </type>
</config>

If I remove the constructor everything works, if not then an infinite loader