Pages

Wednesday, 7 January 2015

Mage_Eav_Model_Entity_Abstract setConnection() must be an instance of Zend_Db_Adapter_Abstract, string given

I got this error while I was installing a third party Magento module. Actually, the module was tested for higher Magento version than 1.4 and I had to install that module on Magento version 1.4.
Cause:
In older Magento versions, setConnection() function of Mage_Eav_Model_Entity_Abstract class expects the parameters only on Zend_Db_Adapter_Abstract type.
Whereas, in newer Magento version, setConnection() function of Mage_Eav_Model_Entity_Abstract class expects the parameters to be either Zend_Db_Adapter_Abstract or string type.
Solution:
Your line of code which resulted in this error might be like the one below:               
$this->setConnection('customer_read', 'customer_write');
You have to change it to:
$resource = Mage::getSingleton('core/resource');
$this->setConnection($resource->getConnection('customer_read'), $resource->getConnection('customer_write'));

Magento1.9 show minicart on mouse hover

Add the following jquery in
app/design/frontend/your_theme/default/template/checkout/cart/minicart.phtml
<script type="text/javascript">
jQuery(document).ready(function() {
    jQuery('.container').hover(function() {
        jQuery(this).children('#header-cart,.skip-cart').addClass("skip-active");
    }, function() {
        jQuery(this).children('#header-cart,.skip-cart').removeClass("skip-active");
    });        
});
</script>
minicart.phtml
<?php
    $_cartQty = $this->getSummaryCount();
    if(empty($_cartQty)) {
        $_cartQty = 0;
    }
?>
<div class="container">
<a href="#header-cart" class="skip-link skip-cart <?php if($_cartQty <= 0): ?> no-count<?php endif; ?>">
    <span class="icon"></span>
    <span class="label"><?php echo $this->__('Cart'); ?></span>
    <span class="count"><?php echo $_cartQty; ?></span>
</a>

<div id="header-cart" class="block block-cart skip-content">
    <?php echo $this->getChildHtml('minicart_content');?>
</div>
</div>
<script type="text/javascript">
jQuery(document).ready(function() {
    jQuery('.container').hover(function() {
        jQuery(this).children('#header-cart,.skip-cart').addClass("skip-active");
    }, function() {
        jQuery(this).children('#header-cart,.skip-cart').removeClass("skip-active");
    });        
});
</script>

Magento:: Display Shopping Cart in Header

Go to app\design\frontend\Your_theme\default\template\page\html\header.phtml
Add the following code inside the header-container div to display total number of items and price in header .
<?php
  $count = $this->helper('checkout/cart')->getSummaryCount();  //get total items in cart
  $total = $this->helper('checkout/cart')->getQuote()->getGrandTotal(); //get total price
  if($count==0)
  {
    echo $this->__('Items: %s',$count);
  }
  if($count==1)
  {
    echo $this->__(' Item: %s',$count);
  }
  if($count>1)
  {
    echo $this->__(' Items: %s',$count);
  }
  echo $this->__(' Total: %s', $this->helper('core')->formatPrice($total, false));
?>

Magento:: How to get cart items total

<?php echo Mage::helper('checkout/cart')->getItemsCount();?> // work in all version

<span class="count">
<?php echo Mage::helper('checkout/cart')->getSummaryCount();?> //magento 1.9
</span>

Friday, 2 January 2015

Magento:: Get Store Email Addresses

General Contact:
/* Sender Name */
Mage::getStoreConfig('trans_email/ident_general/name'); 
/* Sender Email */
Mage::getStoreConfig('trans_email/ident_general/email');
Sales Representative:
/* Sender Name */
Mage::getStoreConfig('trans_email/ident_sales/name'); 
/* Sender Email */
Mage::getStoreConfig('trans_email/ident_sales/email');
Customer Support:
/* Sender Name */
Mage::getStoreConfig('trans_email/ident_support/name'); 
/* Sender Email */
Mage::getStoreConfig('trans_email/ident_support/email');
Custom Email 1:
/* Sender Name */
Mage::getStoreConfig('trans_email/ident_custom1/name'); 
/* Sender Email */
Mage::getStoreConfig('trans_email/ident_custom1/email');
Custom Email 2:
/* Sender Name */
Mage::getStoreConfig('trans_email/ident_custom2/name'); 
/* Sender Email */
Mage::getStoreConfig('trans_email/ident_custom2/email');