Magento 2 Documentation  2.3
Documentation for Magento 2 CMS v2.3 (December 2018)
Public Member Functions | Data Fields | Protected Attributes
Information Class Reference

Public Member Functions

 __construct (Renderer $renderer, RegionFactory $regionFactory, CountryFactory $countryFactory)
 
 getStoreInformationObject (Store $store)
 
 getFormattedAddress (Store $store)
 

Data Fields

const XML_PATH_STORE_INFO_NAME = 'general/store_information/name'
 
const XML_PATH_STORE_INFO_PHONE = 'general/store_information/phone'
 
const XML_PATH_STORE_INFO_HOURS = 'general/store_information/hours'
 
const XML_PATH_STORE_INFO_STREET_LINE1 = 'general/store_information/street_line1'
 
const XML_PATH_STORE_INFO_STREET_LINE2 = 'general/store_information/street_line2'
 
const XML_PATH_STORE_INFO_CITY = 'general/store_information/city'
 
const XML_PATH_STORE_INFO_POSTCODE = 'general/store_information/postcode'
 
const XML_PATH_STORE_INFO_REGION_CODE = 'general/store_information/region_id'
 
const XML_PATH_STORE_INFO_COUNTRY_CODE = 'general/store_information/country_id'
 
const XML_PATH_STORE_INFO_VAT_NUMBER = 'general/store_information/merchant_vat_number'
 

Protected Attributes

 $renderer
 
 $countryFactory
 
 $regionFactory
 

Detailed Description

Store information class used to retrieve and format store information as set in store config

@api

Since
100.0.2

Definition at line 20 of file Information.php.

Constructor & Destructor Documentation

◆ __construct()

__construct ( Renderer  $renderer,
RegionFactory  $regionFactory,
CountryFactory  $countryFactory 
)
Parameters
Renderer$renderer
RegionFactory$regionFactory
CountryFactory$countryFactory

Definition at line 64 of file Information.php.

68  {
69  $this->renderer = $renderer;
70  $this->regionFactory = $regionFactory;
71  $this->countryFactory = $countryFactory;
72  }

Member Function Documentation

◆ getFormattedAddress()

getFormattedAddress ( Store  $store)

Retrieve formatted store address from config

Parameters
Store$store
Returns
string

Definition at line 112 of file Information.php.

113  {
114  return $this->renderer->format($this->getStoreInformationObject($store));
115  }
getStoreInformationObject(Store $store)
Definition: Information.php:80

◆ getStoreInformationObject()

getStoreInformationObject ( Store  $store)

Retrieve generic object with all the misc store information values

Parameters
Store$store
Returns
DataObject

Definition at line 80 of file Information.php.

81  {
82  $info = new DataObject([
83  'name' => $store->getConfig(self::XML_PATH_STORE_INFO_NAME),
84  'phone' => $store->getConfig(self::XML_PATH_STORE_INFO_PHONE),
85  'hours' => $store->getConfig(self::XML_PATH_STORE_INFO_HOURS),
86  'street_line1' => $store->getConfig(self::XML_PATH_STORE_INFO_STREET_LINE1),
87  'street_line2' => $store->getConfig(self::XML_PATH_STORE_INFO_STREET_LINE2),
88  'city' => $store->getConfig(self::XML_PATH_STORE_INFO_CITY),
89  'postcode' => $store->getConfig(self::XML_PATH_STORE_INFO_POSTCODE),
90  'region_id' => $store->getConfig(self::XML_PATH_STORE_INFO_REGION_CODE),
91  'country_id' => $store->getConfig(self::XML_PATH_STORE_INFO_COUNTRY_CODE),
92  'vat_number' => $store->getConfig(self::XML_PATH_STORE_INFO_VAT_NUMBER),
93  ]);
94 
95  if ($info->getRegionId()) {
96  $info->setRegion($this->regionFactory->create()->load($info->getRegionId())->getName());
97  }
98 
99  if ($info->getCountryId()) {
100  $info->setCountry($this->countryFactory->create()->loadByCode($info->getCountryId())->getName());
101  }
102 
103  return $info;
104  }
foreach( $_productCollection as $_product)() ?>" class $info
Definition: listing.phtml:52

Field Documentation

◆ $countryFactory

$countryFactory
protected

Definition at line 52 of file Information.php.

◆ $regionFactory

$regionFactory
protected

Definition at line 57 of file Information.php.

◆ $renderer

$renderer
protected

#- #-

Definition at line 47 of file Information.php.

◆ XML_PATH_STORE_INFO_CITY

const XML_PATH_STORE_INFO_CITY = 'general/store_information/city'

Definition at line 35 of file Information.php.

◆ XML_PATH_STORE_INFO_COUNTRY_CODE

const XML_PATH_STORE_INFO_COUNTRY_CODE = 'general/store_information/country_id'

Definition at line 41 of file Information.php.

◆ XML_PATH_STORE_INFO_HOURS

const XML_PATH_STORE_INFO_HOURS = 'general/store_information/hours'

Definition at line 29 of file Information.php.

◆ XML_PATH_STORE_INFO_NAME

const XML_PATH_STORE_INFO_NAME = 'general/store_information/name'

#+ Configuration paths

Definition at line 25 of file Information.php.

◆ XML_PATH_STORE_INFO_PHONE

const XML_PATH_STORE_INFO_PHONE = 'general/store_information/phone'

Definition at line 27 of file Information.php.

◆ XML_PATH_STORE_INFO_POSTCODE

const XML_PATH_STORE_INFO_POSTCODE = 'general/store_information/postcode'

Definition at line 37 of file Information.php.

◆ XML_PATH_STORE_INFO_REGION_CODE

const XML_PATH_STORE_INFO_REGION_CODE = 'general/store_information/region_id'

Definition at line 39 of file Information.php.

◆ XML_PATH_STORE_INFO_STREET_LINE1

const XML_PATH_STORE_INFO_STREET_LINE1 = 'general/store_information/street_line1'

Definition at line 31 of file Information.php.

◆ XML_PATH_STORE_INFO_STREET_LINE2

const XML_PATH_STORE_INFO_STREET_LINE2 = 'general/store_information/street_line2'

Definition at line 33 of file Information.php.

◆ XML_PATH_STORE_INFO_VAT_NUMBER

const XML_PATH_STORE_INFO_VAT_NUMBER = 'general/store_information/merchant_vat_number'

Definition at line 43 of file Information.php.


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