Thursday, 26 December 2013

my account Login logout script in magento header

my account Login logout script in magento header


<?php
$loggedIn = $this->helper("customer")->isLoggedIn();
if($loggedIn == 1){ echo "<a href=\"".Mage::getBaseUrl()."customer/account/logout/\" />Logout</a>"; }
else{ echo "<a href=\"".Mage::getBaseUrl()."customer/account/\" />Login</a>"; }
?>

Show currency symbol in magento header

Show currency symbol in magento header

<?php echo Mage::app()->getLocale()->currency(Mage::app()->getStore()->getCurrentCurrencyCode())->getSymbol(); ?>


Thursday, 12 December 2013

Related product in view page in magento


Related product in view page in magento

Remove this line of code from catalog.xml
app/design/frontend/default/Your theme/layout/catalog.xml

<reference name="right">
<block type="catalog/product_list_related" name="catalog.product.related" before="-" template="catalog/product/list/related.phtml"/>
</reference>

and add below line of code above the upsell xml bloxk in catalog.xml

<block type="catalog/product_list_related" name="catalog.product.related" as="related_products" before="-" template="catalog/product/list/related.phtml"/>

add this line of cade in view.phtml above upsell block:-

app/design/frontend/default/Your theme/template/catalog/product/view.phtml

<?php echo $this->getChildHtml('related_products') ?>

How to enable language switcher with flag images


How to enable language switcher with flag images

First open the page.xml
app/design/frontend/default/YOURTHEME/layout/page.xml

and add the below line of code under

replace this
<block type="page/switch" name="store_language" as="store_language" template="page/switch/languages.phtml"/>

with
<block type="page/switch" name="store_language" as="store_language" template="page/switch/flags.phtml"/>
Now open the flags.phtml

app/design/frontend/default/YOURTHEME/template/page/switch/flags.phtml

replace this:-

<?php if(count($this->getStores())>1): ?>
<div class="form-language">
<label for="select-language"><?php echo $this->__('Your Language:') ?></label>
<select id="select-language" title="<?php echo $this->__('Your Language') ?>" onchange="window.location.href=this.value" class="flags">
<?php foreach ($this->getStores() as $_lang): ?>
<?php $_selected = ($_lang->getId() == $this->getCurrentStoreId()) ? ' selected="selected"' : '' ?>
<option value="<?php echo $_lang->getCurrentUrl() ?>" style="background-image:url('<?php echo $this->getSkinUrl('images/flags/flag_'.$_lang->getCode().'.gif') ?>');"<?php echo $_selected ?>><?php echo $this->htmlEscape($_lang->getName()) ?></option>
<?php endforeach; ?>
</select>
</div>
<?php endif; ?>

with:-

<?php if(count($this->getStores())>1): ?>
<li class="flag-flag">
<div class="" style="float:left;">
<?php foreach ($this->getStores() as $_lang): ?>
<?php $_selected = ($_lang->getId() == $this->getCurrentStoreId()) ? 'active' : '' ?>
<div style="float:left;" class="<?php echo $_selected ?>">
<a class="flag" href="<?php echo $_lang->getCurrentUrl() ?>"><img src="<?php echo $this->getSkinUrl('images/flags/flag_'.$_lang->getCode().'.png')?>" /></a></div>

<?php endforeach; ?></div>
</li>
<?php endif; ?>

Flag images are put in skin/frontend/default/[your skin]/images/flags/

How to show cart sidebar in header in magento

How to show cart sidebar in header in magento


add this section in checkout.xml
app/design/frontend/default/YOURTHEME/layout/checkout.xml

<reference name="header">
<block type="checkout/cart_sidebar" name="cart_sidebar" as="topCart" template="checkout/cart/sidebar.phtml" before="-">
<action method="addItemRender"><type>simple</type><block>checkout/cart_item_renderer</block><template>checkout/cart/sidebar/default.phtml</template></action>
<action method="addItemRender"><type>grouped</type><block>checkout/cart_item_renderer_grouped</block><template>checkout/cart/sidebar/default.phtml</template></action>
<action method="addItemRender"><type>configurable</type><block>checkout/cart_item_renderer_configurable</block><template>checkout/cart/sidebar/default.phtml</template></action>
<block type="core/text_list" name="cart_sidebar.extra_actions" as="extra_actions" translate="label" module="checkout">
<label>Shopping Cart Sidebar Extra Actions</label>
</block>
</block>
</reference>

like this :-

<reference name="right">
<block type="checkout/cart_sidebar" name="cart_sidebar" template="checkout/cart/sidebar.phtml" before="-">
<action method="addItemRender"><type>simple</type><block>checkout/cart_item_renderer</block><template>checkout/cart/sidebar/default.phtml</template></action>
<action method="addItemRender"><type>grouped</type><block>checkout/cart_item_renderer_grouped</block><template>checkout/cart/sidebar/default.phtml</template></action>
<action method="addItemRender"><type>configurable</type><block>checkout/cart_item_renderer_configurable</block><template>checkout/cart/sidebar/default.phtml</template></action>
<block type="core/text_list" name="cart_sidebar.extra_actions" as="extra_actions" translate="label" module="checkout">
<label>Shopping Cart Sidebar Extra Actions</label>
</block>
</block>
</reference>

add this line of code in header.phtml
app/design/frontend/default/fashion/template/page/html/header.phtml

<?php echo $this->getChildHtml('topCart'); ?>

Tuesday, 10 December 2013

Show product view count in product page in magento

Show product view count in product page in magento

add below line of code in view page:-
app/design/frontend/default/your theme/template/catalog/product/view.phtml

<?php

$id = $id=$_helper->productAttribute($_product, $_product->getId(), 'id');

$fromDate = '2013-12-10';
$toDate   = now();
$viewedProducts = Mage::getResourceModel('reports/product_collection')->addViewsCount($fromDate, $toDate);
foreach($viewedProducts as $product) {
if($product->getData('entity_id')==$id)
{
    echo  "Total View Count: " . $product->getData('views');
}}
?>


You are done!!!!

Show product wish-list count in product page in magento

Show product wish-list count in product page in magento:-

Add below line of code in view page:-

app/design/frontend/default/your theme/template/catalog/product/view.phtml

<?php
$resource = Mage::getSingleton('core/resource');
$readConnection = $resource->getConnection('core_read');
$productid = $_product->getId();
$total_wishlist = $readConnection->fetchCol("SELECT count(*) FROM wishlist_item where product_id = '$productid' ");
                                           
echo 'whishlist count:'.$total_wishlist['0'];
?>


You are done!!!

Monday, 9 December 2013

Add to cart button on upsell product page in magento

Add to cart button on upsell product page in magento

Add to cart button in upsell product page

to add "add to cart" button on upsell product page please open the upsell.phtml page:-

app/design/frontend/default/your theme/template/catalog/product/list/upsell.phtml


add below line of code in related .phtml page:-

<form action="<?php echo $this->getAddToCartUrl($_link) ?>" method="post" id="product_addtocart_form_<?php echo $_link->getId()?>"<?php if($_link->getOptions()): ?> enctype="multipart/form-data"<?php endif; ?>>
          <?php if(!$_link->isGrouped()): ?>
          <input type="text" name="qty" id="qty" maxlength="12" value="<?php echo ($this->getMinimalQty($_link)?$this->getMinimalQty($_link):20) ?>" />
          <label for="qty"><?php echo $this->__('Qty') ?>:</label>
          <?php endif; ?>
          <button type="button" onclick="this.form.submit()"><span><span><span><?php echo $this->__('Add to Cart') ?></span></span></span></button>
        </form>
Your are Done!!!!!!!!!!!!!!

Add to cart button in related product page in magento

Add to cart button in related product page in magento

to add "add to cart" button on related product page please open the related.phtml page:-

app/design/frontend/default/your theme/template/catalog/product/list/related.phtml


add below line of code in related .phtml page:-

<form action="<?php echo $this->getAddToCartUrl($_item) ?>" method="post" id="product_addtocart_form_<?php echo $_item->getId()?>"<?php if($_item->getOptions()): ?> enctype="multipart/form-data"<?php endif; ?>>

 <?php if(!$_item->isGrouped()): ?>
  <input type="text" name="qty" id="qty" maxlength="12" value="<?php echo ($this->getMinimalQty($_item)?$this->getMinimalQty($_item):1) ?>" />

  <label for="qty"><?php echo $this->__('Qty') ?>:</label>

 <?php endif; ?>

 <button type="button" onclick="this.form.submit()"><span><span><span><?php echo $this->__('Add to Cart') ?></span></span></span></button>
 </form>

Your are Done!!!!!!!!!!!!!!