Warning: file_get_contents(/data/phpspider/zhask/data//catemap/5/fortran/2.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Php 启用自定义模块存储,特别是Magento 2不工作_Php_Magento_Magento2_Magento 2.3_Magento2.0.2 - Fatal编程技术网

Php 启用自定义模块存储,特别是Magento 2不工作

Php 启用自定义模块存储,特别是Magento 2不工作,php,magento,magento2,magento-2.3,magento2.0.2,Php,Magento,Magento2,Magento 2.3,Magento2.0.2,我正在尝试仅为单个商店视图启用自定义模块,但该功能仍适用于所有商店视图 我有以下配置: 主网站>(默认商店视图,B2B商店视图) 我只想为B2B商店视图启用我的模块 我尝试使用system.xml完成此操作:代码是: <?xml version="1.0"?> <config xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocatio

我正在尝试仅为单个商店视图启用自定义模块,但该功能仍适用于所有商店视图

我有以下配置: 主网站>(默认商店视图,B2B商店视图) 我只想为B2B商店视图启用我的模块

我尝试使用system.xml完成此操作:代码是:

<?xml version="1.0"?>
<config xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="urn:magento:module:Magento_Config:etc/system_file.xsd">
<system>
   <tab id="customrfq" translate="label" sortOrder="1000">
       <label>Request For Quote</label>
   </tab>
   <section id="customrfq" translate="label" type="text" sortOrder="10" showInDefault="1" showInWebsite="1" showInStore="1">
       <label>RFQ</label>
       <tab>customrfq</tab>
       <resource>CustomB2BRFQ_Module::rfq</resource>
       <group id="department" translate="label" type="text" sortOrder="10" showInDefault="1" showInWebsite="1" showInStore="1">
           <label>RFQ configuration</label>
           <field id="view_list" translate="label comment" type="select" sortOrder="10" showInDefault="1" showInWebsite="1" showInStore="1">
               <label>Show Quotes</label>
               <comment>Show request for quotes</comment>
               <source_model>Magento\Config\Model\Config\Source\Yesno</source_model>
           </field>
       </group>
   </section>
</system>
</config>

询价单
询价
客户询价
CustomB2BRFQ_模块::rfq
RFQ配置
显示报价
显示报价请求
Magento\Config\Model\Config\Source\Yesno
Config.xml:

<?xml version="1.0"?>
<config xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="urn:magento:module:Magento_Store:etc/config.xsd">
<default>
   <customrfq>
       <department>
           <view_list>1</view_list>
       </department>
   </customrfq>
</default>
</config>

1.
布局文件:

<?xml version="1.0"?>
<page xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" layout="1column" xsi:noNamespaceSchemaLocation="urn:magento:framework:View/Layout/etc/page_configuration.xsd">
    <body>
        <referenceContainer name="content">
            <block class="CustomB2BRFQ\Module\Block\RequestForQuoteForm" name="custom_module_form"
                   template="CustomB2BRFQ_Module::rfq.phtml" ifconifg="customrfq/department/view_list" cacheable="false"/>
            <arguments>
               <argument name="path" xsi:type="helper" helper="CustomB2BRFQ\Module\Helper\Data::getPath" translate="true" />
            </arguments>
        </referenceContainer>
    </body>
</page>
 

帮助文件:

<?php
/**
 * Created By : Rashi Goyal
 */
namespace CustomB2BRFQ\Module\Helper;
class Data extends \Magento\Framework\App\Helper\AbstractHelper
{
    const PATH_FIELD = 'customrfq/department/view_list';
    /**
     * @var \Magento\Framework\App\Config\ScopeConfigInterface
     */
    protected $scopeConfig;
    /**
     * @param \Magento\Framework\App\Helper\Context              $context
     * @param \Magento\Framework\App\Config\ScopeConfigInterface $scopeConfig
     */
    public function __construct(
        \Magento\Framework\App\Helper\Context $context,
        \Magento\Framework\App\Config\ScopeConfigInterface $scopeConfig
    ){
        $this->scopeConfig = $scopeConfig;
        parent::__construct($context);
    }

    public function getPath()
    {
        return $this->scopeConfig->getValue(self::PATH_FIELD,\Magento\Store\Model\ScopeInterface::SCOPE_STORE);
    }
}

我认为您为以下属性(system.xml)设置了错误的值:

  • 显示故障
  • showin网站
  • showInStore
根据您的需求,您需要商店提供的功能。因此,必须按如下方式设置这些属性:

  • showInDefault=“0”
  • showInWebsite=“0”
  • showInStore=“1”
使用此选项,您的配置设置仅显示在商店视图上

您还指定了默认值=1(config.xml)

默认情况下,您应使用以下选项:
0