Amazon Web Services – A Guide to Implementation

I realise that I’ve been neglecting my blog for a while now, with my last post published at the end of March. Quite frankly, I’ve not had anything interesting to write about. However, career starting pastures new, I’m starting to have interesting things to write about again. Over the course of time, I’ll probably post a lot of stuff about Amazon Web Services (AWS), Zend Framework, amongst other things. Today’s babble though is about implementing AWS as your core hosting infrastructure, and the benefits and downsides to it. I’ll also post my findings about the best way (in my opinion) to implement certain requirements.

Continue reading “Amazon Web Services – A Guide to Implementation” »

Outlook 2010 not storing passwords

I recently came across a problem with Microsoft Office Outlook 2010 on Windows 7 whereby it didn’t seem to be saving passwords when connecting to Microsoft Exchange (2007, at least). Now, I’ve used Outlook 2010 on Windows 7 before, and it saved the passwords a treat. Some people seemed to suggest it was architecture related (x86 Office on x64 Windows), but others seems to have the problem on x64 Office on x64 Windows 7 (which is where I came about the issue).

Continue reading “Outlook 2010 not storing passwords” »

(Not very) Surprising revelation about Magento

So eBay has come out of it’s shell and exclaimed that it owns 49% of Varien, having invested $22.5m in the Magento project.

That explains why the Paypal module is so tightly integrated within Magento, and is so much more powerful than anyone else could possibly think of making another payment module. Even Google Checkout’s implementation is nowhere near as powerful. And since Google owns the world (or most of it)..

Update: As of June 6th 2011, eBay now owns 100% of Magento Inc.. They’re talking about integrating it with eBay’s own X.Commerce initiative, which will be revealed to developers in October 2011. What that means for Magento, I’m not too sure. Usually, large take-overs like this involve some kind of product overhaul, or ditching in favour of the taking-over company’s own products. I don’t think this is the end of the line for Magento, but I think in the next 12-18 months, we’ll see a massive change in Magento as a whole product.

Getting value of Attribute Option and adding a new Attribute Option in Magento

This, I find, is a hard one to come across. At least, trying to find a sensible solution that just spits out a numerical value which, more often than not, is all you want. Needing to get the value of an option from a multi-option/dropdown attribute. Try this:

public function getAttributeOptionValue($arg_attribute, $arg_value) {
    $attribute_model        = Mage::getModel('eav/entity_attribute');
    $attribute_options_model= Mage::getModel('eav/entity_attribute_source_table') ;

    $attribute_code         = $attribute_model->getIdByCode('catalog_product', $arg_attribute);
    $attribute              = $attribute_model->load($attribute_code);

    $attribute_table        = $attribute_options_model->setAttribute($attribute);
    $options                = $attribute_options_model->getAllOptions(false);

    foreach($options as $option) {
        if ($option['label'] == $arg_value) {
            return $option['value'];
        }
    }

    return false;
}

And use it as such:

$optionValue = $this->getAttributeOptionValue("size", "XL");

where “size” is the attribute name/ID in the database, and “XL” is the exact label belonging to the option you need to get. Likewise, if you need to add a new option to the attribute’s list, use this:

public function addAttributeOption($arg_attribute, $arg_value) {
    $attribute_model        = Mage::getModel('eav/entity_attribute');
    $attribute_options_model= Mage::getModel('eav/entity_attribute_source_table') ;

    $attribute_code         = $attribute_model->getIdByCode('catalog_product', $arg_attribute);
    $attribute              = $attribute_model->load($attribute_code);

    $attribute_table        = $attribute_options_model->setAttribute($attribute);
    $options                = $attribute_options_model->getAllOptions(false);

    $value['option'] = array($arg_value,$arg_value);
    $result = array('value' => $value);
    $attribute->setData('option',$result);
    $attribute->save();

    return $this->getAttributeOptionValue($arg_attribute, $arg_value);
}

and use as such:

$optionValue = $this->addAttributeOption("size", "XXL");

again, where “size” is the attribute name/ID, and “XXL” is the label of the new option required. It returns the value of the option it just added incase it’s needed. Bear in mind that this function doesn’t first check to see if the label already exists as an option, so you should probably use $this->getAttributeOption() first and only run $this->addAttributeOption() upon a false return.

It’s probably not the most efficient way of doing it, but if efficiency is what you really need, $options could be cached/saved so that the DB/model is only every queried once across both functions within the same model.

Amazon S3 CDN distribution for Menalto Gallery 3 v2.1 released

Announcing the release of the Amazon S3 v2.1 module for Gallery 3. A few changes are presented here;

  • Firstly, started using double digits for version numbers so I can create minor revisions
  • Added fields to database to store MD5 hashes of files. These are used to match the MD5 hash of the local file, and what the module thinks is uploaded, and also for comparison with S3 itself (which provides an MD5 hash when asked for bucket info)
  • Re-visited re-sync task. Taken out “emptying bucket” code (as there’s really no need it seems), and simplified the whole process, allowing the module to compare the MD5 hash of the local file against the same file path on S3, and upload/overwrite if they’re different, or if the module doesn’t believe the file has been uploaded.
  • Resolved issues of moving entire albums from one location to another and files disappearing. This invoked a re-visit of the move code as well and cleaned up quite a lot of unnecessary stuff.

Download the latest version here: [download id=”20″ format=”3″]
As always, direct comments, feedback and bug reports to the module’s official thread on Gallery’s forums.

Note: I will no longer be updating the gallery3-contrib git repository as it’s just easier to update my site than it is to update a load of other places and wait for pulls to be granted. Sorry.