Closed artlantis closed 10 years ago
@artlantis Magento2 has a folder inside var
called generation
. Inside this folder Magento generates at runtime some classes that are later used inside the classes you create.
I still haven't wrapped my head 100% on this technique, but it seams to be useful for implementing some design patterns (like proxy for example) and for interception (https://wiki.magento.com/display/MAGE2DOC/Using+Interception). The factory classes are also generated. So Look for the class in var/generation/Sample/News/Model/ArticleFactory.php
. Don't try to modify it because it will be useless. It will be regenerated the next time you delete it or if on developer mode, it will always be regenerated. Try do dig more on https://wiki.magento.com maybe you will find an explanation. I only used an existing module to create this sample module, so it is not my idea.
Hi, I am not sure whether right or not but I saw an "articleFactory" constructor parameter in product helper. \Sample\News\Model\ArticleFactory $articleFactory
But, when I want to check that factory method in the specified folder ( \Sample\News\Model\ ) I can't see any ArticleFactory file. Could you please tell me what is the magic of this technique?