What is the use of pagefactory in Magento 2?
Clash Royale CLAN TAG#URR8PPP
.everyoneloves__top-leaderboard:empty,.everyoneloves__mid-leaderboard:empty margin-bottom:0;
up vote
3
down vote
favorite
Although I refer some blog of pagefactory, I don't understand the use of page factory.
There is one code in the controller. Could you please explain to me how it works?
public function execute()
return $this->_pageFactory->create();
magento2 magento-2.2.5 object-manager factory pagefactory
add a comment |Â
up vote
3
down vote
favorite
Although I refer some blog of pagefactory, I don't understand the use of page factory.
There is one code in the controller. Could you please explain to me how it works?
public function execute()
return $this->_pageFactory->create();
magento2 magento-2.2.5 object-manager factory pagefactory
2
Pagefactory is used to initialize the layout.
â Ansar Husain
Sep 5 at 6:12
add a comment |Â
up vote
3
down vote
favorite
up vote
3
down vote
favorite
Although I refer some blog of pagefactory, I don't understand the use of page factory.
There is one code in the controller. Could you please explain to me how it works?
public function execute()
return $this->_pageFactory->create();
magento2 magento-2.2.5 object-manager factory pagefactory
Although I refer some blog of pagefactory, I don't understand the use of page factory.
There is one code in the controller. Could you please explain to me how it works?
public function execute()
return $this->_pageFactory->create();
magento2 magento-2.2.5 object-manager factory pagefactory
magento2 magento-2.2.5 object-manager factory pagefactory
edited Sep 5 at 6:30
Amrit Pal Singh
699522
699522
asked Sep 5 at 5:57
Bhakti Thakkar
32412
32412
2
Pagefactory is used to initialize the layout.
â Ansar Husain
Sep 5 at 6:12
add a comment |Â
2
Pagefactory is used to initialize the layout.
â Ansar Husain
Sep 5 at 6:12
2
2
Pagefactory is used to initialize the layout.
â Ansar Husain
Sep 5 at 6:12
Pagefactory is used to initialize the layout.
â Ansar Husain
Sep 5 at 6:12
add a comment |Â
4 Answers
4
active
oldest
votes
up vote
5
down vote
accepted
Pagefactory is used to initialize the layout.
Its working in magento2 same like as in magento1 was doing with below code
$this->_view->loadLayout();
$this->_view->renderLayout();
Thank you sir, and could you help me one more time. what is postfactory.
â Bhakti Thakkar
Sep 5 at 7:26
add a comment |Â
up vote
2
down vote
Unlike Magento 1.x in magento 2 introduces factories which are used to set and get data of given object. best practice is, instead of using object manager use factories.
Like that Magento perform all operations systematically without changing the flow of request. so if any module overriding the functionality should have latest data.
add a comment |Â
up vote
2
down vote
Page factory is used to create a page result by initializing the layout. Page factory create the response object in execute()
public function execute()
return $this->pageResultFactory->create();
When you return a page result object from execute method, youâÂÂre telling Magento to kick off the standard layout handle XML file page rendering.
add a comment |Â
up vote
2
down vote
Magento2 uses the Factory Method Design Pattern which states that define and an interface for creating an object, but let subclasses decide which class to instantiate. Factory method design pattern lets a class defer instantiation to subclasses.
Factories are service classes that instantiate non-injectable classes, that is, models that represent a database entity. They create a layer of abstraction between the ObjectManager and business code.
They are an automatically generated class type.
When you reference a factory in a class constructor, MagentoâÂÂs object manager generates the factory class if it does not exist.
You can go through the following articles for more details:
- https://devdocs.magento.com/guides/v2.2/extension-dev-guide/factories.html
- https://alanstorm.com/magento_2_object_manager_instance_objects/
add a comment |Â
4 Answers
4
active
oldest
votes
4 Answers
4
active
oldest
votes
active
oldest
votes
active
oldest
votes
up vote
5
down vote
accepted
Pagefactory is used to initialize the layout.
Its working in magento2 same like as in magento1 was doing with below code
$this->_view->loadLayout();
$this->_view->renderLayout();
Thank you sir, and could you help me one more time. what is postfactory.
â Bhakti Thakkar
Sep 5 at 7:26
add a comment |Â
up vote
5
down vote
accepted
Pagefactory is used to initialize the layout.
Its working in magento2 same like as in magento1 was doing with below code
$this->_view->loadLayout();
$this->_view->renderLayout();
Thank you sir, and could you help me one more time. what is postfactory.
â Bhakti Thakkar
Sep 5 at 7:26
add a comment |Â
up vote
5
down vote
accepted
up vote
5
down vote
accepted
Pagefactory is used to initialize the layout.
Its working in magento2 same like as in magento1 was doing with below code
$this->_view->loadLayout();
$this->_view->renderLayout();
Pagefactory is used to initialize the layout.
Its working in magento2 same like as in magento1 was doing with below code
$this->_view->loadLayout();
$this->_view->renderLayout();
answered Sep 5 at 6:25
Ansar Husain
1,236217
1,236217
Thank you sir, and could you help me one more time. what is postfactory.
â Bhakti Thakkar
Sep 5 at 7:26
add a comment |Â
Thank you sir, and could you help me one more time. what is postfactory.
â Bhakti Thakkar
Sep 5 at 7:26
Thank you sir, and could you help me one more time. what is postfactory.
â Bhakti Thakkar
Sep 5 at 7:26
Thank you sir, and could you help me one more time. what is postfactory.
â Bhakti Thakkar
Sep 5 at 7:26
add a comment |Â
up vote
2
down vote
Unlike Magento 1.x in magento 2 introduces factories which are used to set and get data of given object. best practice is, instead of using object manager use factories.
Like that Magento perform all operations systematically without changing the flow of request. so if any module overriding the functionality should have latest data.
add a comment |Â
up vote
2
down vote
Unlike Magento 1.x in magento 2 introduces factories which are used to set and get data of given object. best practice is, instead of using object manager use factories.
Like that Magento perform all operations systematically without changing the flow of request. so if any module overriding the functionality should have latest data.
add a comment |Â
up vote
2
down vote
up vote
2
down vote
Unlike Magento 1.x in magento 2 introduces factories which are used to set and get data of given object. best practice is, instead of using object manager use factories.
Like that Magento perform all operations systematically without changing the flow of request. so if any module overriding the functionality should have latest data.
Unlike Magento 1.x in magento 2 introduces factories which are used to set and get data of given object. best practice is, instead of using object manager use factories.
Like that Magento perform all operations systematically without changing the flow of request. so if any module overriding the functionality should have latest data.
answered Sep 5 at 6:03
Naveed
1,7331212
1,7331212
add a comment |Â
add a comment |Â
up vote
2
down vote
Page factory is used to create a page result by initializing the layout. Page factory create the response object in execute()
public function execute()
return $this->pageResultFactory->create();
When you return a page result object from execute method, youâÂÂre telling Magento to kick off the standard layout handle XML file page rendering.
add a comment |Â
up vote
2
down vote
Page factory is used to create a page result by initializing the layout. Page factory create the response object in execute()
public function execute()
return $this->pageResultFactory->create();
When you return a page result object from execute method, youâÂÂre telling Magento to kick off the standard layout handle XML file page rendering.
add a comment |Â
up vote
2
down vote
up vote
2
down vote
Page factory is used to create a page result by initializing the layout. Page factory create the response object in execute()
public function execute()
return $this->pageResultFactory->create();
When you return a page result object from execute method, youâÂÂre telling Magento to kick off the standard layout handle XML file page rendering.
Page factory is used to create a page result by initializing the layout. Page factory create the response object in execute()
public function execute()
return $this->pageResultFactory->create();
When you return a page result object from execute method, youâÂÂre telling Magento to kick off the standard layout handle XML file page rendering.
answered Sep 5 at 6:29
Prince Patel
11.5k44067
11.5k44067
add a comment |Â
add a comment |Â
up vote
2
down vote
Magento2 uses the Factory Method Design Pattern which states that define and an interface for creating an object, but let subclasses decide which class to instantiate. Factory method design pattern lets a class defer instantiation to subclasses.
Factories are service classes that instantiate non-injectable classes, that is, models that represent a database entity. They create a layer of abstraction between the ObjectManager and business code.
They are an automatically generated class type.
When you reference a factory in a class constructor, MagentoâÂÂs object manager generates the factory class if it does not exist.
You can go through the following articles for more details:
- https://devdocs.magento.com/guides/v2.2/extension-dev-guide/factories.html
- https://alanstorm.com/magento_2_object_manager_instance_objects/
add a comment |Â
up vote
2
down vote
Magento2 uses the Factory Method Design Pattern which states that define and an interface for creating an object, but let subclasses decide which class to instantiate. Factory method design pattern lets a class defer instantiation to subclasses.
Factories are service classes that instantiate non-injectable classes, that is, models that represent a database entity. They create a layer of abstraction between the ObjectManager and business code.
They are an automatically generated class type.
When you reference a factory in a class constructor, MagentoâÂÂs object manager generates the factory class if it does not exist.
You can go through the following articles for more details:
- https://devdocs.magento.com/guides/v2.2/extension-dev-guide/factories.html
- https://alanstorm.com/magento_2_object_manager_instance_objects/
add a comment |Â
up vote
2
down vote
up vote
2
down vote
Magento2 uses the Factory Method Design Pattern which states that define and an interface for creating an object, but let subclasses decide which class to instantiate. Factory method design pattern lets a class defer instantiation to subclasses.
Factories are service classes that instantiate non-injectable classes, that is, models that represent a database entity. They create a layer of abstraction between the ObjectManager and business code.
They are an automatically generated class type.
When you reference a factory in a class constructor, MagentoâÂÂs object manager generates the factory class if it does not exist.
You can go through the following articles for more details:
- https://devdocs.magento.com/guides/v2.2/extension-dev-guide/factories.html
- https://alanstorm.com/magento_2_object_manager_instance_objects/
Magento2 uses the Factory Method Design Pattern which states that define and an interface for creating an object, but let subclasses decide which class to instantiate. Factory method design pattern lets a class defer instantiation to subclasses.
Factories are service classes that instantiate non-injectable classes, that is, models that represent a database entity. They create a layer of abstraction between the ObjectManager and business code.
They are an automatically generated class type.
When you reference a factory in a class constructor, MagentoâÂÂs object manager generates the factory class if it does not exist.
You can go through the following articles for more details:
- https://devdocs.magento.com/guides/v2.2/extension-dev-guide/factories.html
- https://alanstorm.com/magento_2_object_manager_instance_objects/
answered Sep 5 at 6:37
Anshu Mishra
4,47732351
4,47732351
add a comment |Â
add a comment |Â
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
StackExchange.ready(
function ()
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fmagento.stackexchange.com%2fquestions%2f240856%2fwhat-is-the-use-of-pagefactory-in-magento-2%23new-answer', 'question_page');
);
Post as a guest
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
2
Pagefactory is used to initialize the layout.
â Ansar Husain
Sep 5 at 6:12