我的观察者中有2人正在观察同一sales_order_shipment_save_before事件.ModuleA是我创造的那个,然后我创造了ModuleB
现在只有ModuleB观察者被召唤而不是ModuleA.
请让我知道如何解决这个问题,并且两位观察员都会被召集.
ModuleA
<?xml version="1.0"?>
<config>
<global>
<models>
<shipmentsave>
<class>My_Shipmentsave_Model</class>
</shipmentsave>
</models>
</global>
<adminhtml>
<events>
<sales_order_shipment_save_before>
<observers>
<shipmentsave>
<type>singleton</type>
<class>shipmentsave/observer</class>
<method>salesOrderShipmentSaveBefore</method>
</shipmentsave>
</observers>
</sales_order_shipment_save_before>
</events>
</adminhtml>
</config>
Run Code Online (Sandbox Code Playgroud)
Observer.php
<?php
class My_Shipmentsave_Model_Observer
{
public function salesOrderShipmentSaveBefore(Varien_Event_Observer $observer)
{
$shipment = $observer->getEvent()->getShipment();
return;
}
}
Run Code Online (Sandbox Code Playgroud)
ModuleB
<?xml version="1.0" encoding="UTF-8"?>
<config>
<modules>
<My_Bshipment>
<version>0.1.0</version>
</My_Bshipment>
</modules>
<admin>
<routers>
<bshipment>
<use>admin</use>
<args>
<module>My_Bshipment</module>
<frontName>bshipment</frontName>
</args>
</bshipment>
</routers>
</admin>
<adminhtml>
<events>
<sales_order_shipment_save_before>
<observers>
<shipmentsave>
<type>singleton</type> …Run Code Online (Sandbox Code Playgroud) 我试过调用[POST] /carts/mine/items,带有正确承载的标题和正文:
{
"cart_item": 1,
"sku": "MY_SKU",
"qty": 1
}
Run Code Online (Sandbox Code Playgroud)
我收到了以下回复:
{
"message": "Invalid value of \"%value\" provided for the %fieldName field.",
"parameters": {
"fieldName": "qty",
"value": null
}
}
Run Code Online (Sandbox Code Playgroud)
有两件事,我不明白要放在cart_item中的内容(但这是必需的)而且我不知道为什么它一直告诉我qty为null?
我正在从Magento 1.x迁移到Magento 2
我创建了default.xml文件来自定义现有布局.
我的情况是我有一个名为"main-header"的div,我想要一个名为"menu"的嵌套div.
现在,我知道块可以有模板.所以我尝试创建一个嵌套的块结构(不知道它是否在Magento 2中有效):
<referenceContainer name="header.container">
<container name="common-header" label="Header common to all pages" as="common-header" htmlTag="div" htmlClass="main-header">
<block class="Mymodule\Test\Block\Header" template="header/top_header.phtml">
<block name="header.menu" class="Mymodule\Test\Block\Menu" template="header/menu.phtml"/>
</block>
</container>
</referenceContainer>
Run Code Online (Sandbox Code Playgroud)
在top_header.phtml中,我正在尝试调用:
<?php $block->getChildHtml('header.menu'); ?>
Run Code Online (Sandbox Code Playgroud)
我知道我从Magento 1.x那里得到的上述陈述
我正在尝试使用自定义产品列表在自定义页面上显示分层导航块.
现在我有自定义控制器,xml布局和产品列表模板.
<referenceContainer name="sidebar.main">
<!-- ??? -->
</referenceContainer>
主要是,这个问题是针对Magento 2的git特有的.我有一个有效的Magento 2项目,我使用github repo安装了一个扩展 - https://github.com/Adyen/adyen-magento2.
在我目前的情况下,我必须调试该扩展,并且必须检查我的远程服务器.我已经分配了那个repo,并为例如cc_debug.patch文件创建了一个补丁.现在,我已将该补丁添加到本地服务器上的根目录.然后,如果我使用git apply --apply --directory=vendor/adyen/module-payment/ cc_debug.patch它执行补丁,那就做技巧并修改供应商目录下的文件.我将更改推送到repo,并且由于部署脚本,该文件已移至远程服务器.
现在,我只通过远程服务器进行读取访问,并且没有初始化.git.如果我确实在远程服务器上应用补丁,它肯定会被执行但是如果我下次推送,由于部署脚本供应商将被重新生成并且补丁应用的更改将丢失.据我所知,这里有一些勾引图片,但我对钩子缺乏了解.
我假设我必须在我的git local repo中创建post-deploy hook,如下所示:
#!/bin/sh
patchfile = "cc_debug.patch"
patchingdirectory = "vendor/adyen/module-payment/"
if [ -f "$patchfile" ]
then
git apply --apply --directory=$patchingdirectory $patchfile
fi
Run Code Online (Sandbox Code Playgroud)
现在,我无法将该钩子推送到远程仓库(甚至没有初始化),因此这个解决方案对我不起作用.或者我知道更新后是特定于远程的东西(如果我错了就纠正我)所以我猜测由于这个钩子会在远程服务器上执行更改但是如果我再次在另一台本地机器上克隆,我必须再次创建post-deploy补丁,这不是理想的情况.
每次部署脚本执行时,应用补丁的原因是什么?[注意:部署脚本不在我手中,因为它是由Magento通过github提供的webhooks执行的.所以,我假设必须有一些webhook使用我必须应用补丁,这又是我缺乏知识.]我相信有人和我的情况相同.请指导我.TIA.
我想更改第三方模块的HTML布局,该模块在产品描述页面的数量输入字段上显示INC / DEC按钮。
为此,我必须重写我所做的并且工作正常的第三方模块的JS。
问题是,在第一个具有空缓存的请求上,它的依赖项未加载并出现以下错误:
TypeError: $.widget is not a function (\app\code\MyCompany\General\view\frontend\web\js\qtycontrol.js)
TypeError: $(...).qtycontrol is not a function (where it has been called)
Run Code Online (Sandbox Code Playgroud)
刷新页面一次,使其工作正常。
请在下面找到我创建要覆盖的模块的代码以及原始第3方模块的代码的详细信息。
替代模块(\ app \ code \ MyCompany \ General \ view \ frontend \ web \ js \ qtycontrol.js):
;define([
'jquery',
'jquery/ui'],
(function ($, window, document, undefined) {
$.widget("infortis.qtycontrol", {
, _create: function()
{
this._initPlugin();
}
, _initPlugin: function()
{
//Exetnded code to display inc/dec buttons on the quantity input field but with changes in …Run Code Online (Sandbox Code Playgroud) 当我们将产品属性添加为媒体图像类型时,我遇到了问题.我通过后端成功创建了属性.
但它没有显示在后端的"添加产品"页面中.我也在"添加属性"区域中选择了相应的属性.
我正在进口一些客户:
$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) 更新至最新的Magento 2.2.5
索引:catalogsearch_fulltext永远不会完成.
目录尺寸: -
Store View: 10
Category: 33K
Products: 300K
Run Code Online (Sandbox Code Playgroud)
以下索引需要花费大量时间(2 + hr)才能完成:
catalog_product_category
catalog_product_attribute
Run Code Online (Sandbox Code Playgroud)
并且索引永远不会完成
catalogsearch_fulltext
Run Code Online (Sandbox Code Playgroud)
使用Mirasvit的弹性搜索.
Totak Mysql数据库大小= ~30 + GB
仍然没有索引的结果