Magento

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

2
使用AbstractBackendController测试配置页面:testAclNoAccess失败
我正在为配置部分编写集成测试,并且在默认测试用例中遇到以下失败: My\Module\ConfigTest::testAclNoAccess Failed asserting that 302 is identical to 403 据我所知,一切正常,但是当配置部分拒绝访问时,Magento发送重定向响应而不是“ Forbidden”。 更改测试以获取302状态代码是否有意义?我宁愿不删除该测试用例,因为它已经帮助我捕获了错误的资源标识符。 这是相关代码: namespace My\Module; use Magento\TestFramework\TestCase\AbstractBackendController; class ConfigTest extends AbstractBackendController { protected function setUp() { parent::setUp(); $this->uri = 'backend/admin/system_config/edit'; $this->resource = 'My_Module::config_my_module'; $this->getRequest()->setParam('section', 'my_module'); } // [other tests] }

3
使用“ ifconfig”有条件地添加CSS资产
ifconfig与Magento 1类似,Magento 2中有什么方法可以有条件地添加CSS资产?这是Magento的一个示例: <action ifconfig="config_path/group/field" method="addItem"> <type>skin_css</type><name>css/styles.css</name> </action> 我在Magento 2中尝试了类似的方法,但是没有用: <head> <css src="css/styles.css" ifconfig="config_path/group/field" /> </head> 它只是ifconfig在前端显示属性: <link rel="stylesheet" type="text/css" ifconfig="config_path/group/field" href="http://example.com/pub/static/frontend/Magento/luma/en_US/css/styles.css" /> Magento 2中有等效的功能吗?


13
Magento 2:500内部服务器错误
我遵循以下的Magento开发文档: 如果您添加一个新的.html模板,然后对其进行编辑,则更改将不适用,直到您执行以下操作:删除pub / static / frontend和var / view_preprocessing目录中的所有文件,然后重新加载页面。您可以手动删除文件,也可以在CLI中运行grunt clean:命令。有关在Magento中使用Grunt的详细信息,请参阅安装和配置Grunt。 但是现在在通过htaccess设置的开发人员模式下,我在站点和管理URL上收到内部服务器错误500。如果它寻找已清除的文件来呈现,这是否是一个缓存问题?
10 magento2  php  error 

3
加入购物车后如何触发小型购物车更新
我使用以下课程来测试以自定义方式添加到购物车; use Magento\Framework\App\Action; use Magento\Checkout\Model\Cart; class Add extends Action\Action { protected $cart; public function __construct( Action\Context $context, Cart $cart ){ $this->cart = $cart; parent::__construct($context); } public function execute() { $this->cart->addProductsByIds([1]) ->save(); } } 这很好。当您查看购物车时,它显示了我的物品,在数据库等中所有物品看起来都很酷。但是,微型购物车仍然显示好像在篮子里没有物品。 如果我随后使用产品或列表页面上的“添加到购物车”按钮将其他产品添加到购物车,则它将添加到购物车并更新微型购物车以显示两个商品。 它会在哪里触发迷你车进行自我更新,或者迷你车如何知道需要刷新?
10 magento2 

2
Magento2:将自定义模板添加到下面的产品详细信息页面中的添加到购物车部分
我正在尝试将自定义模板添加到社交共享部分下的产品页面。在我的模块中,我遵循布局文件default.xml中的代码 <body> <referenceContainer name="product.info.social"> <block class="Magento\Framework\View\Element\Template" name="product.info.custom" template="Lapisbard_Product::social.phtml" after="product.info.addtocart"> </block> </referenceContainer> </body> social.phtml内容 <p>Hey there !</p> <?php //$_product = $block->getProduct(); 它工作正常,并在产品页面上显示模板内容。当我使用块类Magento\Catalog\Block\Product\View而不是Magento\Framework\View\Element\Template使用时$block->getProduct();,可以使用来在模板中获取产品对象。 1.我在这里犯什么错误? 2.修改产品页面的最佳方法是什么? 3.是否有一个参考布局文件,可以用来向产品页面的任何部分添加新模板,以在模块中编写布局代码?


3
Magento 2 html文件和phtml文件在自定义模板过程中?
正如我从magento 2文档中检查的有关更改微型购物车内容的内容一样。 有两种方法: 在此页面中:http : //devdocs.magento.com/guides/v2.0/frontend-dev-guide/themes/theme-inherit.html 我们通过自定义minicart.phml并将其放置在以下位置来对其进行更改: app/design/frontend/OrangeCo/orange/Magento_Checkout/templates/cart/minicart.phtml 但在另一页上:http : //devdocs.magento.com/guides/v2.0/frontend-dev-guide/templates/template-sample.html 我们在content.html中对其进行自定义,并将其放置在: app/design/frontend/OrangeCo/orange/Magento_Checkout/web/template/minicart/content.html 因此,这些问题是: magento 2如何决定何时使用html文件和phtml文件? 这与Magento 2:默认,开发人员和生产中的3种模式有关吗?
10 magento2  layout 

2
Magento 2:在与我们联系时显示验证码
我在CMS块中使用以下代码来显示默认的magento与我们联系表格。 <p>{{block class="Magento\Contact\Block\ContactForm" name="contactForm" template="Magento_Contact::form.phtml"}}</p> 只是想知道是否会有一种核心方式来启用表单中的验证码?


2
缓存在magento中如何工作?
我想更清楚地了解Magento缓存算法。 我介绍了 https://www.nicksays.co.uk/developers-guide-magento-cache/ http://www.demacmedia.com/magento-commerce/magento-tutorials/understanding-full-page-cache/ 不过,当我查看var / cache文件夹时,可以看到mage--0to mage--9和mage--afrom mage--f。 他们都是什么? 他们在做什么? 他们怎么办? 有人可以解释这个概念吗?

2
如何在magento 2稳定版中创建主题?
如何在magento 2稳定版中创建主题? 有适用于Beta的教程,但不稳定。 我采取的步骤如下: 在app / design / frontend / Themevendorname / Themename /中创建的文件夹,该文件夹创建了theme.xml和composer.json 但是当我去stores->configuration->General->Design那个设计主题下拉菜单中的管理员时........没有显示新主题。 这是composer.json的行 { "name": "themevendorname/theme-frontend-themename", "description": "N/A", "require": { "php": "~5.4.11|~5.5.0", "magento/framework": "0.1.0-alpha107", "magento/magento-composer-installer": "*" }, "type": "magento2-theme", "version": "0.1.0-alpha107", "extra": { "map": [ [ "*", "frontend/themevendorname/themename" ] ] } } 请检查附件中的图像。另一件事是,我还在vendor-> magento文件夹中创建了一个名为theme-frontend-themename的文件夹,并将相同的文件夹也放在此处,但仍未在管理存储->配置->常规->该设计主题中获得该主题。落下。 任何帮助请。
10 magento2  theme 


2
从保存事件观察器获取产品-Magento 2
在发生产品保存事件之后,我尝试在magento 2中访问该产品。 我在以下位置配置了侦听器: controller_action_catalog_product_save_entity_after xml如下所示: <config xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="urn:magento:framework:Event/etc/events.xsd"> <event name="controller_action_catalog_product_save_entity_after"> <observer name="wire_products_update" instance="TBS\WireProductsHook\Observer\WireProductsUpdate" /> </event> </config> 保存产品后,将调用观察者类,但是我找不到有关如何访问保存的产品的任何信息。观察者类如下: <?php /** * Copyright © 2015 Magento. All rights reserved. * See COPYING.txt for license details. */ namespace TBS\WireProductsHook\Observer; use Magento\Framework\Event\ObserverInterface; class WireProductsUpdate implements ObserverInterface { public function execute( \Magento\Framework\Event\Observer $observer ) { …
10 magento2 

4
Magento 2不允许使用符号链接链接模块
我已经使用符号链接将本地开发模块(单独的git repo)添加到了Magento 2,在我点击PHTML模板之前,它一直运行良好。经过大量调试后,我发现Magento 2文件系统类(Magento\Framework\Filesystem\Directory\Read)使用一种isExists()结合了getAbsolutePath()调用的方法来查看PHTML模板是否存在。但是,该getAbsolutePath()方法检查Magento 2文件系统中是否存在相对路径,如果不存在,则将Magento 2根目录作为前缀。它。就我而言,该模块位于/git/AMagento所在的单独的存储库中/site/B,此行为将检查中是否存在PHTML模板/site/B/git/A。 简而言之:无论系统配置设置“允许符号链接”处于打开状态,都不会拾取Magento 2根文件系统外部的PHTML模板。似乎该设置有效,但前提是该符号链接的源仍在Magento 2文件系统中。 还有其他人遇到过吗?在外部git repo中处理开发的最佳方法是什么?
10 module  magento2 

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.