siteation/magento2-module-storeinfo

This package is abandoned and no longer maintained. The author suggests using the siteation/magento2-storeinfo package instead.

Get your store information with ease

Installs: 18 513

Dependents: 0

Suggesters: 0

Security: 0

Stars: 13

Watchers: 2

Forks: 4

Open Issues: 0

Language:HTML

Type:magento2-module

1.2.1 2022-12-15 19:46 UTC

This package is auto-updated.

Last update: 2022-12-17 17:49:19 UTC


README

Warning This package has moved to https://github.com/Siteation/magento2-storeinfo

This Magento 2 module adds the option to get the store information with ease.

So you can get the store phone number from the Stores > Config. Instead using static block or hard code it in your template directly.

Installation

Install the package via;

composer require siteation/magento2-storeinfo
bin/magento module:enable Siteation_StoreInfo

Note This Module requires Magento 2.3 or higher! For more requirements see the composer.json.

How to use

By defaut this module loads nothing.

Use one of the samples to get started.

Adding a address block

We have made an address block that uses the store information. And also comes with schema tags to enrich the Contact data.

To load the default store address block use 1 of the following xml samples in your template.

Hyva - XML Sample
<referenceBlock name="footer-content">
    <block
        name="footer.store.info"
        as="footer-store-info"
        template="Siteation_StoreInfo::hyva/store-address.phtml"
    />
</referenceBlock>
Luma - XML Sample
<referenceContainer name="footer">
    <block name="footer.store.info"
        as="footer-store-info"
        template="Siteation_StoreInfo::luma/store-address.phtml">
        <arguments>
            <argument name="viewModelStoreInfo" 
                xsi:type="object">Siteation\StoreInfo\ViewModel\StoreInfo</argument>
        </arguments>
    </block>
</referenceContainer>

Get Store info in your own block.

First get the viewModal in your template.

Hyva - Sample Phtml file head
<?php
declare(strict_types=1);

use Hyva\Theme\Model\ViewModelRegistry;
use Magento\Framework\View\Element\Template;
use Magento\Framework\Escaper;
use Siteation\StoreInfo\ViewModel\StoreInfo;

/** @var ViewModelRegistry $viewModels */
/** @var Template $block */
/** @var Escaper $escaper */

/** @var StoreInfo $storeInfo */
$storeInfo = $viewModels->require(StoreInfo::class);
Luma - Sample Phtml file head

For Luma templates, see the previous sample for the xml needed to load the viewModal.

<?php
declare(strict_types=1);

use Magento\Framework\View\Element\Template;
use Magento\Framework\Escaper;

/** @var Template $block */
/** @var Escaper $escaper */

/** @var Siteation\StoreInfo\ViewModel\StoreInfo $storeInfo */
$storeInfo = $block->getData('viewModelStoreInfo');

After this you can load any Magento StoreInfo field as text in your phtml;

<?php
// Get specific predefined store info field
$storeInfo->getPostcode();
$storeInfo->getSalesEmail();

// Get the same as above, using the global functions
$storeInfo->getStoreInfo('postcode'); // 'general/store_information/%s'
$storeInfo->getStoreEmail('email', 'ident_sales'); // 'trans_email/%2$s/%1$s'