Magento empty cart event - events

I'm a real newb in Magento, there's a button in the cart page that empty the cart's content. I'm trying to find the event triggered by this action, I tried checkout_quote_destroy but is not that one, neither sales_quote_remove_item.
I'll appreciate any help.

What you could do is log all events, and search through them for the proper event:
Open: /app/code/core/Mage/Core/Model/App.php
Search for: public function dispatchEvent($eventName, $args) {
Add this line below: Mage::log("Event name: $eventName");
Look in var\log\system.log you will see a long list of events.

Related

Presta shop duplicate action in custom module not working

I am working on a presta shop 1.6/30bees module which has a list view in the backend. 'Edit' and 'Delete' actions are set up and work as expected, however when I use addRowAction('duplicate') to add the duplicate action, I do get a link without the right parameters.
The button is rendered, but the link leaves out the item id and the action name. I thought duplicate is a default action that needs little to no work, however I also do find little documentation on that one.
My module currently extends AdminController, but extending ModuleAdminController did not change the outcome either.
public function renderList() {
// add edit function to list item
$this->addRowAction('edit');
// add duplication function to list item
$this->addRowAction('duplicate');
// add delete function to list item
$this->addRowAction('delete');
return parent::renderList();
}
Am I missing a detail on how to get duplicate to work or am I in the wrong and have to add it like a full custom action?

Magento: Empty Payment Html in Methods.phtml

I’ve got a problem with the payment methods for my checkout. When I reach the Checkout Step for the Payment Methods, the several options are displayed but I am getting no further Information to the Methods “Bank Payment” and “Cash on Delivery” when I click on the radio button.
It seems to me that getPaymentMethodFormHtml (checkout/onepage/payment/methods.phtml) is empty for these Methods. As a result of this issue, I am getting no information in the Order Confirmation Mail (like Bank Name, Cash on Delivery Fee).
Can anyone help me?
Your error should be in
/app/design/adminhtml/default/default/template/payment/form/[cc.phtml]
/app/design/frontend/default/default/template/payment/form/[cc.phtml]
You may need to take a look at each payment method to see the path for their template
e.g
<?php
class MagePal_CimPaymentPro_Block_Form_Payment extends Mage_Payment_Block_Form_Cc
{
protected function _construct()
{
parent::_construct();
$this->setTemplate('magepal/cimpaymentpro/payment/form/cc.phtml');
}
Also, you may want to check to make sure you don't have any javascript error on that page.
You could also use Inspect Element in chrome/Firefox (or firebug) to see if the html is hidden by css

In Magento, what is an observer exactly? What does it do?

I'm an extremely novice programmer who finds himself tasked with learning how to program for Magento. So please forgive me for such a rudimentary question but there don't seem to be a ton of beginning level content on Google regarding Mage.
Can someone explain to me what exactly an observer is? What does it do? What can it be used for?
If someone can give me a super 101 explanation (not assuming much prior knowledge) you'll be my new hero. Thanks.
You can consider Event observer as a trigger.
Once you have set an event observer, for example you can set observer before or after an event, i.e., You can add a event which would execute right after user adds a product to cart or before the add product to cart.
In this event observer, you can write code to customize the data which is either passed to the occuring event (before) or is the output of occured event (after)
Reference : http://www.magentocommerce.com/wiki/5_-_modules_and_development/0_-_module_development_in_magento/customizing_magento_using_event-observer_method
Event :
In Magento you may consider a Controller Action as an event, for example addAction in CartController is an event.
Observer :
As mentioned in name, the observer observes when this action occurs (in our case addAction in CartController) and calls a function either before or after this addAction is called.
You may add your custom code in this obeserver for customization.
An Observer is the piece of code you'll need to write if you implement an Event.
Your question is : what is an event ?
See an event as a "broadcast action" that you can intercept in order to add your specific code to a specific action.
There are events fired all over magento key functionnalities.. For example, you can intercept:
- after or before saving a product
- product added to the cart
- etc
It's just an open-door leaved by magento core developers for you to plug-in..
In magento you have several ways to modify the behavior of the standard fucntionnality :
- you can rewrite classes ( tags in config.xml)
- and you can use the events when an event is available for the functionnality you want to modify
To understand, dive in the code and search "dispatchEvent" in app/code/core ...

Why can I not get the message block in Magento to show on the category page?

I'm trying to get Magento to redirect after a customer clicks the 'Add to Cart' button over to the category page, which I have done with no problem (after a little bit of searching around, of course) by using a hidden field with the name of "return_url". This part works perfectly, and the item is added to the cart, and the user is redirected back to the category page. Once here, no matter what I've tried I cannot get the message block to show the success (or error) message. Here is my most recent code attempt (in view.phtml):
$messages=Mage::getSingleton("checkout/session")->getMessages();
echo $this->getLayout()->createBlock("core/messages")->setMessages($messages)->getGroupedHtml();
Thanks!
Have you tried more simple addSuccess/addError/addNotice functions?
Mage::getSingleton('core/session')->addError(Mage::helper('core')->__('An error'));
Mage::getSingleton('core/session')->addSuccess(Mage::helper('core')->__('A success'));
Mage::getSingleton('core/session')->addNotice(Mage::helper('core')->__('A notice'));
You can add a message to different session model types like "catalog", "customer", "checkout" or simple "core".
Same as:
Mage::getSingleton('catalog/session')
Mage::getSingleton('customer/session')
Mage::getSingleton('checkout/session')
Mage::getSingleton('core/session')
In your case, the customer session messages are not initialized in the category controller. Take a look at
\Mage_Catalog_CategoryController::viewAction
The end of the function should look like this:
$this->_initLayoutMessages('catalog/session');
$this->_initLayoutMessages('checkout/session');
$this->renderLayout();
To display the messages from "customer/session", this area must look like this:
$this->_initLayoutMessages('catalog/session');
$this->_initLayoutMessages('customer/session');
$this->_initLayoutMessages('checkout/session');
$this->renderLayout();

Display a success message to user in a SharePoint Document Library after validation in ItemAdding Event

When validating a document in the ItemAdding event there are many ways to display errors to the user, but there doesn't seem to be a way to display successes to user, like a validation was successful. An info message to the user at the top of document library would be great.
public class MyItemEventReceiver : SPItemEventReceiver {
public MyItemEventReceiver() {}
public override void ItemAdding(SPItemEventProperties properties) {
// Do some validation
// If successful display message to user - can't seem to do
// If unsuccessful cancel and go to the error page - easy
}
}
}
In the event handler you have a Property called Cancel when set to true it will redirect you to the Error Page. Whereas when you dont distrub it, it will redirect you to the Metadata page of the document, i.e it will as you for the Name and Title of the document. Being said that out of the Box it is not possible to archive what you want to do. One alternate approach I would suggest is that once the validation is successful, set a Flag in the Session / Property Bag of the List with the Document GUID as the Key and in the Final Landing page deploy a Custom Web Part that will check for the this GUID and if there is a Value then It will display the Message.
Umm... edit List's AllItems.aspx or edit your masterpage, add Literal control to it. At ItemAdded event just refer to that control and set it's value.
Maybe it turns out you even need code-behind for that masterpage. Refer here.

Resources