Good way to connect database in Phalcon php framework

Database connection settings can be done by registering services in the container.
Here is how we can connect a postgresql database

Make image to base64 dataUri in NodeJS

Images are already in server, may be uploaded by multer. now have to make dataUri for s3.

Magento truncate a table

Truncating may needed if you want to reset all your module data, In your tables Mage_Core_Model_Resource_Db_Abstract model add a function truncate

Call the truncate when needed

Change/Override Base Url from local.xml of Magento

For ‘default’ store
Open /app/etc/local.xml
Add just before closing tag.

Magento Re-Install Extension by Script

Create a file reinstall.php in magneto’s root directory and run by url yoursite.com/reinstall.php
Sometimes it helps to fix broken installation of any extension.

Quick Install Apache PHP Mysql for Magento on Ubuntu

Continue reading Quick Install Apache PHP Mysql for Magento on Ubuntu

Set a value as selected in select dropdown custom admin form in Magento

I found this in Varien_Data_Form_Element_Select which generates the select option html

Find: with in same form file

Add line before:

if your form have no setValues() function just add value in addField like this

option with value 2 will be selected.

Magento Memcache Install, Magento performance optimization

Memcache really makes magento site faster
Memcache is a caching system that holds database objects and data in RAM, so system doesn’t have to make slow database calls to pull data.

it is strongly recommended for magento stores, you know magento is kinda slow thing.

Install Memcached in magento on Ubuntu is very easy.

Continue reading Magento Memcache Install, Magento performance optimization

Magento Switch Store by Customer Group

It’s really nice when you have many customer group and want to show different products to each customer group. This can be done by creating stores in Magento to view different products in each store and dedicate a store for a customer group.

On a Multi Store Magento site where you have many customer group and want to bind customer groups with stores. we can do it by redirecting a customer to a store after login by detecting customer group.

Continue reading Magento Switch Store by Customer Group

Magento Redirect Category link to CMS page, CMS page in Top menu by URL rewrite management

Sometime I have to add article content page and external url in Magento’s top navigation menu. This can be done without using any third-party extension. I have my own menu extension ready for any projects but when menu is not complex and all themes styling are ready for default navigation I use default Navigation.

Magneto have a built-in way to Add any URL in to Magento’s default catalog category top navigation.

Here is how it works:

There is some features in admin panel’s Catalog -> URL rewrite management to work with urls generated by magento when we are adding products, category etc.  I use this to point a category url to cms-page or any.

Lets say I want to add “Home” and “Contact Us” in top menu.
And “Home” is a CMS page which have url /home and “Contact Us” is the default contact form in /contacts

Step 1:
Create Category “Home” and “Contact” (Yes, Category)
from admin Catalog -> ‘Manage Categories’ and keep note of both category ids
make sure thus categories are visible in front-end top menu.

Continue reading Magento Redirect Category link to CMS page, CMS page in Top menu by URL rewrite management

Magento Sort Products by Attribute Set

To Sort Products by Attribute Set, Update the default toolbar files

Mage/Catalog/block/Product/List/Toolbar.php

Continue reading Magento Sort Products by Attribute Set

Magento do something when Order is Complete

Do something when any order is complete or invoice paid by Magento observer

or

Magneto database CRUD

In magento a model is required to perform SQL query in your database tables.
Sort data:

Or Condition:

Continue reading Magneto database CRUD

Magento Quick Snippets

Cart Counter:

Continue reading Magento Quick Snippets