0

Is it possible to do partial dependency injection? For example, I have a class with a method called findAttrValueByLabel, and I want to be able to inject a Magento\Catalog\Model\Product\Attribute\Repository, but also pass two other parameters myself (namely $attr_code and $label). If it is possible, how do I do it? In fact, in general how do I call a method on a class with dependency injection? I know how to do it with the constructor only, because I just need to create it with object manager.

  • Maybe you could use the $data parameter in that case: magento.stackexchange.com/q/118033/2380 – Raphael at Digital Pianism Jun 2 '16 at 17:06
  • Will that work when the values of $attr_code and $label are different every time the function is called? Also, in general how do i call a non constructor method which has dependency injected arguments? (ie what is the syntax) – b_pcakes Jun 2 '16 at 17:12

Your Answer

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

Browse other questions tagged or ask your own question.