I am working on creation of custom module and it is going to be stuck in a problem where i want to add some predefined data to my custom module while installation, so for that i review pre defined modules and found that there is a file installData.php inside Setup of a custom module
I reviewed module-cms all thing is well set and find out a class included inside vendor\magento\module-cms\Setup\insatallData.php
namespace Magento\Cms\Setup; use Magento\Cms\Model\Page; use Magento\Cms\Model\PageFactory; use Magento\Framework\Module\Setup\Migration; use Magento\Framework\Setup\InstallDataInterface; use Magento\Framework\Setup\ModuleContextInterface; use Magento\Framework\Setup\ModuleDataSetupInterface;
use Magento\Cms\Model\PageFactory;
where to find this PageFactory class, because if i am able to find this then in that manner i am able create a Factory class for my own module.
thanks.
2 Answers 2
PageFactory in Magento 2
go through this thread What Triggers the Generation of a Factory in Magento 2 you will understand.
PageFactory is auto generate class in magento2.
Module with model class have factory class. You can check this PageFactroy class inside
var/generation/Magento/Cms/Model/PageFactory.php.
All factory class are autogenerated and its path are found under var/generation/Magento/{{Modulename}}/Model/{{ModelclassFactory.php}}
If your module is custom module not magento core module at that time you have to check Factory class inside var/generation/{{Packagename}}/{{Modulename}}/Model/{{ModelclassFactory.php}}.
ex. your custom module is Company/Test and Test module contain model class,
You have to check TestFactory class inside var/generation/Company/Test/Model/TestFactory.php
-
model class created, but its not generating any
model factoryclass, any reason?Amit Dwivedi– Amit Dwivedi2015年12月22日 05:50:04 +00:00Commented Dec 22, 2015 at 5:50 -
i have updated my answer plz check again.Rakesh Jesadiya– Rakesh Jesadiya2015年12月22日 05:58:24 +00:00Commented Dec 22, 2015 at 5:58