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.

asked Dec 22, 2015 at 4:55

2 Answers 2

1

PageFactory in Magento 2

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

answered Dec 22, 2015 at 5:23
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

answered Dec 22, 2015 at 5:21
2
  • model class created, but its not generating any model factory class, any reason? Commented Dec 22, 2015 at 5:50
  • i have updated my answer plz check again. Commented Dec 22, 2015 at 5:58

Your Answer

Draft saved
Draft discarded

Sign up or log in

Sign up using Google
Sign up using Email and Password

Post as a guest

Required, but never shown

Post as a guest

Required, but never shown

By clicking "Post Your Answer", you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.