0

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.

1

PageFactory in Magento 2

go through this thread What Triggers the Generation of a Factory in Magento 2 you will understand.

1

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 factory class, any reason? – amit_game Dec 22 '15 at 5:50
  • i have updated my answer plz check again. – Rakesh Jesadiya Dec 22 '15 at 5:58

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.