Magento custom model override - magento

I'm new to Magento, so forgive my lack of knowledge. I am following a tutorial to integrate the contacts in Magento and import it to SugarCRM. The tutorial changes the core functions of Magento, but I would like to write a module and leave the core intact. I can easily find information about overriding controllers, models, helper, etc. But I have a question.
Imagining, for example, each time a user registers on my website, his contact information is exported to SugarCRM. In the save contact phase, in my module I know that I can write a specific code and tell that it would need to be run after or before some specific core-functions of Magento are done to save the contacts.What I really don't understand is, how will Magento know that I have a module that will perform me certain actions when I'm creating a new account?

The way magento handle this is by using events/observers. For instance, if you needed to send order information to another system after an order has been placed, you could create a custom module which observe sales_order_place_after.
Read more # http://codemagento.com/2011/04/observers-and-dispatching-events/
To get a list of events see https://magento.stackexchange.com/questions/153/where-can-i-find-a-complete-list-of-magento-events
For how to create an module with observer see https://stackoverflow.com/a/12696681/1191288

Related

How do I get Magento 2 data to use in the template?

I am starting in the Magento development world, and I'm creating a new theme.
On my theme, I have a block which displays business contact info, but I don't know how to get the data from the store.
I have to make a custom menu as well, but stop in the same problem: getting category data from the store.
I also wanted to know if there is any place where you can find more references on this data return issue, such as what available methods and classes are available, for example.
Where do you want to display the custom data ? In a product page or your custom module's separate page ?
If you want to use custom block in sidebar you can follow steps given here
https://aureatelabs.com/magento-2/how-to-add-a-static-block-in-a-sidebar-column-magento-2/.
Here are some ref you can use:
https://itectec.com/magento/magento-magento-2-get-custom-module-data-in-theme-phtml/
https://code.vky.co.in/display-custom-module-collection-data-frontend-magento-2/

File location of phtml file of backend admin page

I installed an extension to add custom fields to customer registration form.I want to add some option value in dropdown menu box of input validation in backend admin page..could you plz tell me the path of the folder where can I find the phtml file which is responsible for that part ?
-Thanks.
The files you are looking for are in:
app/design/adminhtml/default/default/template
But just changing the .phtml file won't do the job. The customer model itself should be extended to provide for your extra field. Therefore i highly recommend you to write a module for this instead of altering Magento core code. This to make sure that you can still use updates in the future.
Writing such an module requires more in depth knowledge of Magento. For more information on custom adminhtml see here.
For information on extending the core functionality look here.
If you don't feel like programming this all yourself take a look at customer attribute modules on Magento Connect.

Magento adding set of attributes/properties to products

I need to add something similar to the Review system already available on Magento. I mean, I want to add a couple of texts, reviewing capacities and alike. It should have an administration side on the backend to be able to reject/accept/edit those texts. I still do not have all the things clear so I want to ask before I embark into a wrong/closed path.
Should I reuse the existing code by copying core files into local and modifying at will?
Or should I add my own tables and link to EAV model using product ID?
On this SO question the accepted answer posts a code on how to add a new custom attribute to all products. I could use this but I would still need to add the reviews part.
I've searched for a similar functionality but can not find anything.

Magento: adding product from frontend form

I have magento demo shop and for example i want registered user to be available to post a product from frontend? Can anyone hook me up with some code showing how to make it? Is it even possible in magento?
It's certainly possible. It actually shouldn't be all that difficult. You're going to create a module, programmatically create an order, and link this page from somewhere. You should be able to hack one together with the following resources:
Programmatically Creating Orders - Inchoo
Creating a Custom Module part 1-8
yes dear it is possible, you have to create a module for that and i think you give to link/tab in customer account page in front side.in account page you provide form of add new product.you have also provide all option like in magento back end. but some customization are required

Magento Multiple Authorize.net Gateways

I have a CAD and USD gateway accounts for processing credit card payments, both from a payment provider with support for the Authorize.net API. I've successfully configured one using Magento's built-in Authorize.net support... but how can I configure a second Authorize.net Gateway for use in my store?
You can reuse the existing authorize.net gateway if you assign separate websites to each currency. They don't need to be actually separate websites with their own domain, just to be designated as websites in the System > Manage Stores menu. Then in Configuration change the Configuration Scope drop down box in the top left to select each website in turn, on the Currency Setup section allow just one currency and in Payment Methods section you can have your specific gateway accounts to match.
This way lets you continue to use the same products for all stores and as long as the base currency is unchanged then it will also continue to convert between currencies automatically.
This can be done, but basically requires you to duplicate the Authorize module and change all the namespaces. This will take some fiddling, but start by copying the app/code/core/Mage/Paygate module to somewhere like app/code/local/Yourcompany/Paygatecad and proceed to rename the classes (Mage_Paygate_Model_Authorizenet becomes Yourcompany_Paygatecad_Model_Authorizenet, etc). Be careful of case-sensitive file and class names, I suggest you use all leading capital followed by lowercase.
Create a Yourcompany_Paygatecad.xml module declaration in app/etc/modules, and duplicate the layout and template files in adminhtml and frontend to use your new module name. You'll also need to edit the system.xml and config.xml so that the config values don't conflict in namespace. grep is your friend.
After all that, you should get a new Payment Method in the System>Config>Payment Methods that you can configure with your CAD details, and the blocks should render in the Checkout flow.
As you've probably gathered from what I've said, there's a fair few changes to be made to avoid conflicts, and you'll need to test this really well. But it should work. I'm not aware of any alternative approach to achieve this... I've done this successfully when I've wanted two different set of options for another payment method and it worked, but that was for a community extension, not Magento core, not that it should really matter where you're copying it from.
--------EDIT-----
Ideally, what you should do is copy and modify only the etc and sql files. That way the
original Mage_Paygate Models and controllers will still be used (gives you best protection for upgrades/patches) and you just update the config values to point to the CAD instance. I can't confirm whether this will work, but I would try that if at all possible.
HTH,
JD

Resources