Magento Selling clothing (or anyother product with options) while having Magento keep track of stock

Creating confugurable products is more work than adding custom attributes but it might be better in some cases (keeping track of stock, having one set of attributes to select from etc).

In short the steps needed are

  1. Create the attributes that will be configurable by the user – for our example they will be Size and Color
  2. Create the attribute set that will be assigned to the variant products – for our example, we’ll call it “T-shirt”
  3. Create the individual variant products
  4. Create the configurable product, and add the “T-shirt” attribute set
  5. Add the individual variants to this configurable product

Create the attributes that will be configurable by the user – for our example they will be Size and Color
In the adminpanel this is under Catalog->Attributes->Manage Attributes
Scope needs to be set to Global and Input type to drop down. Once this is done then Use To Create Configurable Product is shown and this should be set to yes. Setting required to yes is a good idea as well.

Under label / options create a label (for instance size) and give the different options it can take.

Repeat for all attributes you want to create (for instance size and color)

Create the attribute set that will be assigned to the variant products – for our example, we’ll call it “T-shirt”
Now we’re ready to create an attribute set called “T-shirt” to start using for this product. Go to “Catalog -> Attributes -> Manage Attribute Sets” and press “Add New Set”.
Give the new set a name and then drag and drop the attributes to the group where you want them to be when creating a product.

Create the individual variant products
Create a product and make sure that you use the attribute set you have created. Add the attributes where you placed them.


Repeat for all the products you have

Create the configurable product, and add the “T-shirt” attribute set

Add the individual variants to this configurable product
This can be done when the configurable product is created or later on using edit product.

And then it should look something like this in the shop

Magento Selling clothing (or another product with options) without having Magento keep track of stock

Some products have a number of options that are important for the customer to select.
Here I show how to make a product with options (color and size) where Magento only sees one product – so it won’t it will not be possible to see how many large in red you have from Magento.

When you create a product in the admin panel there is a label Custom Options.


Use “Add new option” to make the option (color, size or whatnot)
Then for each of the options use add new row to add the deferent values that the option can have.
The column labeled price is for adding a extra cost for a option (if for instance the red shirt should be more expensive).

Then this will look something like this in the store

Then only down sides I have seen with this is that I have to add the options one time for each of the products (but that is also nice since not all products have the same values) and that Magento will treat this as one single product so I can’t let Magento manage the stock for this/these products.

Magento redirect

Sometimes there is a need to do a redirect from inside a Magento page where you might not know if headers are sent or not – Or maybe you wish to make a new redirect function where you don’t have to worry about writing different code if the headers are sent or not.

This is a way to do a redirect where a javascript redirect is used if headers have been sent (and thus it is no longer possible to use a header redirect)

if (!headers_sent()) {
 
	Mage::app()->getResponse()->setRedirect(Mage::getBaseUrl() . 'portal/');
 
}
 
else {
 
	$baseUrl = Mage::getBaseUrl() . 'portal/';
 
	print '<script type="text/javascript">';
 
	print "window.location.href = '{$baseUrl}';";
 
	print '</script>';
 
}

And the function headers_sent() is a php function so that can of course be used outside of Magento in any php scrip where a header location is nice but not always possible.

OpenX INSERT_RANDOM_NUMBER_HERE example in php

For iframe’s and noscript tags OpenX uses a random string in the image in order to prevent user caching of banners (as that would mean less impressions and possibly outdated ads).
However these tags needs to be added by the user.
An example way to make these random numbers using PHP would be to use

<?php echo rand();?>

So an complete example invocation code would be

<a href="http://www.example.com/ck.php?n=3798N2&cb=<?php echo rand();?>" _fcksavedurl="http://www.example.com/ck.php?n=3798N2&cb=<?php echo rand();?>" _fcksavedurl="http://www.example.com/ck.php?n=3798N2&cb=<?php echo rand();?>" 
<img src="http://www.example.com/avw.php?zoneid=10&n=3798N2&cb=<?php echo rand(); ?>"></a>

Merging personal fabrication and distributed manufacturing.

Another step of the open source 3D printing revolution might be to merge personal fabrication and distributed manufacturing.

Someone produces a model of a custom part that he/she needs produced and then asks the community to produce it (an example of this at thingiverse, a custom part made by Ponskaartje.

I think this is a very nice idea that might get the 3d printing/personal fabrication revolution rolling even faster.

Also I hope that we will start seeing more of this and perhaps even a marketplace that can make this happen (where a user asks for a part and sets some limits on it, and users might bid on making this part) like the sites where for instance programming tasks are put up and the developers have to bid on the task and the one asking chooses the best option.

Magento: Problem uploading images

When I was truing to upload images to products in the Magento admin panel I got the following error:
SSL Error: Invalid or self-signed certificate while uploading image from backend

The way I solved this issue was by setting the timezone on the computer that I was uploading from to the same timezone as the settings in Magento.

Other suggestions to try out if that don’t work:

  • If you are using certificate: Verify that it is valid, you have correct domains etc
  • Set use secure url in admin to false

PostgreSQL 8.3 adding uuid-ossp on Debian

UUID is a nice way to generate (almost) unique id’s.

However on PostgreSQL 8.3 the data type exists, but if you wish to be able to generate UUID’s you need to get a module (in this case uuid-ossp).

On Debian this module is in the contrib package, so if you have not installed this before do it now

user@server:~$ sudo apt-get install postgresql-contrib

Then you need to “load” the module into PostgreSQL; or more accurately you tell PostgreSQL about the new functions this module has, how to reach them etc.
Depending on you security settings (in pg_hba.conf) you may need to log in as the postgres user on your system.

postgres@sever:~$ psql -d MYDB -U postgres -f /usr/share/postgresql/8.3/contrib/uuid-ossp.sql

Ubuntu Hibernate/Suspend problem

First off, quick explanation.
Suspend saves a image to ram. It is faster to save and reload; but the computer uses a minimal amount of energy to keep this in ram. If the power is lost (battery is drained etc) then the image is lost.
Hibernate save a image to disk. It is slightly slower to save and reload; but there is no problem if the power is lost.

However I am not the only one that have noticed that hibernate/suspend on Ubuntu does not work on a default installation.
One solution that more than me have found to be working is to switch to uswsusp.

user@laptop$ sudo apt-get install uswsusp
user@laptop$ sudo s2disk

s2disk does a hibernation (s2ram does a suspend); and it is good to test it out before swapping the hibernate/suspend function.
When you know hibernate/suspend works, you can swap to using uswsusp by using:

user@laptop$ sudo dpkg-divert --rename --divert /usr/sbin/pmi-disabled /usr/sbin/pmi

If you later on would like to swap back you can use

user@laptop$ sudo dpkg-divert --rename --remove /usr/sbin/pmi