Magento

Magento电子商务平台用户的问答

6
Magento 2-覆盖CSS而不在任何地方使用!important
我目前正在为客户在Magento 2网站上工作。假设我的客户的品牌是boofar,而我尝试扩展/覆盖foobar的主题是使用设置为父主题frontend/Foobarthemes/boofar/theme.xml <theme xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="urn:magento:framework:Config/etc/theme.xsd"> <title>Boofar</title> <parent>Foobarthemes/foobar1</parent> <media> <preview_image>media/preview.jpg</preview_image> </media> 然后在下面frontend/Foobarthemes/boofar/web/css/source/_theme.less编写了要覆盖的CSS代码。我也尝试过使用_extend.less。 .magicmenu { .home { display: none !important; } .nav-desktop .level0 .level-top > span { font-size: 12px; font-weight: normal; text-transformation: none; } } 我被迫在!important这里工作。字体和文本都不能在上述代码中使用。 我是否不正确理解Magento 2前端工作流程?

2
Magento 2.1.2 Ui-组件窗体从多个下拉菜单中选择元素
我有两个下拉菜单,其中一个是“ 小时”,另一个是“ 分钟”。我设法显示了几个小时的下拉菜单 但是任何人都可以提供帮助-如何以Ui组件形式在数小时之内显示下拉菜单,而不是数小时?就像图片中的那个一样。 <field name="start_date"> <argument name="data" xsi:type="array"> <item name="options" xsi:type="object">NameSpace\ModuleName\Model\Xyz\Source\Hours</item> <item name="config" xsi:type="array"> <item name="label" xsi:type="string" translate="true">Monday Opening Time</item> <item name="visible" xsi:type="boolean">true</item> <item name="dataType" xsi:type="string">number</item> <item name="formElement" xsi:type="string">select</item> <item name="source" xsi:type="string">item</item> <item name="dataScope" xsi:type="string">start_date</item> <item name="sortOrder" xsi:type="number">220</item> <item name="validation" xsi:type="array"> <item name="required-entry" xsi:type="boolean">true</item> </item> </item> </argument> </field> 我的模型返回小时值 …

2
覆盖标题内容和添加块
我已经扩展了LUMA主题,并且想要自定义标题。 我想在徽标之前添加静态块,并将徽标移动到左侧的页面中心。 最终结果将是 [1]静态块[2]徽标(在中间)[3]搜索表格(此位置已经正确)。 请建议如何实现这一目标。

2
Magento 2:addFieldToFilter检查NULL不起作用
我正在尝试从包含parent_item_id NULL值的数据库中获取记录。 $order_ = $this->_objectManager->create('Vendor\Module\Model\Saleslist') ->getCollection() ->addFieldToFilter( 'order_id', $orderId )->addFieldToFilter( 'parent_item_id', ['eq' => NULL] ); 并且还想添加parent_item_id相等的NULL或 ''字符串检查。

1
如何在di.xml中动态启用/禁用<preference>?
&lt;preference/&gt;我的di.xml文件之一当前具有以下内容: &lt;preference for="Magento\Contact\Controller\Index\Post" type="RadTest\TestModule\Controller\Contact\Post" /&gt; 我在管理面板中为模块启用/禁用了配置选项。我只希望&lt;preference&gt;在我的自定义配置选项设置为启用时启用。 如何&lt;preference/&gt;根据设置的模块配置动态启用和禁用覆盖?



1
Magento 2:记录慢速查询
回到M1,您可以通过修改以下变量来记录慢速查询lib/Varien/Db/Adapter/Pdo/Mysql.php: /** * Write SQL debug data to file * * @var bool */ protected $_debug = false; /** * Minimum query duration time to be logged * * @var unknown_type */ protected $_logQueryTime = 0.05; /** * Log all queries (ignored minimum query duration time) * * @var bool …

1
Magento 2:如何使用ui组件在自定义模块中添加产品网格?
我已经使用此链接在Magento 2管理表单中添加了产品网格: 产品网格。但是现在我正在使用ui组件创建管理表单,但无法使用ui组件更改产品网格。请帮我。 查看/adminhtml/layout/productlabel_productlabel_edit.xml &lt;?xml version="1.0"?&gt; &lt;page xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="urn:magento:framework:View/Layout/etc/page_configuration.xsd"&gt; &lt;body&gt; &lt;referenceContainer name="content"&gt; &lt;uiComponent name="productlabel_form"/&gt; &lt;/referenceContainer&gt; &lt;/body&gt; &lt;/page&gt; 查看/adminhtml/ui_component/productlabel_form.xml &lt;fieldset name="assign_products"&gt; &lt;argument name="data" xsi:type="array"&gt; &lt;item name="config" xsi:type="array"&gt; &lt;item name="label" xsi:type="string" translate="true"&gt;Products in Category&lt;/item&gt; &lt;item name="collapsible" xsi:type="boolean"&gt;true&lt;/item&gt; &lt;item name="sortOrder" xsi:type="number"&gt;40&lt;/item&gt; &lt;/item&gt; &lt;/argument&gt; &lt;container name="assign_products_container" &gt; &lt;argument name="data" xsi:type="array"&gt; &lt;item name="config" xsi:type="array"&gt; &lt;item …

4
删除Magento 2中的所有缓存后出错
在删除所有缓存为 rm -rf var/cache/* var/page_cache/* var/view_preprocessed/* var/generation/* 我低于错误 Warning: ltrim() expects parameter 1 to be string, object given in vendor\magento\framework\Code\Generator\EntityAbstract.php on line 152 Notice: Uninitialized string offset: 0 in vendor\magento\framework\Autoload\ClassLoaderWrapper.php on line 81 Notice: Uninitialized string offset: 0 in vendor\composer\ClassLoader.php on line 317 Notice: Uninitialized string offset: 0 in vendor\composer\ClassLoader.php …

1
如何在管理面板中获取当前的网站ID?
我使用与多个网站相关的自定义扩展程序。我遇到一个问题,通过获取网站ID定义在管理面板中执行的脚本代码。我预期结果website_id为0(store_website表中的默认ID )。但是当我在下面使用此函数时,它总是返回1。 /** @var \Magento\Store\Model\StoreManagerInterface */ $this-&gt;_storeManager-&gt;getStore()-&gt;getWebsiteId(); //return 1, expect 0 $this-&gt;_storeManager-&gt;getWebsite()-&gt;getId(); //return 1 我的问题:以任何方式website_id在管理面板中获取最新信息或定义在adminhtml区域中运行的功能? 注意: 此功能需要在前端和后端均起作用。 任何帮助,将不胜感激。

1
如何使用ui-components将表单字段设为只读?
我的Magento 2模块中具有表单字段的ui组件定义。 &lt;field name="name"&gt; &lt;argument name="data" xsi:type="array"&gt; &lt;item name="config" xsi:type="array"&gt; &lt;item name="dataType" xsi:type="string"&gt;text&lt;/item&gt; &lt;item name="label" xsi:type="string" translate="true"&gt;Some Label&lt;/item&gt; &lt;item name="formElement" xsi:type="string"&gt;input&lt;/item&gt; &lt;item name="source" xsi:type="string"&gt;something_here&lt;/item&gt; &lt;item name="sortOrder" xsi:type="number"&gt;10&lt;/item&gt; &lt;item name="dataScope" xsi:type="string"&gt;name&lt;/item&gt; &lt;item name="notice" xsi:type="string" translate="true"&gt;Enter something here&lt;/item&gt; &lt;item name="validation" xsi:type="array"&gt; &lt;item name="required-entry" xsi:type="boolean"&gt;true&lt;/item&gt; &lt;/item&gt; &lt;/item&gt; &lt;/argument&gt; &lt;/field&gt; 并且我正在尝试将其设置为只读。未禁用。只是只读的。 我尝试添加: &lt;item name="readonly" …

3
CLI中的MAGE_DIRS引导程序参数
在中pub/index.php,以下代码用于为媒体和静态资产设置更改URL以省略“ / pub”: $params[Bootstrap::INIT_PARAM_FILESYSTEM_DIR_PATHS] = [ DirectoryList::PUB =&gt; [DirectoryList::URL_PATH =&gt; ''], DirectoryList::MEDIA =&gt; [DirectoryList::URL_PATH =&gt; 'media'], DirectoryList::STATIC_VIEW =&gt; [DirectoryList::URL_PATH =&gt; 'static'], DirectoryList::UPLOAD =&gt; [DirectoryList::URL_PATH =&gt; 'media/upload'], ]; $bootstrap = \Magento\Framework\App\Bootstrap::create(BP, $params); 不幸的是,在CLI脚本(bin/magento)中没有这样的东西。 我Magento\Setup\Mvc\Bootstrap\InitParamListener用以下代码找到了该类: $initParams = $application-&gt;getServiceManager()-&gt;get(self::BOOTSTRAP_PARAM); $directoryList = $this-&gt;createDirectoryList($initParams); 但是我不知道这个Zend Service Manager在哪里检索数据以及如何影响它。 我的具体问题是,索引器必须生成完整的URL,并且当前这样做的地方就像http://magento.local/pub/media/...我需要的那样http://magento.local/media/... 如何告诉CLI虚拟主机指向的pub“发布”不应该是URL的一部分? 理想情况下,该方法无需依赖其他CLI参数或环境变量即可工作。

1
Magento 2.1.1-通过内容安全策略提高安全性
我的商店可以使用最新版本的Magento(当前为2.1.1)正常运行,并且正在尝试通过Apache 2.4.7(Ubuntu 14.04)上的内容安全策略来提高安全性。我已经从内容页面中删除了所有“ &lt;script&gt;”标记,并创建了单独的files.js。 关于Apache的安全性,我设置了: 标头设置了Content-Security-Policy“ default-src'self'” 但是,它不起作用。Magento本身似乎添加了一些“ &lt;script&gt;”标签。最初的源代码行中的示例: &lt;!doctype html&gt; &lt;html lang =“ pt-BR”&gt; &lt;头&gt; &lt;脚本&gt; var require = { “ baseUrl”:“ http://example.com/pub/static/frontend/Magento/luma/pt_BR ” }; &lt;/脚本&gt; 因此在我看来,为了配置CSP,我必须启用“ unsafe-inline”,这毕竟不是真正的安全。 标头设置了Content-Security-Policy“ default-src'self'script-src'self''unsafe-inline''unsafe-eval'”。 有谁知道如何使用CSP正确设置Magento?谢谢!

3
管理员登录时出错-Magento 2.1
我已经在nginx / PHP-FPM Web服务器上安装了带有PHP 7.0.11的Magento 2.1。当我转到Magento管理员URL并使用我的凭据登录时,收到错误消息- “ 警告:is_dir():open_basedir限制有效。文件(/ etc / pki / tls / certs)不在允许的路径内 ” 这似乎是Magento 2.1的问题,因为我没有在具有相同服务器设置的Magento 2.0安装中遇到此问题。 为了解决此问题,我添加"/etc/pki/tls/certs"了open_basedir设置。 我的问题是: 这个open_basedir错误确实是问题所在,还是由其他原因引起的? "/etc/pki/tls/certs"在我的open_basedir设置中添加安全隐患吗?添加到open_basedir中似乎很奇怪。

By using our site, you acknowledge that you have read and understand our Cookie Policy and Privacy Policy.
Licensed under cc by-sa 3.0 with attribution required.