Magento 2: Generating an Add to Cart URL for Configurable Products

Published by John on January 23, 2020

When using Magento 2, if you want to add a configurable product to the cart outside of the normal product page, like from within a CMS page, you can’t just use the getAddToCartUrl() function, but instead need to create a special form. This article describes one way of creating an add to cart form for a configurable product that you could adabpt to a custom PHTML template file, such as in your theme or a custom module.

Please carefully read the notices though, as this is just a proof of concept and you should NOT simply copy the code as is!

Read More  |  Add Comment

A Quick Look at How the WordPress “Log Out Everywhere” Button Works

Published by John on October 28, 2019

I got an email from a client that I do Wordpress development for about performance impacts of the “Log Out Everywhere”, which appears in the back end of Wordpress when you are editing a user. I realized that I wasn’t overly familiar with how Wordpress sessions work, so took this as an opportunity to dig into how the actual session gets saved in the database.

Read More  |  Add Comment

Adding a Trailing Slash to CMS Pages in Magento 2

Published by John on October 9, 2019

One of my clients is migrating their Magento 1 website to Magento 2. One feature that is a bit tricky is adding a trailing slash to the end of CMS Pages. For Categories and Products, this is not an issue, but it isn’t as straightforward for CMS Pages.

I wrote an observer that you can plugin to your custom Magento 2 plugin to automatically add the trailing slash to CMS Pages when they are saved, which I think is the simplest and non-obtrusive way of addressing this issue. However, if you know a better/easier way, please feel free to leave a comment.

Read More  |  Add Comment

Magento 2: Targeting a Specific CMS Page using Layout.XML

Published by John on September 1, 2019

With Magento 2, adding a layout update usually starts with creating an XML file, using the layout handle of the item you are trying to target. For example, if you wanted to make a change to all category pages, you could create a file named ‘catalog_category_view.xml’ and then add all your updates to it.

For CMS pages, you can do a general update to ALL cms pages or target a specific page by using the identifier(URL Key) of the CMS page.

Read More  |  Add Comment

Hiding WordPress’s ‘PHP Update Required’ Dashboard Warning

Published by John on August 27, 2019

Wordpress has started reporting that PHP Version 5.6 is not supported and adds a nag to the admin dashboard, saying that PHP needs to be updated and “WordPress has detected that your site is running on an insecure version of PHP.”

While it is better to upgrade PHP to version 7, if for some reason you want to hide this box, you can do so by removing the ‘dashboard_php_nag’ meta box.

Read More  |  Add Comment

Next Page »