siteation / magento2-storeinfo
轻松获取您的店铺信息
3.0.0
2024-03-16 10:51 UTC
Requires
- magento/framework: >=103.0
- magento/module-directory: >=100.4
- magento/module-store: >=101.1
README
Magento2 StoreInfo模块简化了将必要店铺信息集成到您的Magento 2网站的过程。传统上,此类信息将通过CMS静态块或硬编码到模板中添加。
然而,StoreInfo模块通过直接访问和检索店铺信息中的值,提供了一种更有效的方法。
主要功能
- 简化店铺信息集成
- 扩展默认的Magento 2店铺信息
- 增强店面展示的额外字段
- 额外的店铺电话号码
- WhatsApp号码
- 商会字段
使用StoreInfo模块,开发者可以轻松增强他们的Magento 2店面,添加全面和可定制的店铺信息。
安装
通过以下方式安装包;
composer require siteation/magento2-storeinfo bin/magento module:enable Siteation_StoreInfo
注意
本模块需要Magento 2.4或更高版本!更多信息请参阅composer.json
。
如何使用
StoreInfo通过提供店铺信息和店铺电子邮件地址,并在您的店面中显示它们,直接使用。
此外,Siteation Storeinfo在Stores > 配置 > Siteation > StoreInfo
下还添加了更多有用的字段。
社交
营业时间
公告
在您的模板块中获取StoreInfo。
首先在模板中获取viewModal,使用以下示例;
Hyva - 样本Phtml文件头部
<?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 - 样本Phtml文件头部
对于Luma模板, 请参阅前面的示例以获取加载viewModal所需的xml。
<?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');
之后,您可以在您的phtml中将任何Magento StoreInfo字段作为文本加载;
<?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'