Giter Club home page Giter Club logo

magento2-module-storeinfo's Introduction

Siteation - Magento 2 module Store Info

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'

magento2-module-storeinfo's People

Contributors

allrude avatar grimlink avatar jissereitsma avatar poespas avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar

magento2-module-storeinfo's Issues

Error on clean M2 install

if Country field in Storeinfo Module country is not chosen, no country selected, trows error on:

getCountry()): ?>

needs to checked/solved in Module and Baldr Theme

Add dependancies to composer

[
  {
    "message": "No composer dependency found for \"magento/module-directory\"",
    "group": "GROUP_MISSING_COMPOSER_DEP",
    "suggestion": "Current version is 100.4.4. Perhaps use ^100.4?"
  },
  {
    "message": "No composer dependency found for \"magento/module-store\"",
    "group": "GROUP_MISSING_COMPOSER_DEP",
    "suggestion": "Current version is 101.1.4. Perhaps use ^101.1?"
  }
]

Feature get region name from region_id

Currently Magento 2 only offers the region_id as a number, from the Store Information,
While the Country ID was readable, e.g. EN.
The region id only returns a number, which makes it really hard to do something with it.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.