Tuesday, November 27, 2012
Add Want Button to your site
Use script
<script>
(function() {
var _w = document.createElement("script"); _w.type = "text/javascript"; _w.async = true;
_w.src = "http://button.wanttt.com/button/script/";
var s = document.getElementsByTagName("script")[0]; s.parentNode.insertBefore(_w, s);
})();
</script>
<a href="http://wanttt.com/want/initial_popup/"
data-merchant_name="ESCAPED_MERCHANT_NAME"
data-title="ESCAPED_PRODUCT_NAME"
data-price="PRODUCT_PRICE"
data-image_url="HIGH_RESOLUTION_PRODUCT_IMAGE_URL"
data-count="true"
data-style="wb1" data-page_source="PRODUCT" class="wantButton"></a>
or go to http://wantbutton.com/code.html
Tuesday, November 6, 2012
show plain text in a password field and then make it a regular password field on focus
Use html as
<input type="text" value="password" id="password">
And use script
jQuery( document ).ready( function(){
jQuery( document ).delegate( "#password", "focusin focusout",
function(e){
var elm = jQuery( "#password" )[0];
if( e.type == "focusin" && elm.type == "text" ) {
jQuery( elm ).replaceWith( jQuery( "<input>", {id: "password", type:"password", value:"" } ) );
jQuery( "#password")[0].focus();
}
else if( e.type =="focusout" && elm.type == "password" && !elm.value ) {
jQuery( elm ).replaceWith( jQuery( "<input>", {id: "password", type:"text", value:"password" } ) );
}
}
);
});
<input type="text" value="password" id="password">
And use script
jQuery( document ).ready( function(){
jQuery( document ).delegate( "#password", "focusin focusout",
function(e){
var elm = jQuery( "#password" )[0];
if( e.type == "focusin" && elm.type == "text" ) {
jQuery( elm ).replaceWith( jQuery( "<input>", {id: "password", type:"password", value:"" } ) );
jQuery( "#password")[0].focus();
}
else if( e.type =="focusout" && elm.type == "password" && !elm.value ) {
jQuery( elm ).replaceWith( jQuery( "<input>", {id: "password", type:"text", value:"password" } ) );
}
}
);
});
Labels:
html,
Javascript
Thursday, October 25, 2012
Creating virtual host in ubuntu
Suppose, the configuration file name is domain.com and local IP address is 127.0.0.1. Type following command in terminal
gksudo gedit /etc/apache2/sites-available/domain.com
Add following lines in configuration file
<VirtualHost 127.0.0.1:80>
DocumentRoot /var/www/test
ServerName domain.com
ServerAlias test.domain.com
ServerAdmin admin@domain.com
</VirtualHost>
Save and close it. Then create a symbolic link of this configuration file to /etc/apache2/sites-enabled directory in order to enable it
cd /etc/apache2/sites-enabled/
sudo ln -s ../sites-available/domain.com .
Then, add a virtual domain with a specific local IP to hosts file that is located in /etc/hosts. You can also add the port using a colon with the IP.
sudo nano /etc/hosts
add this line
127.0.0.1 test.domain.com
Save and close it. After all restart the apache service.
gksudo gedit /etc/apache2/sites-available/domain.com
Add following lines in configuration file
<VirtualHost 127.0.0.1:80>
DocumentRoot /var/www/test
ServerName domain.com
ServerAlias test.domain.com
ServerAdmin admin@domain.com
</VirtualHost>
Save and close it. Then create a symbolic link of this configuration file to /etc/apache2/sites-enabled directory in order to enable it
cd /etc/apache2/sites-enabled/
sudo ln -s ../sites-available/domain.com .
Then, add a virtual domain with a specific local IP to hosts file that is located in /etc/hosts. You can also add the port using a colon with the IP.
sudo nano /etc/hosts
add this line
127.0.0.1 test.domain.com
Save and close it. After all restart the apache service.
Labels:
Ubuntu
Magento : MySQL commands to clear all orders
SET FOREIGN_KEY_CHECKS=0;
TRUNCATE `sales_order`;
TRUNCATE `sales_order_datetime`;
TRUNCATE `sales_order_decimal`;
TRUNCATE `sales_order_entity`;
TRUNCATE `sales_order_entity_datetime`;
TRUNCATE `sales_order_entity_decimal`;
TRUNCATE `sales_order_entity_int`;
TRUNCATE `sales_order_entity_text`;
TRUNCATE `sales_order_entity_varchar`;
TRUNCATE `sales_order_int`;
TRUNCATE `sales_order_text`;
TRUNCATE `sales_order_varchar`;
TRUNCATE `sales_flat_quote`;
TRUNCATE `sales_flat_quote_address`;
TRUNCATE `sales_flat_quote_address_item`;
TRUNCATE `sales_flat_quote_item`;
TRUNCATE `sales_flat_quote_item_option`;
TRUNCATE `sales_flat_order_item`;
TRUNCATE `sendfriend_log`;
TRUNCATE `tag`;
TRUNCATE `tag_relation`;
TRUNCATE `tag_summary`;
TRUNCATE `wishlist`;
TRUNCATE `log_quote`;
TRUNCATE `report_event`;
ALTER TABLE `sales_order` AUTO_INCREMENT=1;
ALTER TABLE `sales_order_datetime` AUTO_INCREMENT=1;
ALTER TABLE `sales_order_decimal` AUTO_INCREMENT=1;
ALTER TABLE `sales_order_entity` AUTO_INCREMENT=1;
ALTER TABLE `sales_order_entity_datetime` AUTO_INCREMENT=1;
ALTER TABLE `sales_order_entity_decimal` AUTO_INCREMENT=1;
ALTER TABLE `sales_order_entity_int` AUTO_INCREMENT=1;
ALTER TABLE `sales_order_entity_text` AUTO_INCREMENT=1;
ALTER TABLE `sales_order_entity_varchar` AUTO_INCREMENT=1;
ALTER TABLE `sales_order_int` AUTO_INCREMENT=1;
ALTER TABLE `sales_order_text` AUTO_INCREMENT=1;
ALTER TABLE `sales_order_varchar` AUTO_INCREMENT=1;
ALTER TABLE `sales_flat_quote` AUTO_INCREMENT=1;
ALTER TABLE `sales_flat_quote_address` AUTO_INCREMENT=1;
ALTER TABLE `sales_flat_quote_address_item` AUTO_INCREMENT=1;
ALTER TABLE `sales_flat_quote_item` AUTO_INCREMENT=1;
ALTER TABLE `sales_flat_quote_item_option` AUTO_INCREMENT=1;
ALTER TABLE `sales_flat_order_item` AUTO_INCREMENT=1;
ALTER TABLE `sendfriend_log` AUTO_INCREMENT=1;
ALTER TABLE `tag` AUTO_INCREMENT=1;
ALTER TABLE `tag_relation` AUTO_INCREMENT=1;
ALTER TABLE `tag_summary` AUTO_INCREMENT=1;
ALTER TABLE `wishlist` AUTO_INCREMENT=1;
ALTER TABLE `log_quote` AUTO_INCREMENT=1;
ALTER TABLE `report_event` AUTO_INCREMENT=1;
-- reset customers
TRUNCATE `customer_address_entity`;
TRUNCATE `customer_address_entity_datetime`;
TRUNCATE `customer_address_entity_decimal`;
TRUNCATE `customer_address_entity_int`;
TRUNCATE `customer_address_entity_text`;
TRUNCATE `customer_address_entity_varchar`;
TRUNCATE `customer_entity`;
TRUNCATE `customer_entity_datetime`;
TRUNCATE `customer_entity_decimal`;
TRUNCATE `customer_entity_int`;
TRUNCATE `customer_entity_text`;
TRUNCATE `customer_entity_varchar`;
TRUNCATE `log_customer`;
TRUNCATE `log_visitor`;
TRUNCATE `log_visitor_info`;
ALTER TABLE `customer_address_entity` AUTO_INCREMENT=1;
ALTER TABLE `customer_address_entity_datetime` AUTO_INCREMENT=1;
ALTER TABLE `customer_address_entity_decimal` AUTO_INCREMENT=1;
ALTER TABLE `customer_address_entity_int` AUTO_INCREMENT=1;
ALTER TABLE `customer_address_entity_text` AUTO_INCREMENT=1;
ALTER TABLE `customer_address_entity_varchar` AUTO_INCREMENT=1;
ALTER TABLE `customer_entity` AUTO_INCREMENT=1;
ALTER TABLE `customer_entity_datetime` AUTO_INCREMENT=1;
ALTER TABLE `customer_entity_decimal` AUTO_INCREMENT=1;
ALTER TABLE `customer_entity_int` AUTO_INCREMENT=1;
ALTER TABLE `customer_entity_text` AUTO_INCREMENT=1;
ALTER TABLE `customer_entity_varchar` AUTO_INCREMENT=1;
ALTER TABLE `log_customer` AUTO_INCREMENT=1;
ALTER TABLE `log_visitor` AUTO_INCREMENT=1;
ALTER TABLE `log_visitor_info` AUTO_INCREMENT=1;
-- Reset all ID counters
TRUNCATE `eav_entity_store`;
ALTER TABLE `eav_entity_store` AUTO_INCREMENT=1;
SET FOREIGN_KEY_CHECKS=1;
TRUNCATE `sales_order`;
TRUNCATE `sales_order_datetime`;
TRUNCATE `sales_order_decimal`;
TRUNCATE `sales_order_entity`;
TRUNCATE `sales_order_entity_datetime`;
TRUNCATE `sales_order_entity_decimal`;
TRUNCATE `sales_order_entity_int`;
TRUNCATE `sales_order_entity_text`;
TRUNCATE `sales_order_entity_varchar`;
TRUNCATE `sales_order_int`;
TRUNCATE `sales_order_text`;
TRUNCATE `sales_order_varchar`;
TRUNCATE `sales_flat_quote`;
TRUNCATE `sales_flat_quote_address`;
TRUNCATE `sales_flat_quote_address_item`;
TRUNCATE `sales_flat_quote_item`;
TRUNCATE `sales_flat_quote_item_option`;
TRUNCATE `sales_flat_order_item`;
TRUNCATE `sendfriend_log`;
TRUNCATE `tag`;
TRUNCATE `tag_relation`;
TRUNCATE `tag_summary`;
TRUNCATE `wishlist`;
TRUNCATE `log_quote`;
TRUNCATE `report_event`;
ALTER TABLE `sales_order` AUTO_INCREMENT=1;
ALTER TABLE `sales_order_datetime` AUTO_INCREMENT=1;
ALTER TABLE `sales_order_decimal` AUTO_INCREMENT=1;
ALTER TABLE `sales_order_entity` AUTO_INCREMENT=1;
ALTER TABLE `sales_order_entity_datetime` AUTO_INCREMENT=1;
ALTER TABLE `sales_order_entity_decimal` AUTO_INCREMENT=1;
ALTER TABLE `sales_order_entity_int` AUTO_INCREMENT=1;
ALTER TABLE `sales_order_entity_text` AUTO_INCREMENT=1;
ALTER TABLE `sales_order_entity_varchar` AUTO_INCREMENT=1;
ALTER TABLE `sales_order_int` AUTO_INCREMENT=1;
ALTER TABLE `sales_order_text` AUTO_INCREMENT=1;
ALTER TABLE `sales_order_varchar` AUTO_INCREMENT=1;
ALTER TABLE `sales_flat_quote` AUTO_INCREMENT=1;
ALTER TABLE `sales_flat_quote_address` AUTO_INCREMENT=1;
ALTER TABLE `sales_flat_quote_address_item` AUTO_INCREMENT=1;
ALTER TABLE `sales_flat_quote_item` AUTO_INCREMENT=1;
ALTER TABLE `sales_flat_quote_item_option` AUTO_INCREMENT=1;
ALTER TABLE `sales_flat_order_item` AUTO_INCREMENT=1;
ALTER TABLE `sendfriend_log` AUTO_INCREMENT=1;
ALTER TABLE `tag` AUTO_INCREMENT=1;
ALTER TABLE `tag_relation` AUTO_INCREMENT=1;
ALTER TABLE `tag_summary` AUTO_INCREMENT=1;
ALTER TABLE `wishlist` AUTO_INCREMENT=1;
ALTER TABLE `log_quote` AUTO_INCREMENT=1;
ALTER TABLE `report_event` AUTO_INCREMENT=1;
-- reset customers
TRUNCATE `customer_address_entity`;
TRUNCATE `customer_address_entity_datetime`;
TRUNCATE `customer_address_entity_decimal`;
TRUNCATE `customer_address_entity_int`;
TRUNCATE `customer_address_entity_text`;
TRUNCATE `customer_address_entity_varchar`;
TRUNCATE `customer_entity`;
TRUNCATE `customer_entity_datetime`;
TRUNCATE `customer_entity_decimal`;
TRUNCATE `customer_entity_int`;
TRUNCATE `customer_entity_text`;
TRUNCATE `customer_entity_varchar`;
TRUNCATE `log_customer`;
TRUNCATE `log_visitor`;
TRUNCATE `log_visitor_info`;
ALTER TABLE `customer_address_entity` AUTO_INCREMENT=1;
ALTER TABLE `customer_address_entity_datetime` AUTO_INCREMENT=1;
ALTER TABLE `customer_address_entity_decimal` AUTO_INCREMENT=1;
ALTER TABLE `customer_address_entity_int` AUTO_INCREMENT=1;
ALTER TABLE `customer_address_entity_text` AUTO_INCREMENT=1;
ALTER TABLE `customer_address_entity_varchar` AUTO_INCREMENT=1;
ALTER TABLE `customer_entity` AUTO_INCREMENT=1;
ALTER TABLE `customer_entity_datetime` AUTO_INCREMENT=1;
ALTER TABLE `customer_entity_decimal` AUTO_INCREMENT=1;
ALTER TABLE `customer_entity_int` AUTO_INCREMENT=1;
ALTER TABLE `customer_entity_text` AUTO_INCREMENT=1;
ALTER TABLE `customer_entity_varchar` AUTO_INCREMENT=1;
ALTER TABLE `log_customer` AUTO_INCREMENT=1;
ALTER TABLE `log_visitor` AUTO_INCREMENT=1;
ALTER TABLE `log_visitor_info` AUTO_INCREMENT=1;
-- Reset all ID counters
TRUNCATE `eav_entity_store`;
ALTER TABLE `eav_entity_store` AUTO_INCREMENT=1;
SET FOREIGN_KEY_CHECKS=1;
Labels:
Magento
Wednesday, October 3, 2012
Magento : add massDelete action in coupon code
First override Mage_Adminhtml_Block_Promo_Quote_Grid class and add following code
protected function _prepareMassaction()
{
$this->setMassactionIdField('rule_id');
$this->getMassactionBlock()->setFormFieldName('rule');
$this->getMassactionBlock()->addItem('delete', array(
'label' => Mage::helper('rule')->__('Delete'),
'url' => $this->getUrl('*/*/massDelete'),
'confirm' => Mage::helper('rule')->__('Are you sure?')
));
return $this;
}
then override Mage_Adminhtml_Promo_QuoteController class and add following code
public function massDeleteAction()
{ //exit;
$rulesIds = $this->getRequest()->getParam('rule');
if(!is_array($rulesIds)) {
Mage::getSingleton('adminhtml/session')->addError(Mage::helper('adminhtml')->__('Please select rule(s).'));
} else {
try {
$model = Mage::getModel('salesrule/rule');
foreach ($rulesIds as $rulesId) {
//echo $rulesId; exit;
$model->load($rulesId);
$model->delete();
}
Mage::getSingleton('adminhtml/session')->addSuccess(
Mage::helper('adminhtml')->__(
'Total of %d record(s) were deleted.', count($rulesIds)
)
);
} catch (Exception $e) {
Mage::getSingleton('adminhtml/session')->addError($e->getMessage());
}
}
$this->_redirect('*/*/index');
}
protected function _prepareMassaction()
{
$this->setMassactionIdField('rule_id');
$this->getMassactionBlock()->setFormFieldName('rule');
$this->getMassactionBlock()->addItem('delete', array(
'label' => Mage::helper('rule')->__('Delete'),
'url' => $this->getUrl('*/*/massDelete'),
'confirm' => Mage::helper('rule')->__('Are you sure?')
));
return $this;
}
then override Mage_Adminhtml_Promo_QuoteController class and add following code
public function massDeleteAction()
{ //exit;
$rulesIds = $this->getRequest()->getParam('rule');
if(!is_array($rulesIds)) {
Mage::getSingleton('adminhtml/session')->addError(Mage::helper('adminhtml')->__('Please select rule(s).'));
} else {
try {
$model = Mage::getModel('salesrule/rule');
foreach ($rulesIds as $rulesId) {
//echo $rulesId; exit;
$model->load($rulesId);
$model->delete();
}
Mage::getSingleton('adminhtml/session')->addSuccess(
Mage::helper('adminhtml')->__(
'Total of %d record(s) were deleted.', count($rulesIds)
)
);
} catch (Exception $e) {
Mage::getSingleton('adminhtml/session')->addError($e->getMessage());
}
}
$this->_redirect('*/*/index');
}
Magento : lazyloading in catloag page
Download lazyload js from below link
http://www.appelsiini.net/projects/lazyload
And save in js/lazyload/jquery.lazyload.js
Then create lazyload.phtml in template/lazyload/lazyload.phtml with following code
<script type="text/javascript" charset="utf-8">
jQuery("img").load(function(){if(jQuery(this).attr("src")!=="<?php echo Mage::getBaseUrl(Mage_Core_Model_Store::URL_TYPE_MEDIA); ?>blank.png"){jQuery(this).removeAttr("height")}});
jQuery(function() {
jQuery("img").lazyload({
effect : "fadeIn",
});
});
</script>
And add following code in catalog.xml
<reference name="head">
<action method="addJs"><script>jquery.lazyload.min.js"></script></action>
</reference>
<reference name="after_body_start">
<block type="core/template" template="lazyloader/lazyload.phtml" name="lazyloader_init" />
</reference>
Remember that jquery must be included in site.
http://www.appelsiini.net/projects/lazyload
And save in js/lazyload/jquery.lazyload.js
Then create lazyload.phtml in template/lazyload/lazyload.phtml with following code
<script type="text/javascript" charset="utf-8">
jQuery("img").load(function(){if(jQuery(this).attr("src")!=="<?php echo Mage::getBaseUrl(Mage_Core_Model_Store::URL_TYPE_MEDIA); ?>blank.png"){jQuery(this).removeAttr("height")}});
jQuery(function() {
jQuery("img").lazyload({
effect : "fadeIn",
});
});
</script>
And add following code in catalog.xml
<reference name="head">
<action method="addJs"><script>jquery.lazyload.min.js"></script></action>
</reference>
<reference name="after_body_start">
<block type="core/template" template="lazyloader/lazyload.phtml" name="lazyloader_init" />
</reference>
Remember that jquery must be included in site.
Labels:
Javascript,
Magento
Subscribe to:
Comments (Atom)