当我们将产品属性添加为媒体图像类型时,我遇到了问题.我通过后端成功创建了属性.
但它没有显示在后端的"添加产品"页面中.我也在"添加属性"区域中选择了相应的属性.
我怎样才能获得magento2中的当前类别?
我想在自定义phtml文件中获取类别名称和类别ID.
使用Magento2.1.0-rc1分支与样本数据
使用REST API catalogProductRepositoryV1 REF:http://devdocs.magento.com/swagger/index.html 从管理令牌API获取密钥并使用该密钥
POST/V1 /产品
&
PUT/V1/products/{sku}
with参数尝试逐个参数
{
"saveOptions": "true",
"product": {
"name": "Test11_11",
"sku": "TESTOPP_111",
"attributeSetId": "15",
"price": "10",
"weight": "10",
"status": "1",
"visibility": "3",
"customAttributes": [
{
"attributeCode": "manufacturer",
"value": "222"
},
{
"attributeCode": "tax_class_id",
"value": "0"
},
{
"attributeCode": "specialPrice",
"value": "10"
},
{
"attributeCode": "description",
"value": "44332211"
},
{
"attributeCode": "eco_collection",
"value": "1"
}
],
"typeId": "simple"
}
}Run Code Online (Sandbox Code Playgroud)
不支持store_id/storeId字段,但产品中的信息不保存以存储它保存到默认的Store ID
GET/V1/products有参数storeId和PUT&POST一样,但没有使用PUT&POST
我正在进口一些客户:
$objectManager = \Magento\Framework\App\ObjectManager::getInstance();
$customerFactory = $objectManager->create('\Magento\Customer\Model\CustomerFactory');
$customer = $objectManager->create('Magento\Customer\Model\Customer')->setWebsiteId(1)->loadByEmail('customrr@custom.com');
try {
if(!empty($customer->getData('email')))
{
$customer->setAttr1(1); // Attr1 = Name of the custom Attribute
$customer->setAttr2(2); // Attr2 = Name of the custom Attribute
}
else
{
$customer = $customerFactory->create()->setWebsiteId(1);
}
$customer->setLastname("Lastname");
$customer->setFirstname("Firsty");
.....
$customer->save();
Run Code Online (Sandbox Code Playgroud)
客户将正确保存所有标准属性,但无论如何我的新属性都不会保存.我也尝试过:
$customer->setCustomAttribute('Attr1','value');
Run Code Online (Sandbox Code Playgroud)
但这也行不通.
自定义属性在Magentos 2后台显示相关,如果手动创建客户,也会正确保存值.
我想在head标签开始后添加自定义脚本.
喜欢.
<head>
<script>console.log("I'm loaded!");</script>
Run Code Online (Sandbox Code Playgroud)
我试图在default_head_blocks.xml中添加代码
<referenceContainer name="head.additional">
<block class="Custom\Module\Block\Success" template="Custom_Module::success/head.phtml"/>
</referenceContainer>
Run Code Online (Sandbox Code Playgroud)
=>输出:
<script>console.log("I'm loaded!");</script>
</head>
Run Code Online (Sandbox Code Playgroud)
此代码在head标记结束之前使用add script.
请检查以下代码
Block => Custom/Module/Block/Onepage/Success.php
namespace Custom\Module\Block\Onepage;
use Magento\Framework\View\Element\Template;
class Success extends \Magento\Checkout\Block\Onepage\Success {
public function getOrder()
{
$objectManager =\Magento\Framework\App\ObjectManager::getInstance();
$helper = $objectManager->get('Custom\Module\Helper\Data');
$lastOrderId = $this->getOrderId();
if (empty($lastOrderId))
{
return null;
}
$orderData = $objectManager->create('Magento\Sales\Model\Order')->loadByIncrementId($this->getOrderId());
return $orderData;
}
}
Run Code Online (Sandbox Code Playgroud)
Helper => Custom\Module\Helper\Data.php
namespace Custom\Module\Helper;
class Data extends \Magento\Framework\App\Helper\AbstractHelper
{
/**
* @param \Magento\Framework\App\Helper\Context $context
*/
protected $_request;
public function __construct(
\Magento\Framework\App\Helper\Context $context,
\Magento\Framework\App\Request\Http …Run Code Online (Sandbox Code Playgroud) 我已经成功安装了magento2,但是有很多js错误.
当看到控制台登录firebug时,它显示了很多错误,还有其他任何东西可以配置magento css和js.

我无法在magento 2中重建索引.谷歌之后,我得到了解决方案,我们可以使用shell命令重新索引
php dev/shell/indexer.php reindexall
Run Code Online (Sandbox Code Playgroud)
但它给出了错误
Could not open input file: dev/shell/indexer.php
Run Code Online (Sandbox Code Playgroud)
因为我在dev中看不到shell文件夹.
我对Magento 2的分层导航有一个问题,即在应用某些属性过滤器时它没有显示结果.显示结果的唯一过滤器是价格.
我通过赋值"Filterable(with results)"创建了4个其他属性(Lab,format,season等).我创建的这些属性在"分层导航"菜单中正确显示,并且还指示每个属性具有的产品数量.
但是,当我点击其中任何一个时,我都会收到消息,说没有找到带有这些属性的产品.
我试图清理缓存,重新索引并将magento模式更改为生产但没有任何作用
我正在尝试通过 React with Apollo 进行一个非常基本的查询。
当我在 GraphiQL 中执行此查询时,我很好地得到了结果,但在我的应用程序中,我得到了一个未定义的数据对象。并显示错误消息:
网络错误:JSON 输入意外结束
查询是:
query {
category(id: 3) {
id
children {
id
name
}
}
}
Run Code Online (Sandbox Code Playgroud)
这是我的组件
import React, { Component } from 'react';
import { Query } from 'react-apollo';
import gql from 'graphql-tag';
const CATEGORIES_LIST = gql`
query CATEGORIES_LIST {
category(id: 3) {
id
children {
id
name
}
}
}
`;
class Cat extends Component {
render() {
return (
<div>
<p>Items!</p>
<Query query={CATEGORIES_LIST}>
{payload => {
console.log(payload);
return <p>fetch …Run Code Online (Sandbox Code Playgroud) 我已经使用 Magento2.4 安装了弹性搜索(7.x),并且使用 PHP 7.3 当我运行 reindex 命令(bin/magento indexer:reindex)时出现以下错误。
目录搜索索引进程未知错误:{“error”:{“root_cause”:[{“type”:“cluster_block_exception”,“reason”:“索引 [magento2_product_1_v1] 被阻止:[TOO_MANY_REQUESTS/12/磁盘使用量超出洪水阶段”水印,索引具有只读允许删除块];"}],"type":"cluster_block_exception","reason":"索引 [magento2_product_1_v1] 被阻止: [TOO_MANY_REQUESTS/12/磁盘使用量超出洪水阶段水印,索引具有只读允许删除块];"},"status":429}
如果有人解决了这个问题吗?请告诉我。
谢谢。