[Magento 2] Get current product

Getting the “current product” in Magento 2 is trickier than it was in Magento 1. However, it is like that for a reason: Mage:: is a thing from the past, no more accessing to everything from everywhere (someone I know would say: “this is not logic at all”). That’s the reason why, in order to get the current product in a product page, you’ll need to use the class Magento\Framework\Registry in your block and add the Read more…

[Forms] Remove a field from a Form

Recently I wanted to remove a field from a form object. It was easy, we need to know 2 things: Fieldset name (‘main’ by default) Field name With this information we can just update the form object with:     <?php $this->getForm()->removeField(‘password_fieldset’); ?>

Filter a collection when the attribute value is not set

Since the very first time I started working with collections in Magento I run into situations where I needed to filter a collection by an attribute whose value is not set yet (for example, when the attribute is of the type ‘yes/no’, values 0/1). If I wanted to filter by all the products with a value ‘1’, that was easy, but when I was on the case of filtering by ‘0’, then the collection filter Read more…

Some thoughts about Magento 2

During the past 5 years I have been working on eCommerce and always with Magento. Magento “1”. Magento 1 has become the natural option to recommend to anyone who wants to implement a secure, complete, extensible ecommerce site. I have learned a lot while developing on Magento, but also when discussing functional specifications with our clients, finding out what can be done and what is not a good idea to do. When it comes to Read more…

[New Relic] One of the best tools to monitor your Magento shop

At my company we’ve been using tools like Munin to monitor the server. Munin is a great tool that shows all type of graphs of what’s going on in the server: Apache processes, Varnish memory, Database performance, Server load, Disk usage, Memcache performance… and a lot more. Basically, you can configure any service you have so that Munin can generate graphs. But Munin only informs us about server stuff. It doesn’t really provide any type Read more…

[Magento] Class “Mage” not found – Possible reasons

The «Class “Mage” not found» issue has been recently a headache in most of our projects. I could say that there was a specific change eventually (either a package update, package installation, configuration change…) that make this error appear. The problem is not the error itself, the problem is that this error is not providing any type of information at all. As a consequence, it makes it very difficult to investigate what the actual issue Read more…

Magento 404 issue in some stores

We have recently had an issue with a weird 404 page in Magento. Basically, when accessing to some stores, we got a 404 page: but not the 404 page when a page doesn’t exist. It was a 404 Magento page, different than the ordinary ones. After investigating we have finally found that the problem was with the SET_ENV variable. We have set up this in the server configuration. But the code we where applying didn’t Read more…

Paypal Express + New Customer = no taxes applied and customer assigned to NOT LOGGED IN group in Magento

Recently I asked a question on Stackoverflow about a weird issue when using Paypal Express in Magento. If the customer is registered during the payment process, when the order is completed, the customer is not assigned to any group and no taxes are applied to the order. I finally found the solution myself and like to post the fix in here. It is necessary to rewrite the class app/code/core/Mage/Paypal/Model/Express/Checkout.php and modify the method _prepareNewCustomerQuote() so Read more…

Press Ctrl+C to copy the following code.
"