Magento Asked by Black on February 3, 2021
I try to add a new product in a afterSave plugin for MagentoQuoteApiCartItemRepositoryInterface, but I get:
Type Error occurred when creating object:
CompanyQuotePluginRalSpecialColorPriceSurcharge, Argument 3 passed
to CompanyQuotePluginRalSpecialColorPriceSurcharge::__construct()
must be an instance of MagentoCatalogModelProductFactory, instance
of MagentoFrameworkAppConfig given, called
appcodeCompanyQuoteetcdi.xml
<?xml version="1.0"?>
<config xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="urn:magento:framework:ObjectManager/etc/config.xsd">
<type name="MagentoQuoteApiCartItemRepositoryInterface">
<plugin name="company_quote_ral_specialcolor_price_surcharge"
type="CompanyQuotePluginRalSpecialColorPriceSurcharge"
sortOrder="10"/>
</type>
</config>
appcodeCompanyQuotePluginRalSpecialColorPriceSurcharge.php
<?php
namespace CompanyQuotePlugin;
use MagentoCatalogModelProductFactory;
class RalSpecialColorPriceSurcharge
{
/**
* @var CompanyQuoteModelConfigSettings
*/
private $settings;
public function __construct(
MagentoCatalogModelProductFactory $productFactory,
) {
$this->productFactory = $productFactory;
}
...
I figured it out. The problem was, that I executed bin/magento setup:di:compile
earlier, which means that the code is getting compiled into the static files and loaded from there.
So if you call it once, then you always have to call it again after making changes to the constructor.
Answered by Black on February 3, 2021
Get help from others!
Recent Answers
Recent Questions
© 2024 TransWikia.com. All rights reserved. Sites we Love: PCI Database, UKBizDB, Menu Kuliner, Sharing RPP