Magento 2 Documentation  2.3
Documentation for Magento 2 CMS v2.3 (December 2018)
Public Member Functions | Data Fields | Protected Attributes
Config Class Reference
Inheritance diagram for Config:
DataObject

Public Member Functions

 __construct (\Magento\Framework\App\Config\ScopeConfigInterface $scopeConfig, \Magento\Shipping\Model\CarrierFactory $carrierFactory, array $data=[])
 
 getActiveCarriers ($store=null)
 
 getAllCarriers ($store=null)
 
- Public Member Functions inherited from DataObject
 __construct (array $data=[])
 
 addData (array $arr)
 
 setData ($key, $value=null)
 
 unsetData ($key=null)
 
 getData ($key='', $index=null)
 
 getDataByPath ($path)
 
 getDataByKey ($key)
 
 setDataUsingMethod ($key, $args=[])
 
 getDataUsingMethod ($key, $args=null)
 
 hasData ($key='')
 
 toArray (array $keys=[])
 
 convertToArray (array $keys=[])
 
 toXml (array $keys=[], $rootName='item', $addOpenTag=false, $addCdata=true)
 
 convertToXml (array $arrAttributes=[], $rootName='item', $addOpenTag=false, $addCdata=true)
 
 toJson (array $keys=[])
 
 convertToJson (array $keys=[])
 
 toString ($format='')
 
 __call ($method, $args)
 
 isEmpty ()
 
 serialize ($keys=[], $valueSeparator='=', $fieldSeparator=' ', $quote='"')
 
 debug ($data=null, &$objects=[])
 
 offsetSet ($offset, $value)
 
 offsetExists ($offset)
 
 offsetUnset ($offset)
 
 offsetGet ($offset)
 

Data Fields

const XML_PATH_ORIGIN_COUNTRY_ID = 'shipping/origin/country_id'
 
const XML_PATH_ORIGIN_REGION_ID = 'shipping/origin/region_id'
 
const XML_PATH_ORIGIN_CITY = 'shipping/origin/city'
 
const XML_PATH_ORIGIN_POSTCODE = 'shipping/origin/postcode'
 

Protected Attributes

 $_scopeConfig
 
 $_carrierFactory
 
- Protected Attributes inherited from DataObject
 $_data = []
 

Additional Inherited Members

- Protected Member Functions inherited from DataObject
 _getData ($key)
 
 _underscore ($name)
 
- Static Protected Attributes inherited from DataObject
static $_underscoreCache = []
 

Detailed Description

Class Config @api

Since
100.0.2

Definition at line 16 of file Config.php.

Constructor & Destructor Documentation

◆ __construct()

__construct ( \Magento\Framework\App\Config\ScopeConfigInterface  $scopeConfig,
\Magento\Shipping\Model\CarrierFactory  $carrierFactory,
array  $data = [] 
)

Constructor

Parameters
\Magento\Framework\App\Config\ScopeConfigInterface$scopeConfig
\Magento\Shipping\Model\CarrierFactory$carrierFactory
array$data

Definition at line 48 of file Config.php.

52  {
53  $this->_scopeConfig = $scopeConfig;
54  $this->_carrierFactory = $carrierFactory;
55  parent::__construct($data);
56  }

Member Function Documentation

◆ getActiveCarriers()

getActiveCarriers (   $store = null)

Retrieve active system carriers

Parameters
mixed$store
Returns
AbstractCarrierInterface[]

Definition at line 64 of file Config.php.

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  }
$config
Definition: fraud_order.php:17

◆ getAllCarriers()

getAllCarriers (   $store = null)

Retrieve all system carriers

Parameters
mixed$store
Returns
AbstractCarrierInterface[]

Definition at line 89 of file Config.php.

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  }
$config
Definition: fraud_order.php:17

Field Documentation

◆ $_carrierFactory

$_carrierFactory
protected

Definition at line 39 of file Config.php.

◆ $_scopeConfig

$_scopeConfig
protected

Definition at line 34 of file Config.php.

◆ XML_PATH_ORIGIN_CITY

const XML_PATH_ORIGIN_CITY = 'shipping/origin/city'

Definition at line 25 of file Config.php.

◆ XML_PATH_ORIGIN_COUNTRY_ID

const XML_PATH_ORIGIN_COUNTRY_ID = 'shipping/origin/country_id'

Shipping origin settings

Definition at line 21 of file Config.php.

◆ XML_PATH_ORIGIN_POSTCODE

const XML_PATH_ORIGIN_POSTCODE = 'shipping/origin/postcode'

Definition at line 27 of file Config.php.

◆ XML_PATH_ORIGIN_REGION_ID

const XML_PATH_ORIGIN_REGION_ID = 'shipping/origin/region_id'

Definition at line 23 of file Config.php.


The documentation for this class was generated from the following file: