I have two different modules and with installing that modules i am creating two events, names are different, event's trigger is same (i.e. admin/model/customer/customer/addCustomer/after) and action are also different in OpenCart 2.3.
My Problem is when i add the customer from admin side it executs only for first module. It does not execute for second module.
if i uninstall the first module and add the customer then event for my second module is working fine,
I want to execute some code from two different modules when customer will be added by administrator,
Can anybody help me with this.
I had similar issue in my event call. Kindly check that in your custom event function you are not returning anything after function call.
If you are returning it anything it will come out from the event logic and will not run your or any other module's event.
So kindly comment any return done in your function and test.
Hope it helps.
Never return values incase you are calling any CURL or third party API.
instead of returning values you can store it in any global variables and go ahead.
Related
I wanted to run some code via PrestanShop when a specific button is pressed, before/after the designed action is happened.It's not alter the designed action, just is send some notification to an external system (notify the 3-rd party that we have a new sale and maybe with sales detalis: product, prices, etc)
To be more specific the action is finish a sale(or make an order) when click the related button.
I read something related (hooks and module) but maybe someone have the same issue then any help is appreciated.(even with no code, but good hints)
Maybe what hook is to be triggered here or some hints how to alter the code using PS-standards.
(light way and not just adding some php code to alter in the hard way the core)
Note: language on interface is romanian and the action is when a sale is post into the system (became an order, payments is not relevant/order_status).
Thank you,
Traian
You can use actionValidateOrder and make your call to your 3rd party in this function.
This hook is called here :
classes/PaymentModule.php line 716
We're developing an Yii2 php appliction, which can be seen as a AirBNB clone for sake of simplicity. I'm trying to devide the application into modules, but keep getting ugly dependencies no matter how I twist or try. Couple of examples:
There is a booking and an item module, when displaying an item, the booking module is also to be used to disable dates when an item is already booked.
On the confirm booking page, a credit card form is implemented which belongs to the payment module, which couples the modules really tightly.
The homepage should display items, which depend on the item module for generating the right image url's etc.
How can we keep this kind of things decoupled?
For anybody looking at the same problem, I currently solved it by keeping every strictly decoupled. Modules can either make a call to a custom made WidgetRequester, which sees is a requested widget exists in another module, and returns it if it does, which solves the problem of pages with multiple module dependencies (an item page with a booking form i.e.).
Modules can also trigger normal Yii events, which can be picked up by other modules in their Bootstrap file, and process the events to their own liking.
Im new to magento,
I need to execute a query to insert a flag into orders table of magento when an order is successful (i.e returned from payment page), Ive found the front end files, but not sure where to place the code to execute this simple query, Im not comfortable with folder structure of magento.
Im using magento 1.7 currently
Please help me if you know where is the controller file to achieve this, if you can give me the file paths and class names it will be much helpful for me to uderstand this.
You need to get the event for OrderAfterSave, In observer file, you will get the last order id by using that you could insert flag.
Here is the link to tutorial. Hope this will help
http://blog.decryptweb.com/event-observer-magento/
You should use an Observer for this as it is the cleanest method as you do not have to rewrite any core files.
See http://www.nicksays.co.uk/magento-events-cheat-sheet-1-7/ for a full list of observers in Magento 1.7
See http://www.magentocommerce.com/wiki/5_-_modules_and_development/0_-_module_development_in_magento/customizing_magento_using_event-observer_method for more information about using observers.
If you want to observer the order success action I would use checkout_onepage_controller_success_action there are many others regarding orders, something like checkout_type_onepage_save_order_after as it will give you access to the order object which you will not have to reinitialize.
I'm looking for a link or tutorial on how to trigger a http call or function/method/class each time a recurring/sale/checkout is made in Magento..
I need to book all sales in an external accounting service
Have looked at this link, but it doesn't look like it can trigger on events in Magento?! Here you need to make the calls external
http://www.magentocommerce.com/wiki/doc/webservices-api/api
Really hope someone could help me :)
In every event, magento has been add a dispatchEvent.
like sales_order_save_after/sales_order_delete_after/customer_customer_save_after or many more. check the $_eventPrefix on a class. if there is $_eventPrefix on a class then you can call the Mage::DispatchEvent for trigger a call.
MagentoCommerce
Inchoo
I'm trying to make a loose connection between a Magento installation and another application. In particular, there are only two things I care about at the moment - customers and their purchases. What I edited thus far is the file app/code/core/Mage/Customer/controllers/AccountController.php - function createPostAction() is augmented to send the customer's info to the other application. Another modification was made in success.phtml file to send out the details of the order once it's placed.
The problem I'm having is that if a user just places items in a cart (as a guest) and then registers as part of the checkout process - the customer's record in the second application is never created. It only works if the user first explicitly registers, and then checks out separately.
I suppose AccountController.php may be the wrong file to modify to achieve my desired result, which file should I use instead?
Edit: I am not including the code samples, as it's largely irrelevant - the problem is not with the code, but with the fact that it's apparently in the wrong place. Where would be a good place to add custom code which should run when a new customer is registered?
This is a bit tricky to do cleanly in Magento but possible to achieve. I've had the same task a while ago and solved using observers
First you need to create an observer which listens controller_action_postdispatch event:
<events>
<controller_action_postdispatch>
<observers>
<yourmodule_anything>
<type>singleton</type>
<class>yourmodule/observer</class>
<method>someMethod</method>
</yourmodule_anything>
</observers>
</controller_action_postdispatch>
</events>
Then in your observer method you can check action names as follows
<?php
$action = $observer->getEvent()->getControllerAction();
if ($action->getFullActionName() == 'customer_account_createpost') {
if (Mage::getSingleton('customer/session')->isLoggedIn()) { // this check allows to determine if customer session was created which means successfull registration
}
}
Something similar can be done for checkout registration. In general observers are great (and proper) way to extend Magento functionality. Read more about them here
Anton S is right - you should check if Magento is firing an event when this occurs. If so, your code should respond to that event.
If that is not the case, or you need custom logic to run before the account is created, please consider overriding/overloading the controller using a custom module: http://www.magentocommerce.com/wiki/5_-_modules_and_development/0_-_module_development_in_magento/how_to_overload_a_controller
This keeps the original core code intact. It essentially tells Magento to use your custom controller instead. If the method it needs to execute is not found in your controller, it will use the code from the core instead.