logo
Dec
6

Better way to load layout blocks outside of Magento

Better way to load layout blocks outside of Magento For loading Magento Layout Blocks externally or in a controller without any complexity, use this: From external file, we need to initiate Magento session: Mage::getSingleton(‘core/session’, array(‘name’=>’frontend’)); $session = Mage::getSingleton(‘customer/session’, array(‘name’=>’frontend’)); $layout =...
Sep
27

How to configure libstdc++ with GCC 4.8?

You need to tell your dynamic linker (it’s executed when you run your program) where to find the library. Set LD_LIBRARY_PATH to the path of the library (probably somewhere under /app/gcc/4.8.0/lib or something). Use find /app/gcc/4.8.0 -name “libstdc++.so.6″. Add the directory to your LD_LIBRARY_PATH. e.g with the path I mentioned: export...
Sep
11

Openresty : Programming with Magento/Mysql – Get Inventory of Products REST API

Skills Requried – LUA, nginx, mysql If you have nginx-openresty installed, open the vhost file of your domain, than follow this: Let your REST API path is http://<your-domain>.com/getstockserv?p=123450,12145 where p is the parameter where all product ids of Magento Products has been supplied. Now add this entry to the vhost file - location ^~ /getstockserv { content_by_lua ‘ local mysql =...
Sep
9

How to add a Volume to EC2 Instance?

How to add a Volume to EC2 Instance? Go to EC2 console to create the volume and attach it to the instance, and then we’ll mount the volume to make it available. - under Elastic Block Store, click Volumes. - Click on Create Volume – Select the General Purpose (SSD) volume type. - Wait for your Volume to be available. - Right click on it and select Attach Volume, Select the instance and specify an unused device name say...
Sep
4

How to make nginx works with Geo IP?

How to make nginx works with Geo IP? NGINX GeoIP Installation: Follow these steps to install GeoIP with nginx: wget http://geolite.maxmind.com/download/geoip/api/c/GeoIP.tar.gz tar -zxvf GeoIP.tar.gz cd GeoIP-1.4.8/ ./configure make make install echo ‘/usr/local/lib’ > /etc/ld.so.conf.d/geoip.conf yum install gcc pcre-devel.x86_64 openssl-devel.x86_64 yum install readline-devel pcre-devel openssl-develWe are using openresty...
Aug
7

Nginx Openresty Get/Set Cookies using LUA.

Nginx Openresty Get/Set Cookies using LUA. To set cookies using lua while using nginx_lua module in openresty/nginx server, use this code: local expires = 3600 * 24  — 1 day ngx.header["Set-Cookie"] = “session=demo; Path=/; Expires=” .. ngx.cookie_time(ngx.time() + expires) This will set cookie session = demo for 1 day from current time on path /.
Aug
5

Use PHP Functions in LUA Code

Use PHP Functions in LUA Code explode Based on [PHP explode] Example: explode(” and “,”one and two and three and four”) –> {“one”,”two”,”three”,”four”} Compatibility: Lua 5.0 and 5.1function explode(div,str) if (div==”) then return false end local pos,arr = 0,{} – for each divider found for st,sp in function() return...
Aug
4

Purge redis keys in matching pattern

After logging in to linux shell execute this command redis-cli KEYS “*$1*” | xargs redis-cli DEL where $1 is the argument/string which you need to find. E.g.   redis-cli KEYS “*test*” | xargs redis-cli DEL where test is a string you need to search for.  
Aug
3

Mysql get size of tables in a database

To find the detail of size of tables in a database use this query in mysql console: SELECT table_name AS “Tables”, round(((data_length + index_length) / 1024 / 1024), 2) “Size in MB” FROM information_schema.TABLES WHERE table_schema = “$DB_NAME” ORDER BY (data_length + index_length) DESC; E.g. for database name mydatabase : SELECT table_name AS...
Aug
1

Nginx Proxy requests are redirecting to upstream name.

If you are using nginx as a reverse proxy and having the redirection issues to upstream name when proxy request results in 301,302 redirects, e.g. http://www.mind-geek.net/new.html is proxied by backend upstream i.e. upstream backend { server 54.21.42.13:80; } location / { proxy_pass http://backend; } and the requests are getting ended eith http://backend/new.html, than you need to sepecify the...
Jul
31

How to add indexer in a Custom Module?

Follow these steps: config.xml: <index>                        <indexer> <cms_indexer> <model>module/cmsindexer</model> </cms_indexer> </indexer> </index> Model: app/code/local/Name/Module/Model/Cmsindexer.php Class Module_Model_CmsIndexer extends Mage_Index_Model_Indexer_Abstract { public function getName(){ return ‘Add CMS...
Jul
30

What is configure, make, make install ?

There are lot of confusions for usual configure, make, make install sequence to get a program running in Linux. Unfortunately, most developers today have never used a compiler to install an application and used the GUI application builders. The make utility is designed to decrease a programmer’s need to remember line of commands. I guess that is actually the good way of saying, it decreases a...
Jul
29

How to Enable Password Authentication in Amazon EC2 Instances?

Edit the ssh configuration file - # vim /etc/ssh/sshd_config Change PasswordAuthentication to yes from no to enbable login via clear text passwords. Here is the snippet: # Change to no to disable tunnelled clear text passwords PasswordAuthentication yes Save and close the File. Restart ssh service – service sshd restart Voila, Now, you can login using the user account and passwords on same...
Jul
17

Set timezone of Mysql Server

Many times timezone issues with your database server causes wrong information to be entered in reports, transaction tables etc. To fix timezone issues with your mysql server, just login to your mysql and execute following query: SET GLOBAL time_zone = ‘<REQUIRED TIMZONE>; E.g. SET GLOBAL time_zone = ‘+5:30′; If you have to get the  current timezone, use this- SELECT TIMEDIFF(NOW(),...
Dec
25

Nginx show/set real ip address(public) from Amazon ELB Load Balancer address

To make it work, we need to add following lines to nginx configuration file: real_ip_header X-Forwarded-For; set_real_ip_from 0.0.0.0/0; It makes nginx to trust an X-Forwarded-For header from anyone, which makes Real Ip visible on logs and can be used in other programs where real ip is required.
Dec
9

Nginx allow cross domain ajax requests

To enable Nginx for Cross Origin calls add this in nginx configuration for the domain  : location /{ add_header ‘Access-Control-Allow-Origin’ ‘http://subdomain.mind-geek.net’; add_header ‘Access-Control-Allow-Credentials’ ‘true’; add_header ‘Access-Control-Allow-Methods’ ‘GET’; } That’s it, it will enable GET requests from http
Aug
6

Automate Magento Image Cache – Don’t let your website down when catalog image cache is flushed!

Problem - How to remove Magento Image Cache selectively, when you need to replace existing images and Clicking “Flush Catalog Image Cache” on Magento Cache Management will empty the cache folder which consumes lot of cpu plus memory, and for replacing few images Magento will generate all product images (say for replacing 2 product images it will remove all your 3000 product catalog image...
May
21

Magento Inventory Management – Desktop Tool

Download Magento Desktop Tool allows you to easily manage inventory on your Magento Store.   This application allows Store Owners to update product stock on their website. It also allows user to setup a  Gmail(Google) SMTP A/c so that they will get a copy of uploaded stock csv file, which allows them to keep record of stock updation over their store. Download here. Requirements: - Magennto API...
Apr
18

Remove Double Extensions in Linux

  Following script will help you to remove double extensions which can be added by some programs or by user mistakes and need to be corrected in bulk. Here is the solution, You have to perform this in the current working directory (non-recursively). vim fix_extension.sh Content of fix_extension.sh #!/bin/bash echo "Existing Extension" $1 echo "Converted Extension" $2 for file in *$1 do mv "${file}"...
Apr
10

Check Application Memory usage using simple command

To check the total amount of memory used by any program’s child processes: Create a shell script # vim checkmem.sh Contents: echo “————————————-Memory Checkup————————————”; ps -ylC $1 –sort:rss | awk ‘!/RSS/ { s+=$8 } END { printf...

« Previous Entries

logo