/** * Retrieve all methods for supplied shipping data * * @param \Magento\Quote\Model\Quote\Address\RateRequest $request * @return $this * @todo make it ordered */ public function collectRates(\Magento\Quote\Model\Quote\Address\RateRequest $request) { $storeId = $request->getStoreId(); if (!$request->getOrig()) { $request->setCountryId($this->_scopeConfig->getValue(Shipment::XML_PATH_STORE_COUNTRY_ID, \Magento\Store\Model\ScopeInterface::SCOPE_STORE, $request->getStore()))->setRegionId($this->_scopeConfig->getValue(Shipment::XML_PATH_STORE_REGION_ID, \Magento\Store\Model\ScopeInterface::SCOPE_STORE, $request->getStore()))->setCity($this->_scopeConfig->getValue(Shipment::XML_PATH_STORE_CITY, \Magento\Store\Model\ScopeInterface::SCOPE_STORE, $request->getStore()))->setPostcode($this->_scopeConfig->getValue(Shipment::XML_PATH_STORE_ZIP, \Magento\Store\Model\ScopeInterface::SCOPE_STORE, $request->getStore())); } $limitCarrier = $request->getLimitCarrier(); if (!$limitCarrier) { $carriers = $this->_scopeConfig->getValue('carriers', \Magento\Store\Model\ScopeInterface::SCOPE_STORE, $storeId); foreach ($carriers as $carrierCode => $carrierConfig) { $this->collectCarrierRates($carrierCode, $request); } } else { if (!is_array($limitCarrier)) { $limitCarrier = [$limitCarrier]; } foreach ($limitCarrier as $carrierCode) { $carrierConfig = $this->_scopeConfig->getValue('carriers/' . $carrierCode, \Magento\Store\Model\ScopeInterface::SCOPE_STORE, $storeId); if (!$carrierConfig) { continue; } $this->collectCarrierRates($carrierCode, $request); } } return $this; }