1

I am trying to track down some bugs in an extension, but I need answers from the core code (specifically vendor/magento/module-quote/Model/QuoteRepository.php).

I've tried adding "private $_logger;" to the class declarations, along with adding to the constructor:

public function __construct(
    QuoteFactory $quoteFactory,
    StoreManagerInterface $storeManager,
    \Magento\Quote\Model\ResourceModel\Quote\Collection $quoteCollection,
    \Magento\Quote\Api\Data\CartSearchResultsInterfaceFactory $searchResultsDataFactory,
    JoinProcessorInterface $extensionAttributesJoinProcessor, 
    \Psr\Log\LoggerInterface $logger
) {
    $this->quoteFactory = $quoteFactory;
    $this->storeManager = $storeManager;
    $this->searchResultsDataFactory = $searchResultsDataFactory;
    $this->extensionAttributesJoinProcessor = $extensionAttributesJoinProcessor;
    $this->_logger = $logger;
}

Then I try to write to the log like this:

public function get($cartId, array $sharedStoreIds = [])
{
    $this->_logger->log(\Psr\Log\LogLevel::DEBUG, 'Hello I wrote to the log!');

when the page runs I get the error:

Fatal error: Uncaught TypeError: Argument 6 passed to Magento\Quote\Model\QuoteRepository::__construct() must implement interface Psr\Log\LoggerInterface, none given, called in /home/livean9/public_new/var/generation/Magento/Quote/Model/QuoteRepository/Interceptor.php on line 14 and defined in /home/livean9/public_new/vendor/magento/module-quote/Model/QuoteRepository.php:89

What am I doing wrong?

  • Did you recompile your DI? Try running setup:di:compile. – Daniel Mesquita Apr 24 '17 at 20:58
  • Geez, sometimes I'm so stupid! Thanks for the reminder! – Todd Apr 24 '17 at 21:16
  • No problem... I'll add as an answer. – Daniel Mesquita Apr 24 '17 at 21:28
2

Try recompiling your DI by running setup:di:compile. That should do the trick.

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.