Questions tagged «plugin»

表示有关Magento 2插件的问题(BeforePlugin,AfterPlugin和AroundPlugin)。插件在Magento文档中也称为拦截器。

1
是什么导致以下错误:警告:字符串偏移量'is_in_stock'非法…在第87行的AdvancedInventory.php
在模块开发期间,我一直在编写一个插件,该插件在加载产品选项集合之前会对其进行修改(添加描述字段)。就这个: 等/ di.xml <type name="Magento\Catalog\Model\ResourceModel\Product\Option\Collection"> <plugin name="addOptionDescription" type="Vendor\Module\Plugin\Product\Option\Collection" sortOrder="10" disabled="false"/> </type> 码: <?php namespace Vendor\Module\Plugin\Product\Option; use Vendor\Module\Model\OptionDescription; use Magento\Catalog\Model\ResourceModel\Product\Option\Collection as OptionCollection; class Collection { /** * @var \Vendor\Module\Helper\Data */ protected $helper; public function __construct( \Vendor\Module\Helper\Data $helper ) { $this->helper = $helper; } /** * @param OptionCollection $subject * @param bool …

1
通过插件无法在magento 2中保存自定义付款字段数据,
我正在尝试通过插件保存我的自定义字段数据,但是它不起作用。 插件类 namespace Vendor\Module\Model\Checkout; class PaymentInformationManagementPlugin { protected $paymentMethodManagement; public function __construct( \Magento\Quote\Model\QuoteFactory $quote, \Magento\Quote\Api\PaymentMethodManagementInterface $paymentMethodManagement ) { $this->paymentMethodManagement = $paymentMethodManagement; $this->quoteManagement = $quoteManagement; } public function beforeSavePaymentInformation( \Magento\Checkout\Model\PaymentInformationManagement $subject, $cartId, \Magento\Quote\Api\Data\PaymentInterface $paymentInformation ) { //$paymentInformation->getData('extension_attributes'); $extenstinAttributes = $paymentInformation->getExtensionAttributes(); $taxCode = $extenstinAttributes->getTaxCode(); $paymentInformation->setExtensionAttributes($taxCode); $this->paymentMethodManagement->set($cartId, $paymentInformation); return true; // var_dump($taxCode);exit; // …

2
Magento 2:虚拟类型插件
Magento 2关于插件的文档让我感到困惑: 首先要说的是: 插件不能与虚拟类型一起使用 但后来说: 您可以将类,接口或虚拟类型指定为插件观察到的类型名称 我是否缺少某些内容,或者文档是否相互矛盾?我们可以为虚拟类型创建插件吗?
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.