Getting Configurable Product from Simple Product ID in Magento 1.5+

I recently stumbled across a hurdle which stopped some of my code from working. It was code that gets the configurable product associated with a given simple product. Many solutions out there call a “loadParentProductIds()” function within the Mage_Catalog_Model_Product class. However, as of Magento 1.4.2.0, they deprecated this method, simply by setting the data element (and returning) an empty array. So any calls to this function would return/yield no parents. Hm, how to get the parent product now?

Finally, I managed to find a workable solution. Check this out;

$simpleProductId = 465;
$parentIds = Mage::getResourceSingleton('catalog/product_type_configurable')
                  ->getParentIdsByChild($simpleProductId);
$product = Mage::getModel('catalog/product')->load($parentIds[0]);
echo $product->getId(); // ID = 462 (aka, Parent of 465)

There you have it. Short and sweet.

Adding multiple products to the cart simultaneously in Magento (Part 2)

A while ago I wrote about adding multiple products to the shopping cart simultaneously. It turns out this seems to have stopped working from Magento 1.4 or so. Up until now, I’ve not really had the time to look in detail to figure out why. Finally, this evening, I got some time. So I dug deeper.

It turns out there seems to have been some changes in the way models persist their data, and unsetting and unloading/resetting them didn’t seem to cut it any more. Anyway, below is a fixed version of the previous post. Tested on 1.4.2.0 and 1.6.0.0.

This is a replacement for the file app/code/local/BTS/AddMultipleProducts/controllers/AddController.php;

getRequest()->getParam('products'));
        $cart = Mage::getModel('checkout/cart');
        $cart->init();
        /* @var $pModel Mage_Catalog_Model_Product */
        foreach ($products as $product_id) {
            if ($product_id == '') {
                continue;
            }
            $pModel = Mage::getModel('catalog/product')->load($product_id);
            if ($pModel->getTypeId() == Mage_Catalog_Model_Product_Type::TYPE_SIMPLE) {
                try {
                    $cart->addProduct($pModel, array('qty' => '1'));
                }
                catch (Exception $e) {
                    continue;
                }
            }
        }
        $cart->save();
        if ($this->getRequest()->isXmlHttpRequest()) {
            exit('1');
        }
        $this->_redirect('checkout/cart');
    }

}

Amazon EC2 Elastic Load Balancer limit

If, like us, you’re running a shared hosting platform on Amazon EC2, and have many clients requiring SSL certificates, you’ll probably be using Elastic Load Balancers to do the SSL termination for you, since you can’t have multiple Elastic IP’s associated with a single instance.

However, when you reach either 5 or 10 ELB’s, you’ll be greeted with this error message when trying to create another one:

Error: TooManyLoadBalancers: undefined

Amazon define relatively low quotas for new AWS accounts, which are usually fine for most users. However, some use cases apply where you need these limits to be increased. The problem with the ELB limit, is that there’s not very much documentation explaining that there is a limit, nor how to request to increase it. The answer lies hidden away here on Amazon’s AWS site. This is the form you need to fill in to request an increase on the account’s ELB limit.

Adding new attribute to Customer Account in Magento

I recently discovered that this is a right pig to get going. There’s plenty of “solutions” on the interwebs. Many seemingly either don’t work, don’t work as expected, or are complete hacks which makes your extension not modular (i.e; by executing the “addAttribute” function within a template, then removing it once it’s done).

Here’s how I did it. Continue reading “Adding new attribute to Customer Account in Magento” »

Speeding Up Internet Access with Firefox

I stumbled across a post earlier today, and I thought it was far too rich and useful not to share. This post isn’t for the faint hearted, as a wrong click on a configuration key not mentioned here could impair Firefox’s performance, or worse, stop it working completely.

By following these instructions, you agree I have no liability whatsoever if something goes pear-shaped because you clicked on something you shouldn’t have!

With that said..

  • In Firefox; navigate to “about:config”. Click the “I’ll be careful” button (last warning!). You’ll be greeted with a load of configuration options.
  • Set the following values for the keys specified (use the search box at the top of the page to find the key. Searching for “network.http.max” will return the top 3 keys).
    • network.http.max-connections-per-server: 25
    • network.http.max-persistent-connections-per-proxy: 25
    • network.http.max-persistent-connections-per-server: 25
    • network.http.pipelining: true (just double click where it says “false” to change it to true)
    • network.http.pipelining.maxrequests: 8
    • network.http.pipelining.ssl: true
    • network.http.proxy.pipelining: true

Setting these values alone, I saw a huge increase in how fast pages loaded. If you have any other tips for speeding up your Firefox, please comment! I’d love to know other people’s experiences using these, and any other methods (whether good or bad).