Magento - Clean custom Account/Registration Fields - magento

I followed this tutorial to add fields in the registration form of a customer under Magento, I succeed to run the example, but I know that It is not clean, for upates later...
What' the best way to rewrite all the files used in the tutorial, in a clean way :
app/design/frontend/default/yourtheme/template/customer/form/register.phtml
app/design/frontend/default/yourtheme/template/customer/form/edit.phtml
app/code/core/Mage/Customer/Model/Entity/Setup.php
app/code/core/Mage/Customer/etc/config.xml
app/code/core/Mage/Customer/controllers/AccountController.php
Thanks a lot

You need to create your own module. Never edit files in app/code/core/ folder. If you want to add functionality to Magento, you need to rewrite the base classes.
Alan Storm has good tutorials to follow:
How to create a simple 'Hello World' module in Magento?
To rewrite a controller (AccountController in your case), and after you create you own module, you can follow this tutorial.
Configure the Layout
In your app/code/local/MyCompany/Module/etc/config.xml:
<?xml version="1.0"?>
<config>
<frontend>
<layout>
<updates>
<mydesign>
<file>myfile.xml</file>
</mydesign>
</updates>
</layout>
(...)
Then you could update your layout in app/design/frontend/default/mydesign/layout/myfile.xml.

Related

Arabic words in invoice pdf print Magento

I'm trying to fix this problem by using integration TCPDF in magento but i don't know how do that
this is my try in this file
\app\code\core\Mage\Sales\Model\Order\Pdf\Abstract.php
require_once('TCPDF/TCPDF.php');
$pdf = new TCPDF_TCPDF
(PDF_PAGE_ORIENTATION, PDF_UNIT, PDF_PAGE_FORMAT, true,'UTF-8', false);
I don't know waht i'm doing wrong. thank you.
1) Don't edit core files.
2) There are multiple invoice generators in magento: invoice from the backend, invoice on success page etc. So make sure that you are editing and testing the right one. The example below works for invoices in the backend.
3) There may be custom modules that are overwriting your xml, like Webshopapps_Invoicing, check that or it will not work (that's the issue that I had when trying something similar).
After you copied TCPDF to your magento lib folder so that you will have now root/TCPDF/TCPDF.php edit TCPDF.php by changing the class name from tcpdf to TCPDF_TCPDF
Go into code/local/Yourcompany and create the folder invoices. In this folder create etc/config.xml with this content:
<?xml version="1.0"?>
<config>
<modules>
<Yourcompany_Invoices>
<version>0.0.1</version>
</Yourcompany_Invoices>
</modules>
<global>
<models>
<sales>
<rewrite>
<order_pdf_invoice>Yourcompany_Invoices_Sales_Model_Order_Pdf_Invoice</order_pdf_invoice>
</rewrite>
</sales>
</models>
</global>
</config>
Create another folder structure in code/local/Yourcompany like this Sales/Model/Order/Pdf and add Invoice.php:
class Yourcompany_Invoices_Sales_Model_Order_Pdf_Invoice extends Mage_Sales_Model_Order_Pdf_Invoice {
// it can be another class if you have a custom module overwriting it, like Webshopapps_Invoicing_Sales_Model_Order_Pdf_Invoice
$pdf = new TCPDF_TCPDF();//your stuff here
}
Then submit a test order and go into admin and check a pdf invoice.

how to add extra filter to custom product reports in magento

I am doing custom product reports in magento. I followed as the steps in the url
But how can I add extra filter after "from:","to:","show By:". I know where to edit in core file(adminhtml/default/default/template/report/grid.php). But it is not the correct way. how to override this filter block for custom reports.
If you want to edit the template file, implement your own module, add a section to the config.xml
<config>
<stores>
<admin>
<!-- override default admin design package and theme -->
<design>
<package>
<name>default</name>
</package>
<theme>
<default>CHOOSE_A_NICE_NAME</default>
</theme>
</design>
</admin>
</stores>
</config>
and then start changing your template in
adminhtml/default/CHOOSE_A_NICE_NAME/template/report/grid.php
Thanks for you swift reply Fabian Blechschmidt...almost I did the same but I overrode the template file.
adminhtml/default/mytheme/template/reportnew/grid.php
I just copied all the report files to mytheme/template folder (reportnew) and its working fine.
I have managed to add two extra fields viz country and a custom attribute "myattrib". But now I am unable to fetch the values from the grid to the model so that I can filter results based on these fields.
Thanks Murali

Magento: Custom module not working on magento 1.3.2.3

I have designed a custom magento extension. It has custom menus on magento admin panel. I have tested it on magento 1.5. But when I tested it on magento 1.3.2.3 it didn't show any menu. I have checked module status from System->Configraion->Advanced and it is enabled there. What could be the possible problems here??? Why my module is not working on magento1.3.2.3??
Please help.
Clean cache.
Try to remove ACL(if any) from config.xml.
As already suggested: Log out and Log in.
Check logs in (mage root)/var/logs/ system.log and exception.log
Check config.xml structure of any default module. For example, check
(mage root)/app/code/core/Mage/Catalog/etc/config.xml
I suppose there should be something useful for you.
I think you need your Helper->Data.php in place and also have the entry for the helper in your config.xml, sth like:
<global>
<helpers>
<Mymodule>
<class>Myspace_Mymodule_Helper</class>
</Mymodule>
</helpers>
</global>

Adding Block in existing module of magento

I have customized customer module to meet my requirement. I am able to rewrite block classes of customer module. I am trying to add one custom block class in this module which is not exists in existing customer module but I don't know how to accomplish this.
my code looks like in config.xml
<blocks>
<customer>
<rewrite>
<widget_name>Mynamespace_Customer_Block_Widget_Name</widget_name>
<form_register>Mynamespace_Customer_Block_Form_Register</form_register>
<form_edit>Mynamespace_Customer_Block_Form_Edit</form_edit>
</rewrite>
</customer>
</blocks>
I created a new block class under the Form directory of customer module called 'Test.php'
And customer layout file looks like
<reference name="my.account.wrapper">
<block type="customer/form_test" name="customer_test" template="customer/form/test.phtml"/>
</reference>
But it is not executing the block class file.
Is there anything should be added in config.xml file of this module?
Please help how this block can be integrated with existing module.
Thanks.
You shouldn't really be adding blocks to the customer module, you should be adding them to your own module. If you want to keep on w/ the customer module, check to make sure that your block is named as Mage_Customer_Block_Form_Test and extends Mage_Core_Block_Template. Otherwise, create the class as Mynamespace_Customer_Block_Form_Test and keep it in your module directory. Then, add a block definition for your class in config.xml:
<blocks>
<mynamespace_customer>
<class>Mynamespace_Customer_Block</class>
</mynamespace_customer>
</blocks>
Then you should be able to load the block as mynamespace_customer/form_test.
It may be easier to debug your problem if you use a module name other than customer. Generally speaking, that is a bad idea and will likely cause bugs in the system.
Hope that helps!
Thanks,
Joe
You may already be aware of this but think about checking LayoutViewer to see what the layout thinks it is using.
Although I'm sure your example config.xml is just an example please make sure that you've remembered to create a rewrite for form_test and that there is a valid blocks section for your own module.
BTW, LayoutViewer could really do with being packaged properly for Magento Connect. The linked file lacks the necessary config to enable the module and it would be much more useful if accessible from PEAR.

Magento - Adding Files to Local/Mage has no Effect

I would like to make changes to some Magento core files. To make sure the changes are future proof I copy the file from code/core/Mage to code/local/Mage.
I keep the file structures and file names consistent. The problem is when I do this the changes have no effect (I've refreshed the cache)
Any ideas where I'm going wrong? If I edit the core files directly the changes take place.
You should create a new local module and define rewrites in the config.xml file:
Create app/code/local/MyCompany/MyModule directory. Add subfolders etc and model.
Now create etc/config.xml file containing:
<?xml version="1.0" encoding="utf-8?>
<config>
<modules>
<MyCompany_MyModule>
<version>0.1.0</version>
</MyCompany_MyModule>
</modules>
<global>
<models> <!-- type of class to rewrite -->
<catalog> <!-- base module to rewrite -->
<rewrite>
<product>MyCompany_MyModule_Model_Product</product>
</rewrite>
</catalog>
</models>
</global>
</config>
Implement model/Product.php with your changes. Easiest way is to inherit from the base class and rewrite the metho.
Also remember to activate your module in app/etc/modules.
The above poster is correct in that the preferred way to edit core functionality is to use rewrites. In some cases, though, this isn't possible, in which case you should be able to place core files into the /app/code/local/Mage directory to get them to work. Block and Model files should work immediately in this way, as should controllers if I remember correctly. Other files (such as config files) may not be automatic.
Could you post the details of a particular file that doesn't respond as you expect? It's easier to debug particulars than generalities. Also, make sure that you have shut off any opcode cache that you have installed on the server in addition to flushing the normal cache.
Thanks,
Joe
You can easily overwrite xml settings using local.xml. So, if you want to overwrite/add to app/code/core/Mage/Customer/etc/config.xml you just add it to app/etc/local.xml.

Resources