Posts

  • Magento Adminhtml and Relative Links to Static Resources

    Relative links in URLs allow you to only specify the path to an resource that is in the same or subfolder of the current folder. Lets say the current page you are on is http://example.com/test/ and you want to reference an image at http://example.com/test/image.jpg. You could put the full http://example.com/test/image.jpg in the src attribute of the img tag, or you could use just image.jpg instead. This works well when you are not sure what the directory path is the parent directory of your code. However, it can cause some issues when your code is moved to another location, but some resources are not moved, such as image.jpg. ##Magento Adminhtml Magento’s Adminhtml, or administration backend goes through a completely different route in the app/Mage.php code to enable you to control the menu, products, and content of your site, among other things. Many eCommerce sites using Magento need some aspect of the administration backend customized to handle the unique workflow for the business. However, there are some occasions where this can cause some unintended consequences. ###Relative Links in Magento When customizing the administration backend for Magento, there are some cases where you may need to include a third party library to achieve the desired result. One thing that many of these libraries do is reference all of their resources with relative links. If, in the process of including the third party library, you neglect to include the resources referenced in the JavaScript or CSS, then it will cause a 404 error to occur when accessing the resources.

  • MySQL Deadlocks with Magento

    One of the things that Magento, and specifically the Zend Framework provide developers is the ability to not have to think about database details as it should just handle all that for you. When it becomes obvious that there is a problem somehow with the production database getting some sort of SQL errors, its time for the developers to start caring about the implementation and architecture details of the database. ##Symptoms One of the indicators of upcoming troubles is that your admin users start to get error messages saying that there are deadlocks in the transactions. At first, these errors are extremely sporadic and hard to track down. Over time and increased traffic loads, they will become more frequent to the point that it requires attention.

  • Top 5 Ways to Make a Developer Your Enemy

    Developers are known to be some of the most finicky employees you will encounter in the workplace. However, this is a list of things that will annoy or infuriate developers and non-developers alike.

  • Varnish and Magento Performance Mystery

    One of the things that you think you will solve when you implement a Varnish caching server in front of a Magento website is performance problems. However, this is not necessarily the case.

  • How Not to Use SQL Transactions

    SQL Transactions allow you to isolate atomic operations so that you can ensure that a third party does not update the data affected during the atomic operation protected by the transaction. An example of an operation that you would want to protect with a SQL Transaction would be transferring funds from one bank account to another. The first step of this operation would be to subtract the funds from bank account A. Once complete, we would then add the same amount of funds to bank account B. Assuming nothing fails, everything works as expected. However, if there is other database activity at the same time or an error occurs in one of the queries, without a transaction you could have the funds removed from bank account A or added to bank account B, but not both, causing a major balancing issue with your bank accounts.

  • Unexpected Results with SQL Server and Python pyodbc

    Using the Microsoft SQL Server Management Studio (SSMS) with SQL Server hides many of the API complications that can sometimes arise when working with SQL Server. One specific example would be when using Python on Windows with the pyodbc driver. If you have an update statement that performs a simple update to a status column and a datetime column, you can have some unexpected results.

  • SQL Server Transaction Log Exponential Growth

    There are few things more frustrating than seemingly random issues that crop up in software when configuration changes occur. One such occurrence is when you migrate your databases from Microsoft SQL Server 2012 Standard Edition to Microsoft SQL Server 2012 Enterprise Edition with High Availability and the transaction log suddenly begins to experience exponential growth without ceasing.

  • WordPress and the Genesis Framework

    It turns out that working with WordPress and the Genesis Framework is quite a bit different than working with Magento or other blogging platforms. Ghost is a blogging platform that runs on NodeJs that utilizes Handlebars templates for the layout of the content on the website itself. Similarly, Magento uses its own templating system in .phtml files for laying out content on the screen. However, WordPress, and specifically the Genesis Framework have taken this simple templating concept and added quite a few layers of abstraction to come to the end result. This does give WordPress a great deal of extensibility for the various plugins that have been written for WordPress. Unfortunately, this makes for a steeper learning curve for developers working on a WordPress website.

  • Saving Products in Magento Deletes Tier Pricing

    Magento’s framework makes many things simple to accomplish when working with the products and categories of your eCommerce website. However, I have found one scenario that doesn’t exactly work as expected. ##Tier Pricing in Magento Magento allows you to setup custom pricing levels based upon the quantity purchased. You set the minimum quantity purchased to enable the lower price when the part is added to the customer’s cart. You could see where losing the tiered pricing for an entire catalog of products would be a big deal for a site. ##Saving Products The way I ran across this issue was to load all of the products for a particular category, remove the a category from the list of categories for the product, and then save the product. When I simply performed these steps, all tiered pricing would disappear. In order to combat this, I tried to load tiered prices for the product before saving, but this only caused database errors on save, as Magento was trying to duplicate the tiered pricing settings. The same happened if I loaded the tiered pricing separately, saved the product, and then add the tiered pricing back to the product before saving it again. ##Properly Saving Category Changes for Products One of the ways that I was able to find to properly add a product to a category and set the position in the category is to use the following:

    $cat_api = new Mage_Catalog_Model_Category_Api;
    $cat_api->assignProduct($categoryId, $productId, $position);
    

  • Creating a Best-Sellers Category with Magento

    Magento allows you to organize products in categories, and a single product can be a member of quite a few separate categories. As a result, you can create a category that is specifically for your top selling products. You could manually keep track of which products sell the best, either by number of sales completed, or by the actual quantity of each product that were sold. If you want to spend all your time managing this category, then this is the way to go. However, there is a much easier way to manage the products in the category. ##Automatically Add Products to a Category Adding the top-selling products to your Popular Products category is something that takes a bit of thought and planning before implementing it due to some of the restrictions that Magento places on developers working with products and categories. The flow for doing this would be to first get the list of all products that are currently in the Popular Products. Once we have the list of products currently in the Popular Products category, we can remove all of these products from the category, ensuring we do remove products from the category that are no longer popular. Once the category is emptied, we would need to get the list of product ids for the popular products. Once we have this new list of products, we can add them all to the Popular Products category, set the position of the products in the category, and then view the category page that shows our most popular products.

subscribe via RSS