Skip to content

CollectRates() in getAllItems() is empty

I’m using Magento 2.4.6.

When I try to access $request->getAllItems() it returns an empty array.

Also, I’m trying with Quote and the same result.

public function collectRates(RateRequest $request) // NOSONAR
    {

        if (!$this->getConfigFlag('active')) {
            return false;
        }

        $this->_logger->info('COLLECT RATES 0 '. json_encode($request->toArray()));
        $this->_logger->info('COLLECT RATES 1 '. json_encode($this->_quote->getAllVisibleItems()));
        $this->_logger->info('COLLECT RATES 2 '. json_encode($this->_quote->getAllItems()));
        $this->_logger->info('COLLECT RATES 3 '. json_encode($this->_quote->getData()));
        $this->_logger->info('COLLECT RATES 4 '. json_encode($this->_quote->getCustomer()));

output:

[2023-11-16T13:20:20.882524+00:00] main.INFO: COLLECT RATES 0 {"all_items":[{},{}],....} [] []
[2023-11-16T13:20:20.883382+00:00] main.INFO: COLLECT RATES 1 [] [] []
[2023-11-16T13:20:20.883596+00:00] main.INFO: COLLECT RATES 2 [] [] []
[2023-11-16T13:20:20.883680+00:00] main.INFO: COLLECT RATES 3 [] [] []
[2023-11-16T13:20:20.884622+00:00] main.INFO: COLLECT RATES 4 {} [] []

What I’m missing?

thanks