Your shopping cart is empty. Browse our Store

Magento

Open Source eCommerce Evolved

Magento Forum

   
Creating a Module with custom Database Table Tutorial
 
alkarim
Sr. Member
 
Total Posts:  245
Joined:  2008-04-10
 

aye aye sir, I found it..

public function editAction()
    
{
        $newsId     
$this->getRequest()->getParam('id');
        
$newsModel  Mage::getModel('news/list')->load($newsId);

        
{...}

var $newsId is empty, then when it loads at Mage::getModel its found nothing… then occurs error

grin , anyway thanks, I just want to make a module without create new database table, just want to get from anothers table

hm, still in progress working on this…

 
Magento Community Magento Community
Magento Community
Magento Community
 
alkarim
Sr. Member
 
Total Posts:  245
Joined:  2008-04-10
 

nice it works when I added <module> table in case… thanks

one more question :
How should I do to change the controller into index.php or homepage, eg :

when I created abc module then I can go to http://local/index.php/abc, but How can I make it, so I can go to http://local/index.php or http://local

thanks

 
Magento Community Magento Community
Magento Community
Magento Community
 
alistek
Sr. Member
 
Total Posts:  293
Joined:  2008-04-02
Normal, IL
 

The easiest way I would do is to create a static block and include your custom module template in there and then set the home page to use that.  The other way might be through Routers but I wouldn’t know how to do that.

-Adam

 
Magento Community Magento Community
Magento Community
Magento Community
 
alkarim
Sr. Member
 
Total Posts:  245
Joined:  2008-04-10
 

hi @alistek,

I got the problem here, it might would happened to you too.. when I go to my NEW MODULE then to to another menu, something strange happened…

you see, when I am at TIME module, and when I want to go to another menu , THE URL is still TIME/ bla, bla bla

any idea ?

thanks

Image Attachments
Screenshot.png
 
Magento Community Magento Community
Magento Community
Magento Community
 
alistek
Sr. Member
 
Total Posts:  293
Joined:  2008-04-02
Normal, IL
 

Hi Alkarim,

That is actually a Magento bug that I hadn’t noticed till now.  If you look in the config.xml file:

/app/code/core/Mage/Sales/etc/config.xml

<menu>
             <
sales translate="title" module="sales">
                <
title>Sales</title>
                <
sort_order>20</sort_order>
                <
depends><module>Mage_Sales</module></depends>
                <
children>
                    <
order translate="title" module="sales">
                        <
title>Orders</title>
                        <
action>adminhtml/sales_order</action>
                        <
sort_order>10</sort_order>
                    </
order>
                    <
invoice translate="title" module="sales">
                        <
title>Invoices</title>
                        <
action>*/sales_invoice</action>
                        <
sort_order>20</sort_order>
                    </
invoice>
                    <
shipment translate="title" module="sales">
                        <
title>Shipments</title>
                        <
action>*/sales_shipment</action>
                        <
sort_order>30</sort_order>
                    </
shipment>
                    <
creditmemo translate="title" module="sales">
                        <
title>Credit Memos</title>
                        <
action>*/sales_creditmemo</action>
                        <
sort_order>40</sort_order>
                    </
creditmemo>
                </
children>
             </
sales>
        </
menu>

You can see that the actions for invoices, shipments, and credit memo’s are ‘*/<action>’.  The problem with this is that it will append the url action to whatever the current module is.  Since we don’t have our module in adminhtml in the core code it does not correctly give the url.  If you change the * to adminhtml, it works just fine.

<menu>
             <
sales translate="title" module="sales">
                <
title>Sales</title>
                <
sort_order>20</sort_order>
                <
depends><module>Mage_Sales</module></depends>
                <
children>
                    <
order translate="title" module="sales">
                        <
title>Orders</title>
                        <
action>adminhtml/sales_order</action>
                        <
sort_order>10</sort_order>
                    </
order>
                    <
invoice translate="title" module="sales">
                        <
title>Invoices</title>
                        <
action>adminhtml/sales_invoice</action>
                        <
sort_order>20</sort_order>
                    </
invoice>
                    <
shipment translate="title" module="sales">
                        <
title>Shipments</title>
                        <
action>adminhtml/sales_shipment</action>
                        <
sort_order>30</sort_order>
                    </
shipment>
                    <
creditmemo translate="title" module="sales">
                        <
title>Credit Memos</title>
                        <
action>adminhtml/sales_creditmemo</action>
                        <
sort_order>40</sort_order>
                    </
creditmemo>
                </
children>
             </
sales>
        </
menu>

-Adam

 
Magento Community Magento Community
Magento Community
Magento Community
 
alkarim
Sr. Member
 
Total Posts:  245
Joined:  2008-04-10
 

hi @alistek, I think it would be better if I change <module> name with admin at local..

thanks

 
Magento Community Magento Community
Magento Community
Magento Community
 
alistek
Sr. Member
 
Total Posts:  293
Joined:  2008-04-02
Normal, IL
 

That would probably work too, I honestly haven’t explored changing things as much as in compiling all of this info I used earlier recommendations and tutorials.  If you come up with a better way please do share what you did, as it can certainly use improvement.

-Adam

 
Magento Community Magento Community
Magento Community
Magento Community
 
metal
Jr. Member
 
Total Posts:  14
Joined:  2008-05-15
 

hi

i have finaly created a new module but when im editing my phtml file in frontend nothing happend. I see empty page. What i have to do?

 
Magento Community Magento Community
Magento Community
Magento Community
 
metal
Jr. Member
 
Total Posts:  14
Joined:  2008-05-15
 

do i have to create xml file in layout folder or something?

 
Magento Community Magento Community
Magento Community
Magento Community
 
alistek
Sr. Member
 
Total Posts:  293
Joined:  2008-04-02
Normal, IL
 

Yes the <module>.xml file MUST be in the layout folder, that is what determines what gets displayed on the frontend AND the backend (seperate for each theme).

-Adam

 
Magento Community Magento Community
Magento Community
Magento Community
 
alkarim
Sr. Member
 
Total Posts:  245
Joined:  2008-04-10
 

hi @alistek,
I just wondering about its controllers.

You see at controllers folder, there is <Module>Controller. What makes you think it should be <Module>Controller… How about if I want to change its name like MooController ??

any ideas?

 
Magento Community Magento Community
Magento Community
Magento Community
 
alistek
Sr. Member
 
Total Posts:  293
Joined:  2008-04-02
Normal, IL
 

It doesn’t have to be <Module>controller, you can name it anything you want and then use the layout xml to determine the block and controller to use.  Also you can use URL rewrites in the backend to make things look nicer.

-Adam

 
Magento Community Magento Community
Magento Community
Magento Community
 
rubikintegration
Jr. Member
 
Total Posts:  5
Joined:  2008-07-13
 

It’s quite weird that even tho I get “New Module successfully created!” I could not find this new folder anywhere. I thought it was the problem with the chmod, so I tried on my localhost (running xampp on winxp) but the same thing happens. What could be the problem here?

Thank you for the great module

Edit

Go to the module creator index page in your web browser, and fill in the desired module information. If you enter your Magento directory, the module creator will attempt to install the module directly into Magento, though file permissions must be set correctly for this to happen. If your file permissions are incorrect, or you do not want the module installed right away, you can leave the Magento Directory blank, and the module creator will create the module in a folder called new, and place it in the module creator’s folder.

Me feeling so stupid *_*

 
Magento Community Magento Community
Magento Community
Magento Community
 
rubikintegration
Jr. Member
 
Total Posts:  5
Joined:  2008-07-13
 

BTW, news module is greatly needed by most people, it’d be great if there is a simple already coded module for this so we can just plug-n-play ^_^

 
Magento Community Magento Community
Magento Community
Magento Community
 
alistek
Sr. Member
 
Total Posts:  293
Joined:  2008-04-02
Normal, IL
 

If you entered the Magento directory then it will automatically install into /app/code/local/<Namespace>/<Module>/, if you didn’t enter a Magento directory then it will be directly underneath the root directory of Module Creator and called New.

-Adam

 
Magento Community Magento Community
Magento Community
Magento Community
Magento Community
Magento Community
    Back to top
 
Sales: Call 877.832.5289 (North America) 310.295.4144 (International) to request a call-back.
© Copyright 2008 Varien. Magento is a trademark of Irubin Consulting Inc. DBA Varien
Privacy Policy|Terms of Service
Magento Community Count
32091 users|363 users currently online|71970 forum posts