1

I have 2 custom modules installed, when opening a front end of a module1, i get error related to module2, this is the error

Argument 4 passed to VendorName\Module2\Block\Magento\Framework\Pricing\Render::__construct() must be of the type array, null given, called in /var/www/html/magento2.3.1/vendor/magento/framework/ObjectManager/Factory/AbstractFactory.php on line 117 [] []

In front end i got this error

Missing required argument $data of VendorName\Module2\Block\Magento\Framework\Pricing\Render.

As you see the module2 overrides Magento\Framework\Pricing\Render.php class

On VendorName/Module2/Block/Magento/Framework/Pricing/Render.php

namespace VendorName\Module2\Block\Magento\Framework\Pricing;

use Magento\Framework\Pricing\Amount\AmountInterface;
use Magento\Framework\Pricing\Price\PriceInterface;
use Magento\Framework\Pricing\SaleableInterface;
use Magento\Framework\Pricing\Render\Layout;
use Magento\Framework\View\Element\Template;
use VendorName\Module2\Helper\Data;

/**
 * Class Render
 * @package VendorName\Module2\Block\Magento\Framework\Pricing
*/
class Render extends \Magento\Framework\Pricing\Render
{

 * @var \VendorName\Module2\Helper\Data
 */
private $dataHelper;

/**
 * Render constructor.
 * @param \VendorName\Module2\Helper\Data $dataHelper
 * @param Template\Context $context
 * @param Layout $priceLayout
 * @param array $data
 */

public function __construct(Data $dataHelper, Template\Context $context, Layout $priceLayout, array $data)
{
    $this->dataHelper = $dataHelper;
    parent::__construct($context, $priceLayout, $data);
}

}

I searched for the call to render class on Module 1 i found it here in venorName1/Module1/Helper/Catalog.php

namespace VendorName1\Module1\Helper;

use Magento\Framework\Stdlib\DateTime\DateTime;

class Catalog extends \Magento\Framework\App\Helper\AbstractHelper
{
private $date;
private $helper;
private $renderer;
private $block;
private $linkFactory;
private $optionBlock;
private $priceFormat;
private $imageHelper;
private $coreRegistry;
private $blockFactory;
private $productLinks;
private $priceCurrency;
private $pricingHelper;
private $objectManager;
private $catalogHelper;
private $storeInterface;
private $productFactory;
private $downloadHelper;
private $configurableBlock;
private $catalogProductHelper;
private $eachProduct = [];

public function __construct(
    DateTime $date,
    \Webkul\Pos\Helper\Data $helper,
    \Magento\Framework\Registry $coreRegistry,
    \Magento\Catalog\Helper\Image $imageHelper,
    \Magento\Catalog\Helper\Data $catalogHelper,
    \Magento\Framework\Pricing\Render $renderer,
    \Magento\Framework\App\Helper\Context $context,
    \Magento\Framework\View\Element\Template $block,
    \Magento\Framework\Filesystem\DirectoryList $dir,
    \Webkul\Pos\Block\Configurable $configurableBlock,
    \Magento\Downloadable\Helper\File $downloadHelper,
    \Magento\Framework\Pricing\Helper\Data $priceFormat,
    \Magento\Catalog\Model\ProductFactory $productFactory,
    \Magento\Framework\Pricing\Helper\Data $pricingHelper,
    \Magento\Catalog\Helper\Product $catalogProductHelper,
    \Magento\Downloadable\Model\LinkFactory $linkFactory,
    \Magento\Catalog\Block\Product\View\Options $optionBlock,
    \Magento\Framework\ObjectManagerInterface $objectManager,
    \Magento\Framework\View\Element\BlockFactory $blockFactory,
    \Magento\Store\Model\StoreManagerInterface $storeInterface,
    \Magento\Downloadable\Block\Catalog\Product\Links $productLinks,
    \Magento\Framework\Pricing\PriceCurrencyInterface $priceCurrency
) {
    $this->date           = $date;
    $this->helper         = $helper;
    $this->renderer       = $renderer;
    $this->block          = $block;
    $this->_baseDir       = $dir->getPath("media");
    $this->optionBlock    = $optionBlock;
    $this->priceFormat    = $priceFormat;
    $this->blockFactory   = $blockFactory;
    $this->coreRegistry   = $coreRegistry;
    $this->imageHelper    = $imageHelper;
    $this->priceCurrency  = $priceCurrency;
    $this->pricingHelper  = $pricingHelper;
    $this->objectManager  = $objectManager;
    $this->catalogHelper  = $catalogHelper;
    $this->productLinks   = $productLinks;
    $this->linkFactory    = $linkFactory;
    $this->downloadHelper = $downloadHelper;
    $this->productFactory = $productFactory;
    $this->storeInterface = $storeInterface;
    $this->configurableBlock = $configurableBlock;
    $this->catalogProductHelper = $catalogProductHelper;
    parent::__construct($context);
}
}

How can i fix this error or debug it?

  • In your module 1, are you trying to call your customer Render class or the default Magento framework one? – mlunt May 10 '19 at 15:52
  • @mlunt it's the Magento Framework \Magento\Framework\Pricing\Render $renderer, on constructor $this->renderer = $renderer; I tried to call the Module 2 Render class but always same error – tarek fellah May 12 '19 at 14:45
  • It may be looking for your new instance from module 1 because of the dependency inheritance. I’d put an echo statement in your module 1 class to confirm. – mlunt May 12 '19 at 16:32
  • Put an cho on venorName1/Module1/Helper/Catalog.php or the page front end controller where i have the error? – tarek fellah May 12 '19 at 19:01
  • In the module itself – mlunt May 12 '19 at 19:03
1

Try deleting the generated directory -

rm -rf generated/
| improve this answer | |
  • I got the same error – tarek fellah May 12 '19 at 14:53

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.