Wednesday, 31 October 2012

Redirecting www to non-www Using .htaccess

The Apache Web server supports URL rewriting with the mod_rewrite engine. Placing custom rules in an .htaccess file lets you do all sorts of useful things to keep your URLs tidy. One really handy thing you can do for search engines and visitors is redirecting traffic from www to non-www version of your domain (and vice versa).


Some people prefer to use www.somesite.com, but some people prefer the shorter somesite.com. There isn't really a right or wrong way to do it, but whatever you choose you can make sure all of your visitors get sent to the same place. With a few simple rules on the server you can choose from non-www to www, or redirecting from www to non-www.

If you already have a file named .htaccess on your Website you can add to it. If not, create one (yes, include the period at the beginning). Add either of the following rules and save. Replace yourdomain.com with your actual domain name.

Redirect www to non-www:
RewriteEngine On
RewriteBase /
RewriteCond %{HTTP_HOST} ^www.yourdomain.com [NC]
RewriteRule ^(.*)$ http://yourdomain.com/$1 [L,R=301]


Redirect non-www to www:
RewriteEngine On
RewriteBase /
RewriteCond %{HTTP_HOST} ^yourdomain.com [NC]
RewriteRule ^(.*)$ http://www.yourdomain.com/$1 [L,R=301]


Both of these rules send a full search engine friendly 301 HTTP redirect. They also preserve the entire URL (so yoursite.com/about redirects to www.yoursite.com/about).

Search engines can usually figure out which format is preferred, but since you're showing the same page for www and non-www URLs it can't hurt to be consistent about it.

Create your .htaccess rewrite code:
Use our www Redirect Generator tool to automatically generate the required redirect code.

Magento product details store tablename

Product name store in : catalog_product_entity_varchar
product id store in : catalog_product_entity_int
product price store in : catalog_product_entity_decimal

How to Call Newsletter in footer in Magento

To show Newsletter in footer go to app/design/frontend/default/YourTheme/layout/newsletter.xml and add the following lines in default
<reference name="footer">
<block type="newsletter/subscribe" name="footer.newsletter"

template="newsletter/subscribe.phtml"/>
</reference>

and add the following line in app/design/frontend/default/YourTheme/template/page/html/footer.phtml
<?php echo $this->getChildHtml('footer.newsletter'); ?>

Remove Category option from Layered Navigation options list in magnto

This is what I did to remove the “Category” section from my layered navigation so I wouldnt have any repeat information with the attributes I wanted in the layered navigation.
go to app/design/frontend/default/default/template/catalog/layer and open up view.phtml for edit.
 


<dl id="narrow-by-list"><?php $_filters = $this->getFilters() ?>
<?php foreach ($_filters as $_filter): ?>
<?php if($_filter->getItemsCount()): ?>
<?php if($_filter->getName() != "Category"){ ?><dt><?php echo $this->__($_filter->getName()) ?></dt>
<dd><?php echo $_filter->getHtml() ?></dd><?php } endif; ?>
<?php endforeach; ?></dl>

Removing dropdowns from Product List Pager in magnto

1. Open up template/catalog/product/list/toolbar.phtml, and look for the “Sort By” div. Completely replace the select and dropdown options with:
<?php foreach($this->getAvailableOrders() as $_key=>$_order): ?>
<a href=”<?php echo $this->getOrderUrl($_key, ‘asc’) ?>” ><?php echo $this->__($_order) ?></a>
<?php endforeach; ?>

2. In the same file, look for the “Limiter” div and replace with:
<div class=”limiter”>
<label><?php echo $this->__(‘Show’) ?></label>
<?php foreach ($this->getAvailableLimit() as $_key=>$_limit): ?>
<a href=”<?php echo $this->getLimitUrl($_key) ?>”><?php echo $_limit ?></a>
<?php endforeach; ?>
<?php echo $this->__(‘per page’) ?>
</div>

Magento: Get store information

Get store data
Mage::app()->getStore();

Store Id
Mage::app()->getStore()->getStoreId();

Store code
Mage::app()->getStore()->getCode();

Website Id
Mage::app()->getStore()->getWebsiteId();

Store Name
Mage::app()->getStore()->getName();

Is Active
Mage::app()->getStore()->getIsActive();

Store Home Url
Mage::app()->getStore()->getHomeUrl();

Delete all Products and ResetProduct id’s in Magento

TRUNCATE TABLE `catalog_product_bundle_option`; 

TRUNCATE TABLE `catalog_product_bundle_option_value`; 

TRUNCATE TABLE `catalog_product_bundle_selection`; 

TRUNCATE TABLE `catalog_product_entity_datetime`;

TRUNCATE TABLE `catalog_product_entity_decimal`;

TRUNCATE TABLE `catalog_product_entity_gallery`; 

TRUNCATE TABLE `catalog_product_entity_int`;

TRUNCATE TABLE `catalog_product_entity_media_gallery`;

TRUNCATE TABLE `catalog_product_entity_media_gallery_value`;

TRUNCATE TABLE `catalog_product_entity_text`;

TRUNCATE TABLE `catalog_product_entity_tier_price`; 

TRUNCATE TABLE `catalog_product_entity_varchar`;

TRUNCATE TABLE `catalog_product_link`; 

TRUNCATE TABLE `catalog_product_link_attribute`;

TRUNCATE TABLE `catalog_product_link_attribute_decimal`; 

TRUNCATE TABLE `catalog_product_link_attribute_int`; 

TRUNCATE TABLE `catalog_product_link_attribute_varchar`; 

TRUNCATE TABLE `catalog_product_link_type`; 

TRUNCATE TABLE `catalog_product_option`; 

TRUNCATE TABLE `catalog_product_option_price`; 

TRUNCATE TABLE `catalog_product_option_title`; 

TRUNCATE TABLE `catalog_product_option_type_price`;

TRUNCATE TABLE `catalog_product_option_type_title`; 

TRUNCATE TABLE `catalog_product_option_type_value`;

TRUNCATE TABLE `catalog_product_super_attribute`;

TRUNCATE TABLE `catalog_product_super_attribute_label`;

TRUNCATE TABLE `catalog_product_super_attribute_pricing`;

TRUNCATE TABLE `catalog_product_super_link`; 

TRUNCATE TABLE `catalog_product_enabled_index`; 

TRUNCATE TABLE `catalog_product_website`;

TRUNCATE TABLE `catalog_product_entity`;
 TRUNCATE TABLE `cataloginventory_stock`;

TRUNCATE TABLE `cataloginventory_stock_item`;

TRUNCATE TABLE `cataloginventory_stock_status`;

Truncate all categories and and Reset Categoryt id’s in Magento

TRUNCATE TABLE `catalog_category_entity`;TRUNCATE TABLE `catalog_category_entity_datetime`;
TRUNCATE TABLE `catalog_category_entity_decimal`;TRUNCATE TABLE `catalog_category_entity_int`; 
TRUNCATE TABLE `catalog_category_entity_text`;TRUNCATE TABLE `catalog_category_entity_varchar`; 
TRUNCATE TABLE `catalog_category_product`;TRUNCATE TABLE `catalog_category_product_index`;

Magento: How to solve indexing problem?

open your phpmyadmin.and run below given Query in sql tab.



DROP TABLE IF EXISTS `index_process_event`;
DROP TABLE IF EXISTS `index_event`;
DROP TABLE IF EXISTS `index_process`;


CREATE TABLE `index_event` (
`event_id` BIGINT(20) UNSIGNED NOT NULL AUTO_INCREMENT,
`type` VARCHAR(64) NOT NULL,
`entity` VARCHAR(64) NOT NULL,
`entity_pk` BIGINT(20) DEFAULT NULL,
`created_at` DATETIME NOT NULL,
`old_data` MEDIUMTEXT,
`new_data` MEDIUMTEXT,
PRIMARY KEY (`event_id`),
UNIQUE KEY `IDX_UNIQUE_EVENT` (`type`,`entity`,`entity_pk`)
) ENGINE=INNODB DEFAULT CHARSET=utf8;

CREATE TABLE `index_process` (
`process_id` INT(10) UNSIGNED NOT NULL AUTO_INCREMENT,
`indexer_code` VARCHAR(32) NOT NULL,
`status` ENUM('pending','working','require_reindex') NOT NULL DEFAULT 'pending',
`started_at` DATETIME DEFAULT NULL,
`ended_at` DATETIME DEFAULT NULL,
`mode` ENUM('real_time','manual') NOT NULL DEFAULT 'real_time',
PRIMARY KEY (`process_id`),
UNIQUE KEY `IDX_CODE` (`indexer_code`)
) ENGINE=INNODB DEFAULT CHARSET=utf8;

INSERT INTO `index_process`(`process_id`,`indexer_code`,`status`,`started_at`,`ended_at`,`mode`) VALUES (1,'catalog_product_attribute','pending','2010-02-13 00:00:00','2010-02-13 00:00:00','real_time'),(2,'catalog_product_price','pending','2010-02-13 00:00:00','2010-02-13 00:00:00','real_time'),(3,'catalog_url','pending','2010-02-13 19:12:15','2010-02-13 19:12:15','real_time'),(4,'catalog_product_flat','pending','2010-02-13 00:00:00','2010-02-13 00:00:00','real_time'),(5,'catalog_category_flat','pending','2010-02-13 00:00:00','2010-02-13 00:00:00','real_time'),(6,'catalog_category_product','pending','2010-02-13 00:00:00','2010-02-13 00:00:00','real_time'),(7,'catalogsearch_fulltext','pending','2010-02-13 00:00:00','2010-02-13 00:00:00','real_time'),(8,'cataloginventory_stock','pending','2010-02-13 00:00:00','2010-02-13 00:00:00','real_time');

CREATE TABLE `index_process_event` (
`process_id` INT(10) UNSIGNED NOT NULL,
`event_id` BIGINT(20) UNSIGNED NOT NULL,
`status` ENUM('new','working','done','error') NOT NULL DEFAULT 'new',
PRIMARY KEY (`process_id`,`event_id`),
KEY `FK_INDEX_EVNT_PROCESS` (`event_id`),
CONSTRAINT `FK_INDEX_EVNT_PROCESS` FOREIGN KEY (`event_id`) REFERENCES `index_event` (`event_id`) ON DELETE CASCADE ON UPDATE CASCADE,
CONSTRAINT `FK_INDEX_PROCESS_EVENT` FOREIGN KEY (`process_id`) REFERENCES `index_process` (`process_id`) ON DELETE CASCADE ON UPDATE CASCADE
) ENGINE=INNODB DEFAULT CHARSET=utf8;

Magento Database Connection

$sql = Mage::getSingleton('core/resource')->getConnection('core_write');
$result = $sql->query("SELECT class_name from tax_class");

while ($row = $result->fetch(PDO::FETCH_ASSOC)) {
echo $row['class_name']."<br />";
}

my authorize.net details

Authorize.net Zip

 

Tuesday, 23 October 2012

Redirect site from non-www to www

RewriteCond %{HTTP_HOST} !^www\.
RewriteRule ^(.*)$ http://www.%{HTTP_HOST}/$1 [R=301,L]

Thursday, 11 October 2012

How to integrate datepicker in magento backend side

magento_admin_date_picker

 

Date function in PHP

echo(“Result with date():”);
echo(date(“l”) . “”);
echo(date(“l dS \of F Y h:i:s A”) . “”);
echo(“Oct 3,1975 was on a “.date(“l”, mktime(0,0,0,10,3,1975)).””);
echo(date(DATE_RFC822) . “”);
echo(date(DATE_ATOM,mktime(0,0,0,10,3,1975)) . “”);


echo(“Result with gmdate():”);
echo(gmdate(“l”) . “”);
echo(gmdate(“l dS \of F Y h:i:s A”) . “”);
echo(“Oct 3,1975 was on a “.gmdate(“l”, mktime(0,0,0,10,3,1975)).””);
echo(gmdate(DATE_RFC822) . “”);
echo(gmdate(DATE_ATOM,mktime(0,0,0,10,3,1975)) . “”);


 


 


Output:


Result with date():
Tuesday
Tuesday 24th of January 2006 02:41:22 PM
Oct 3,1975 was on a Friday
Tue, 24 Jan 2006 14:41:22 CET
1975-10-03T00:00:00+0100


Result with gmdate():
Tuesday
Tuesday 24th of January 2006 01:41:22 PM
Oct 3,1975 was on a Thursday
Tue, 24 Jan 2006 13:41:22 GMT
1975-10-02T23:00:00+0000

Wednesday, 10 October 2012

Add twitter button on product detail page in magento

<a href="http://twitter.com/share" data-count="vertical">Tweet</a>

<script type="text/javascript" src="http://platform.twitter.com/widgets.js"></script>

 

<a href="http://twitter.com/share" data-count="horizontal">Tweet</a>

<script type="text/javascript" src="http://platform.twitter.com/widgets.js"></script>

 

<a href="http://twitter.com/share" data-count="none">Tweet</a>

<script type="text/javascript" src="http://platform.twitter.com/widgets.js"></script>

 

Add facebook like button on product detail page in magento

<p><?php $currentUrl = $this->helper('core/url')->getCurrentUrl(); ?><br />
<script src="http://connect.facebook.net/en_US/all.js#xfbml=1"></script><fb:like href="<?php echo $currentUrl ?>" show_faces="false" width="450" font=""></fb:like>

 

<?php $currentUrl = $this->helper('core/url')->getCurrentUrl(); ?>
<iframe src="http://www.facebook.com/plugins/like.php?href=<?php echo $currentUrl ?>&amp;layout=standard&amp;show_faces=true&amp;width=450&amp;action=like&amp;font&amp;colorscheme=light&amp;height=80" scrolling="no" frameborder="0" style="border:none; overflow:hidden; width:450px; height:80px;" allowTransparency="true"></iframe>

 

<?php $currentUrl = $this->helper('core/url')->getCurrentUrl();  ?>
<script src="http://connect.facebook.net/en_US/all.js#xfbml=1"></script><fb:like href="<?php echo $currentUrl ?>" layout="button_count" show_faces="true" width="450" font=""></fb:like></p>

 

<p><?php $currentUrl = $this->helper('core/url')->getCurrentUrl(); ?><br />
<iframe src="http://www.facebook.com/plugins/like.php?href=<?php echo $currentUrl ?>&amp;layout=button_count&amp;show_faces=true&amp;width=450&amp;action=like&amp;font&amp;colorscheme=light&amp;height=21" scrolling="no" frameborder="0" style="border:none; overflow:hidden; width:450px; height:21px;" allowTransparency="true"></iframe></p>

Magento Hint Websites

http://www.wpbeginner.com/wp-themes/wordpress-theme-cheat-sheet-for-beginners/
http://ivvy.ru/en/bloggy
http://sushilshirbhate.wordpress.com/2011/07/07/magento-theme-development-cheat-sheet/
http://magento4u.wordpress.com/2011/03/28/add-extra-fields-in-registration-page/
http://www.magento.cc/custom-accountregistration-fields.html
http://www.magento.cc/category/magento/cms
http://www.magento.cc/category/magento/module
http://www.pauldonnellydesigns.com/blog/magento-display-address-fields-in-create-an-account/
http://www.excellencemagentoblog.com/magento-blogs/
http://www.itoris.com/magento-ajax-login-registration.html
http://www.magentoworks.net/magento-extension
http://www.cutehits.com/2011/07/overriding-core-controller-in-magento/
http://nickwan.wordpress.com/
http://blog.ecommercesoftwaresolutionsonline.com/archives/category/magento-developer-notes
http://oaktondata.com
http://wordcastnet.com/2009/speed-up-wordpress-with-google-gears-and-the-turbo-feature/
http://kb.magenting.com/category/5/general-configuration.html
http://www.webspeaks.in/2011/03/override-controllers-in-magento.html
http://learntipsandtricks.com/blog/magento/149/How-to-enable-Address-Information-on-Magento-Customer-Registration-Page
http://www.phptechi.com/category/php/magento
http://www.westwideweb.com/wp/page/4/
http://ultimento.com/wiki/blog/
http://xhtmlandcsshelp.blogspot.in/
http://xhtmlandcsshelp.blogspot.in/search?updated-max=2010-11-30T19:48:00%2B05:30&max-results=10&start=50&

by-date=false
http://alanstorm.com/category/magento
http://dbhoopendra.blogspot.in/search/label/Magento
http://www.learnmagento.org/magento-tutorials/how-to-install-sample-data-in-a-magento-site/#
http://www.devraju.com/category/magento/
http://www.johannreinke.com/en/category/php/magento/
http://www.webspeaks.in/
http://magentoshare.blogspot.in/
http://www.fmeextensions.com/
http://blog.magentoconnect.us/page/3/
http://blog.ecommercesoftwaresolutionsonline.com/archives/1036/magento-how-to-place-facebook-like-and-twitter-buttons-

in-the-products-view-page.html