Custom Sized Products
This is an old revision of the document!
Purposed: Sell more products than you have room for in the database by taking customer input and attaching it to the customer’s order.
Skill level: Intermediate to Advanced developer.
Target Audience: Any organization that creates “Made-to-Order” products.
This article will detail an approach to taking custom sized orders from customers and attaching the specific information to an order invoice.
The steps involved are:
- Create a product attribute in an attribute_set for your products that need a custom size. We will call this attribute “custom_size’ for the remainder of this article.
- Alter the product info page to show specific form controls to the user for entering their size information.
- Alter the cart procedure to attach the customer’s information to the product
- Alter the order processing procedure to pass the product information into the order (sales_quote_item in Magento speak)
You will need to create a product attribute called “custom_size” and attach this to any attribute set required for each product that can accept a custom size. This attribute will not be shown to the front end. It will act as a container and pass messages through-out the Magento system.
Altering the product info page to include specific size form controls is different for each organization’s needs. For this article we will create 2 input fields, one to ask for width information as whole inches, and one to get fractional width information down to the 1/8th of an inch.
As the first step, we will hard code in a valid of 23 & 1/8” into the custom field for testing purposes.
in app/code/core/Mage/Checkout/controllers/CartController.php around line: 89
$product→setData(’custom_size’, ‘32 1/8”‘);
Add the above line just above the line:
Now we have to modify the definition of the Sales Quote in order for it to read and store this new, non-standard information from a product. Normally, in Magento, all unique characteristics are described by one SKU and one Product ID. Having a 1-to-1 mapping of features to unique SKU is necessary, we are trying to target the organizations that have too many products to turn into unique products in the database.