Magento 2 Documentation  2.3
Documentation for Magento 2 CMS v2.3 (December 2018)
Information.php
Go to the documentation of this file.
1 <?php
7 namespace Magento\Store\Model;
8 
9 use Magento\Directory\Model\CountryFactory;
13 
21 {
25  const XML_PATH_STORE_INFO_NAME = 'general/store_information/name';
26 
27  const XML_PATH_STORE_INFO_PHONE = 'general/store_information/phone';
28 
29  const XML_PATH_STORE_INFO_HOURS = 'general/store_information/hours';
30 
31  const XML_PATH_STORE_INFO_STREET_LINE1 = 'general/store_information/street_line1';
32 
33  const XML_PATH_STORE_INFO_STREET_LINE2 = 'general/store_information/street_line2';
34 
35  const XML_PATH_STORE_INFO_CITY = 'general/store_information/city';
36 
37  const XML_PATH_STORE_INFO_POSTCODE = 'general/store_information/postcode';
38 
39  const XML_PATH_STORE_INFO_REGION_CODE = 'general/store_information/region_id';
40 
41  const XML_PATH_STORE_INFO_COUNTRY_CODE = 'general/store_information/country_id';
42 
43  const XML_PATH_STORE_INFO_VAT_NUMBER = 'general/store_information/merchant_vat_number';
47  protected $renderer;
48 
52  protected $countryFactory;
53 
57  protected $regionFactory;
58 
64  public function __construct(
67  CountryFactory $countryFactory
68  ) {
69  $this->renderer = $renderer;
70  $this->regionFactory = $regionFactory;
71  $this->countryFactory = $countryFactory;
72  }
73 
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  }
105 
113  {
114  return $this->renderer->format($this->getStoreInformationObject($store));
115  }
116 }
__construct(Renderer $renderer, RegionFactory $regionFactory, CountryFactory $countryFactory)
Definition: Information.php:64
getStoreInformationObject(Store $store)
Definition: Information.php:80
foreach( $_productCollection as $_product)() ?>" class $info
Definition: listing.phtml:52