Rajat Tripathi
Rajat Tripathi

Reputation: 17

How to call magento module in custom page?

I have added this:

echo $this->getLayout()->createBlock('core/template')->setTemplate('sales/order/history.phtml')->toHtml();

to mypage.phtml, but it is giving

Fatal error: Call to a member function getSize() on a non-object in C:\xampp\htdocs\puckerimages_cvs\app\design\frontend\default\pucker\template\sales\order\history.phtml on line 41

Can anybody tell me how to call core module controller in custom pages

Upvotes: 0

Views: 1567

Answers (2)

Shivam
Shivam

Reputation: 2443

try this

instead of "core/template" use "sales/order_history"

<?php echo $this->getLayout()->createBlock('sales/order_history')->setTemplate('sales/order/history.phtml')->toHtml();?>

hope this help you

Upvotes: 0

Elavarasan
Elavarasan

Reputation: 2669

I dont know exactly what you were tried to do..Controller is nothing but your url segment. If you want get controller from Url use the following code,

Mage::app()->getRequest()->getControllerName();

Mage::app()->getRequest()->getActionName();

Mage::app()->getRequest()->getRouteName();

Mage::app()->getRequest()->getModuleName();

If you want get collection of data from your Module use the following code,

 Mage::getModel('groupname/classname');

or

Mage::getSingleton('groupname/classname');

Example

$collection = Mage::getModel('module/model_name')->getCollection()
    ->addAttributeToSort('order', 'ASC')
    ->addAttributeToSort('last_name', 'ASC')
    ->addAttributeToSort('first_name', 'ASC')
;

Upvotes: 2

Related Questions