我想覆盖现有Magento/*模块的控制器行为。我想创建自己的Magento/Customer/Controller/Account/LoginPost.php实现。
我想从 Magento 外部创建一个自定义登录页面。为此,我需要获取 form_key。
如何从 Magento 外部使用 javascript 和/或 PHP 获取当前的 form_key?
笔记:
我愿意在Magento中添加一个PHP文件来生成for_key(但我不知道该写什么以及放在哪里)。
我是 Magento 的新手。
我正在运行 Magento 2.0。
我想出了这个解决方案。但请给我找一个更好的!
<!doctype html>
<html>
<head>
<meta charset="utf-8">
<title>Get the form key</title>
<script>
window.onload=function(){
/* Get form_key from Magento */
var ajax = new XMLHttpRequest();
ajax.open("POST", "/", false);
ajax.send();
document.getElementById('hidden_div').innerHTML = ajax.responseText;
var the_form_key = document.getElementsByName("form_key")[0].value;
alert(the_form_key);
};
</script>
</head>
<body>
<div id="hidden_div" style="display:none"></div>
</body>
</html>
Run Code Online (Sandbox Code Playgroud) 我使用该文件在我的自定义主题中添加了一些 js 文件 \app\design\frontend\<vendor>\<theme>\Magento_Theme\layout\default_head_blocks.xml
<link src="js/modernizr.custom.28468.js"/>
<link src="js/jquery.js"/>
<link src="js/bootstrap.min.js"/>
<link src="js/wow.js"/>
<link src="js/jquery.bxslider.js"/>
<link src="js/jquery_select.js"/>
<link src="js/page.js"/>
Run Code Online (Sandbox Code Playgroud)
但它在控制台中显示一些错误,并且功能无法正常工作
任何帮助将不胜感激。
我从下面的代码中得到了属性值 232
$_product->getData('farben');
Run Code Online (Sandbox Code Playgroud)
我如何从这个值中得到它的标签?
在rest api中,我使用“/rest/V1/guest-carts/e3e1fd447e0e315dd761942cf949ce5d/items”方法来获取magento购物车项目。它运作良好,结果是
[
{
"item_id": 100,
"sku": "abc-1",
"qty": 1,
"name": "Product one",
"price": 19,
"product_type": "simple",
"quote_id": "e3e1fd447e0e315dd761942cf949ce5d"
},
{
"item_id": 101,
"sku": "abc-2",
"qty": 1,
"name": "Product two",
"price": 54,
"product_type": "simple",
"quote_id": "e3e1fd447e0e315dd761942cf949ce5d"
}
]
Run Code Online (Sandbox Code Playgroud)
现在我想获取列表中每个产品的图像(可能是缩略图)。有什么办法可以达到这个结果吗?
在 magento 2.1.3 根文件夹中运行 grunt clean 后出现错误
If you have installed the plugin already, please setting the static mapping.
See https://github.com/shootaroo/jit-grunt#static-mappings
Warning: Task "clean" failed. Use --force to continue.
Aborted due to warnings.
Run Code Online (Sandbox Code Playgroud)
我试过npm install clean&npm install clean --save-dev但得到同样的错误。
我查看了静态映射的 url,但在 Magento 环境中不清楚我应该在哪里添加什么?
我该如何解决这个错误?
我在Magento 2 HTML中找到了以下代码:
<div id="cart-totals" class="cart-totals" data-bind="scope:'block-totals'">
Magento 2在前端使用Knockout,但我在Knockout docs中找不到关键字"scope"在这个上下文中的含义.它是Magento 2的功能吗?
我创建了一个名为 name 的模块MyCompany\MyModule。在这个模块中,我想创建大约 3 或 4 个 db 表,例如:greeting_message、greeting_post、greeting_comment。然后,我在Setup下面创建了文件夹MyCompany\MyModule并添加了一个文件InstallSchema.php
这是代码:
<?php
/**
* Copyright © 2016 Magento. All rights reserved.
* See COPYING.txt for license details.
*/
namespace MyCompany\MyModle\Setup;
use Magento\Framework\Setup\InstallSchemaInterface;
use Magento\Framework\Setup\ModuleContextInterface;
use Magento\Framework\Setup\SchemaSetupInterface;
/**
* @codeCoverageIgnore
*/
class InstallSchema implements InstallSchemaInterface
{
/**
* {@inheritdoc}
* @SuppressWarnings(PHPMD.ExcessiveMethodLength)
*/
public function install(SchemaSetupInterface $setup, ModuleContextInterface $context)
{
/**
* Create table 'greeting_message'
*/
$table = $setup->getConnection()
->newTable($setup->getTable('greeting_message'))
->addColumn(
'greeting_id',
\Magento\Framework\DB\Ddl\Table::TYPE_INTEGER,
null,
['identity' => …Run Code Online (Sandbox Code Playgroud) 我正在为 Magento 2 构建一个主题。主页需要遍历所有类别并输出类别名称、url 和上传到 .phtml 文件中管理员内类别的图像。
这是可能的,我怎样才能做到这一点?
提前致谢 :)
magento2 ×10
magento ×3
javascript ×2
attributes ×1
database ×1
gruntjs ×1
knockout.js ×1
magento-2.0 ×1
magento2.1 ×1
mvvm ×1
mysql ×1
product ×1
r ×1
scope ×1
themes ×1