So, new computer means setting up the development environment again. Here’s what I’m setting up today:
Netbeans PHP – as an alternative to trusty old JEdit
jruby 64 bit (32 bit ruby doesn’t work with vagrant)
a Debian VM
a debian .box file presetup for vagrant
vagrant – for provisioning VMs and handling host networking nicely
The plan: get xdebug going sensibly in a local environment.
The script mentioned previously is here:
It’ll tell you whether your configurable attributes are set sensibly based on how many values there are. Note it assumes size and color as attributes you care about – you can change that on line 38 if you want.
So I was writing a script to check the integrity of configurable products on a couple of sites – it appeared that the attributes on some products didn’t match the actual set of child products available, so you had weird results like dropdowns with 1 color available.
It worked okay on a site with 250 active configurable products, but ran out of memory quickly on a site with 1000. What was going on?
It turns out that this line:
$attributes = $product->getTypeInstance()->getConfigurableAttributesAsArray($product);
consumed 0.5-2MB of memory for each product – what’s happening is that the Configurable type singleton is storing the configurable attribute data on the $product that we pass into that method, in order to reuse it later. If we’re not planning on doing anything else with that product (eg it’s from a collection we’re looping through), this is just wasted.
To remove all the stuff the above method adds to the product,