Magento 2 Documentation  2.3
Documentation for Magento 2 CMS v2.3 (December 2018)
Config.php
Go to the documentation of this file.
1 <?php
7 namespace Magento\Shipping\Model;
8 
10 
17 {
21  const XML_PATH_ORIGIN_COUNTRY_ID = 'shipping/origin/country_id';
22 
23  const XML_PATH_ORIGIN_REGION_ID = 'shipping/origin/region_id';
24 
25  const XML_PATH_ORIGIN_CITY = 'shipping/origin/city';
26 
27  const XML_PATH_ORIGIN_POSTCODE = 'shipping/origin/postcode';
28 
34  protected $_scopeConfig;
35 
39  protected $_carrierFactory;
40 
48  public function __construct(
49  \Magento\Framework\App\Config\ScopeConfigInterface $scopeConfig,
50  \Magento\Shipping\Model\CarrierFactory $carrierFactory,
51  array $data = []
52  ) {
53  $this->_scopeConfig = $scopeConfig;
54  $this->_carrierFactory = $carrierFactory;
55  parent::__construct($data);
56  }
57 
64  public function getActiveCarriers($store = null)
65  {
66  $carriers = [];
67  $config = $this->_scopeConfig->getValue('carriers', \Magento\Store\Model\ScopeInterface::SCOPE_STORE, $store);
68  foreach (array_keys($config) as $carrierCode) {
69  if ($this->_scopeConfig->isSetFlag(
70  'carriers/' . $carrierCode . '/active',
71  \Magento\Store\Model\ScopeInterface::SCOPE_STORE,
72  $store
73  )) {
74  $carrierModel = $this->_carrierFactory->create($carrierCode, $store);
75  if ($carrierModel) {
76  $carriers[$carrierCode] = $carrierModel;
77  }
78  }
79  }
80  return $carriers;
81  }
82 
89  public function getAllCarriers($store = null)
90  {
91  $carriers = [];
92  $config = $this->_scopeConfig->getValue('carriers', \Magento\Store\Model\ScopeInterface::SCOPE_STORE, $store);
93  foreach (array_keys($config) as $carrierCode) {
94  $model = $this->_carrierFactory->create($carrierCode, $store);
95  if ($model) {
96  $carriers[$carrierCode] = $model;
97  }
98  }
99  return $carriers;
100  }
101 }
getAllCarriers($store=null)
Definition: Config.php:89
$config
Definition: fraud_order.php:17
__construct(\Magento\Framework\App\Config\ScopeConfigInterface $scopeConfig, \Magento\Shipping\Model\CarrierFactory $carrierFactory, array $data=[])
Definition: Config.php:48
getActiveCarriers($store=null)
Definition: Config.php:64