0

I have following problem. I am overriding \Magento\GroupedProduct\Block\Product\View\Type\Grouped with this way:

First i override it in the di.xml

 <preference for="Custom\Class\Block\Grouped\Kachel" type="Magento\GroupedProduct\Block\Product\View\Type\Grouped" />

Everything works fine like this:

<?php

namespace Custom\Class\Block\Grouped;


class Kachel extends \Magento\GroupedProduct\Block\Product\View\Type\Grouped {

  public function someCustomFunc(){

  }

}

But i get alot of errors if i try to inject some dependecys:

namespace Custom\Class\Block\Grouped;

protected $_storeManager;
public function __construct(
   \Magento\Store\Model\StoreManagerInterface $storeManager
){
   $this->_storeManager=$storeManager;
}

class Kachel extends \Magento\GroupedProduct\Block\Product\View\Type\Grouped {

  public function someCustomFunc(){

  }

}

How can i for example add this storemanager to my class here?

Is it also possible to extend this class with some other custom class?

3
  • You need to call the parent construct and add you custom dependencies
    – Shankar
    May 11, 2020 at 12:34
  • @Shankar is it possible to inject other custom classes?
    – Ilijanovic
    May 11, 2020 at 12:45
  • Yes its possible
    – Shankar
    May 12, 2020 at 5:13

0

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Browse other questions tagged or ask your own question.