161 cards
Linked content

Limiting The Number of Autocomplete Results

SweetTooth details how to limit the number of autocomplete entries, as by default this list is not limited whatsoever, not good on a store with lots of products!

Associating An Orphan Sage Pay Suite Transaction With An Order

We had a situation whereby a client placed an order and went through Sage Pay
succesfully, however the order was not able to be created on Magento, so we had
an error stating "WARNING - There are approved Sage Pay transactions that have
no associated Magento orders. Click here to go to Orphan Transactions List".
This isn't the easiest of problems to solve, so here is how we did it:

  1. Find out the order details, this will probably mean ringing the customer and
    finding out what they ordered and where they want it delivered to.

Windows Apache 2.4 VirtualHost Definition

Put this in your httpd.conf:

<VirtualHost *:80>
    DocumentRoot "C:/your/docroot"
    ServerName yourname.local
    DirectoryIndex index.php
<Directory "C:/your/docroot">
    Options Indexes FollowSymLinks
    AllowOverride All
    Require all granted

Add Category Attributes Through SQL Updates

This is creating a module which will update categories to include new attributes.

  1. inside app/etc/modules/yourmodule.xml put the following:

     <?xml version="1.0"?>
  2. Next, inside app/code/local/Yourmodule/Sql/etc/config.xml put the following:

     <?xml version="1.0"?>
Linked content

Controller rewrite

Controller file:

  * Controllers are not loaded with autoloader,
  * to extend a controller class we need to first call the actual class file
  * ExtendableController is that class fileName!
require_once Mage::getBaseDir('code') . '/core/Mage/ModuleName/controllers/ExtendableController.php';

class Namespace_Module_SomeController extends Mage_ModuleName_ExtendableController
 * your controller actions here

see link


URL rewrite XML

The following remaps services/view/index/url_key/param:


Complete tag:
if set to 1 magento will use the source layout handles otherwise it will use new layout handles associated with the rewrite.

Getting The Amount Of Items in the Cart

To get the amount of line items (i.e. 10 of 1 product is 1):


To get the total number of items (i.e. 10 of 1 product is 10):


Resize A Product Image

Mage::helper('catalog/image')->init($product, 'image')->resize(150);

Adding Attribute To Category List Product Collection

Only a core set of attributes are added to the product collection (for the list page) by default. This bit of XML will allow you to add additional attributes to that collection:



Linked content

Create Admin User/Role via SQL

Fasntastic webpage which allows you to create a new admin user and role via SQL - it does all the SQL generation for you and also looks lovely!

Find Unused Product Attributes

Just to keep things tidy!

SELECT attribute_id, attribute_code, frontend_label
FROM eav_attribute
WHERE entity_type_id = 4
AND attribute_id NOT IN(SELECT attribute_id FROM eav_entity_attribute);

Product EAV Attribute Set, Group and Attribute List

To see a list of all attribute sets, groups, and associated attributes for products, use this SQL. BONUS! Also shows the sort ordering, useful for determining which sort_order you need to place an attribute in a certain position:

SELECT s.attribute_set_name,
FROM eav_attribute_set s
LEFT JOIN eav_attribute_group g   ON s.attribute_set_id   = g.attribute_set_id
LEFT JOIN eav_entity_attribute ea ON g.attr...

Import Not Working Until You Save

This is because you've missed out _product_websites, for which all products should have a value of base

Importing Images

Ok so to import images you first need these columns:

  • _media_attribute_id - the attribute_id of media_gallery (see below)
  • _media_image - the path of the image, i.e. /some_image.jpg
  • _media_lable - the image label, i.e. "My nice image"
  • _media_position - the position, 1, 2 etc
  • _media_is_disabled - whether the image is excluded from the gallery or not

You do the whole weird multi-line thing to import multiple images. Every image
you use (whether it's in the gallery, or being used for the image, small_image
or `thumbn...

Full Module Configuration Reference

<!-- # Module Initialisation
    app/etc/modules/Namespace_ModuleName.xml -->


<!-- # Module Configuration
    app/code/local/Namespace/ModuleName/etc/config.xml -->




Config Helper Rewrite Definition


This website uses short-lived cookies to improve usability.
Accept or learn more