Mounting Amazon S3 bucket on EC2 Instance

Posted on Updated on

Install required libraries :
sudo yum install -y gcc libstdc++-devel gcc-c++ fuse fuse-devel curl-devel libxml2-devel mailcap automake openssl-devel
git clone
cd s3fs-fuse/
./configure –prefix=/usr –with-openssl
sudo make install

Create password file with S3 identity and credential :
echo MYIDENTITY:MYCREDENTIAL > /home/ec2-user/s3fs-passwd
chmod 600 /home/ec2-user/s3fs-passwd

To make file accessible for other users as well(ie nginx user) :
sudo nano /etc/fuse.conf
uncomment “user_allow_other”

To mount :
s3fs bucketname /usr/share/nginx/html/project-name/sitemap/ -o passwd_file=/home/ec2-user/s3fs-passwd -o allow_other

To mount with debug :
s3fs bucketname /usr/share/nginx/html/project-name/sitemap/ -o passwd_file=/home/ec2-user/s3fs-passwd -d -d -f -o f2 -o curldbg -o allow_other


Mount on boot :
create the global credential file :
echo MYIDENTITY:MYCREDENTIAL > /etc/passwd-s3fs
chmod 600 /path/to/passwd

sudo nano /etc/fstab
mybucket /path/to/mountpoint fuse.s3fs _netdev,allow_other 0 0


Thankx for reading. Cheers!!!

Mystery of line break character in php file writes

Posted on

‘\n’ in single quotes is a literal \n. So you won’t see line breaks when you put \n within single quotes

file_put_contents(‘log.txt’, TEST\nTEST, FILE_APPEND);
Result in log.txt file :

“\n” in double quotes is interpreted as a line break. You will see the line breaks when you put \n within double quotes
file_put_contents(‘log.txt’, TEST\nTEST, FILE_APPEND);
Result in log.txt file :


For more info:

Thankx for reading. Cheers!!!

Useful Magento Extensions

Posted on Updated on

  1. Enhanced Admin Grids (+ Editor)
    Allow to customize a vast majority of the administration grids and add to it some useful features + an editor
  2. Magento Debug
    Debug toolbar for Magento
  3. Featured products
    Display list of featured products
  4. Pulse Storm Launcher
    The Pulse Storm Launcher is a fast, free, and fantastic productivity extension for the Magento admin console
  5. Online Magento Module Creator
    Magento Module Creator is a magento online module tool

Prestashop: Override Tools Class

Posted on

Recently, I tried overriding the meta tags on my homepage in one of my prestashop sites.
Here is what I did, made a new class in the folder overrides/classes/Tools.php and created
class Tools extends ToolsCore

I tried overriding the
public static function getHomeMetaTags
in my overridden class.

But something seemed to be wrong, and getHomeMetaTags function from the core parent class was being called instead of the child class’s getHomeMetaTags function.
After going through the code for a few hours, I found that the getHomeMetaTags was being called as self::getHomeMetaTags($id_lang, $page_name); in the function getMetaTags() in the parent.

So the problem was self::getHomeMetaTags($id_lang, $page_name); // PHP binds this to ToolsCore::getHomeMetaTags() right away
This would call the getHomeMetaTags function of the core class

So in order to override the getHomeMetaTags() function I also had to override the getMetaTags() function so that the self::getHomeMetaTags($id_lang, $page_name) function call in the child class would call the function of the same child Class.

To sum up, In order to override the static method getHomeMetaTags in child Tools class, you will also have to override the getMetaTags method as well in the child class.

Thank you for reading.
Hope this was helpful to you.

Magento: Get attribute Group Name of a product attribute

Posted on Updated on

The code below will get you the  attribute group name of a product attribute.
For eg. if you want to get the attribute group name “General” of a product attribute say “description”, the code below will do the job for you.

$resource = Mage::getSingleton('core/resource');
* Retrieve the read connection
$readConnection = $resource->getConnection('core_read');
$product = Mage::getModel('catalog/product')->load(15);// replace 15 with the required product Id
$attributeId = 117; // id of the product attribute
$attributeSetId = $product->getAttributeSetId();
$query = 'SELECT * FROM `' . $resource->getTableName('eav/entity_attribute')
.'` AS main_table JOIN `'
.'` AS group_table ON main_table.attribute_group_id = group_table.attribute_group_id WHERE attribute_id = "' 
. $attributeId
.'" and main_table.attribute_set_id = "'
. $attributeSetId . '"';
* Execute the query and store the results in $results
$results = $readConnection->fetchAll($query);

// gives you the name of the required group name
$attributeGroupName = $results[0]['attribute_group_name'];
echo $attributeGroupName;

Thank you for reading.
Hope this was helpful to you.

Magento : Redirect to a url from Event Observer Model

Posted on Updated on

//get the required url

$url = Mage::getUrl('checkout/cart');//eg to redirect to cart page

//get the http response object

$response = Mage::app()->getFrontController()->getResponse();

//set the redirect header to the response object


//send the response immediately and exit since there is nothing more to do with the current execution 🙂


Thank you for reading.
Hope this was helpful to you.

Regular Expression CheatSheat

Posted on Updated on

\d, \w, and \s match digit, word character, and whitespace
\D, \W, and \S (negate) match non-digt, non-word character, and non-whitespace
+ one or more times
* zero or more times (greedy)
*? zero or more times (lazy)
? zero or one time
^ matches beginning of line
$ matches end of line
{n,m} n to m times (inclusive), {n} exactly n times
[0-9] or [ABCdef] matches one character in set
[^0-9]+ leading circumflex (^) negates, so matches one or more non-digits
| match either pattern to left or pattern to right
() to define groups (referenced as $1, $2, …)
\ for literal next character — e.g., \? for literal question mark and \\ for backslash (\)