Questions tagged «magento2»

有关Magento 2的一般问题,不专门针对次要版本。使用此标签可以区分Magento1。如果您对特定版本有疑问,请改用相应的“ Magento-2.x”标签。Magento 2次要版本之间的功能可能有所不同。



4
Magento 2-如何将自定义CSS文件添加到头部?
在Magento 1.x中,我可以使用如下代码的帮助器将CSS文件添加到头部。 <reference name="head"> <action method="addCss"><stylesheet helper="module/helperclass/helperfunction"/></action> </reference> 有人知道如何在Magento 2中执行此操作吗?
8 magento2  layout  xml 

1
Magento 2自定义XML模式验证
这是Magento 2 xml验证的后续步骤: 我了解如何xsi:noNamespaceSchemaLocation在IDE中进行映射,因此可以实时验证xml。 但是,如果我必须使用自己的验证架构来创建自己的配置文件,该怎么办? 我应该为什么值xsi:noNamespaceSchemaLocation呢? 现在我在class.xml: <?xml version="1.0"?> <classes xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="class.xsd"> .... </classes> 效果很好,因为class.xsd与my处于同一文件夹中class.xml。 但是我计划使我的模块可扩展,并实际上由多个模块组成。 现在,我在附加模块中使用了class.xsd文件的相对路径,这似乎有点错误。 <?xml version="1.0"?> <classes xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="../../../Base/etc/umc/class.xsd"> .... </classes> 显然我不能使用,urn:magento:framework...因为我的模块不在框架中,我也不能使用,urn:magento:module...因为我的模块不是核心模块。或者我可以使用后者? 还是应该使用自定义urn? 并且(最后一个)如果我使用自定义urn,命令会自动将其拾取,bin/magento dev:urn-catalog:generate还是应该做一些特别的事情?

2
如何使用块类型=“ core / template”在Magento2中包含phtml文件?
我已经完成以下工作: Magento 2 EE Admin > Content > Pages > Add New 页面称为Hello World 内容是: {{block type="core/template" template="/Modules/About.phtml"}} 我去创造了。 App/design/frontend/Magento/Blank/Modules/About.phtml 当我访问localhost / m2 / hello时 该页面加载了预期的内容,但没有加载about.phtml,其中包含纯文本调用 <p>Hello this file is correct</p>


2
Magento 2-保持产品图像长宽比
我正在使用Magento 2类别页面。 但是我不知道如何保持产品图像的宽高比。 在magento 1.x中,我可以获取图像src以使用以下代码。 <?php echo $this->helper('catalog/image') ->init($_product, 'small_image') ->constrainOnly(FALSE) ->keepAspectRatio(TRUE) ->keepFrame(FALSE) ->resize(300); ?> 但是在magento 2中,我可以在/app/design/frontend/Magento/luma/etc/view.xml文件中设置图像大小。 <image id="category_page_grid" type="small_image"> <width>240</width> <height>300</height> </image> <image id="category_page_list" type="small_image"> <width>240</width> <height>300</height> </image> 我试图用“自动”输入高度,但是没有用。 我也尝试只输入宽度,但是它也没有用。 而且我在Magento_Catalog / templates / product / list.phtml文件中找到了以下用于显示产品图片的代码。 <?php $productImage = $block->getImage($_product, $image); ?> <a href="<?php echo $_product->getProductUrl() ?>" class="product …
8 magento2 

2
如何创建带有填充源的表单ui组件选择框
我正在尝试找出如何在magento组件ui表单中创建一个选择框,并将其指向可以在其中填充选择列表的位置。 我以为这样的事情会起作用,但它不会 <field name="formats"> <argument name="data" xsi:type="array"> <item name="config" xsi:type="array"> <item name="dataType" xsi:type="string">text</item> <item name="disabled" xsi:type="boolean">false</item> <item name="label" xsi:type="string" translate="true">formats</item> <item name="formElement" xsi:type="string">select</item> <item name="enabled" xsi:type="boolean">false</item> <item name="source" xsi:type="string">Magento\Catalog\Model\Product\AttributeSet\Options</item> <item name="dataScope" xsi:type="string">formats</item> </item> </argument> </field> 谢谢
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.