Showing posts with label Magento. Show all posts
Showing posts with label Magento. Show all posts

Thursday, 23 June 2016

Add to Wishlist Link in Magento

<a href="<?php echo $this->helper('wishlist')->getAddUrl($_product) ?>"
 data-toggle="tooltip" data-placement="top" title="Add to Wishlist">

Add to Cart Button or link in Magento

<!--  Link -->

<a href="<?php echo Mage::helper('checkout/cart')->getAddUrl($_product); ?>"
data-toggle="tooltip"  title="Add to Cart">
Add to Cart
</a>

<!-- Button -->

 <button type="button" title="<?php echo $this->__('Add to Cart') ?>"
onclick="setLocation('<?php echo Mage::helper('checkout/cart')->getAddUrl($_product); ?>')"><span><?php echo $this->__('Add to Cart') ?></span></button>

Tuesday, 17 May 2016

My Account URL in Magento

<li> <a href="<?php echo Mage::getUrl('customer/account'); ?>" title="<?php echo $this->__('My Account'); ?>"><?php echo $this->__('My Account'); ?></a></li>

Monday, 25 January 2016

Get recently viewed products on any page in Magento

I.Place the below code below in any template where you want to add (in.phtml file)

 <?php echo $this->getLayout()->createBlock('reports/product_viewed')->setTemplate('reports/product_viewed.phtml')->toHtml(); ?>


II.Place code  below in any Backend CMS  => page or static block


{{block type="reports/product_viewed" template="reports/product_viewed.phtml"}}

Friday, 22 January 2016

Get Product attributes Value in Magento

 <?php
//call on any page and any place
 $attribute_code ="139";
echo $attribute_value = $product->getResource()->getAttribute($attribute_code)->getFrontend()->getValue($_product);
 ?>


//On Catalog Page

<?php $_product = $this->getProduct(); ?>

<?php echo $_product->getData('attributename'); ?>


//On List page
To display a product manufactures attribute on the product list page

Go Admin -> Catalog -> Attributes -> Manage Attributes

Set "Used in Product Listing" to Yes

Then in 'list.phtml'

 <?php echo $_product->getAttributeText('manufacturer') ?>

Get Custom attribute value by name

<?php  echo $attributeValue = Mage::getModel('catalog/product')
      ->load($_product->getId())
      ->getAttributeText('attributename');
       ?>

Set Product Limit on Collection in Magento

$collection = $category->getProductCollection();
$collection->getSelect()->limit(4);

Thursday, 21 January 2016

Add Logout Link in Header Topbar in Magento

  <?php if (Mage::helper('customer')->isLoggedIn() ){ ?>
  <a href="<?php echo Mage::helper('customer')->getLogoutUrl(); ?>"><?php echo 'Log Out'; ?></a>
                             <?php } else { ?>
                         
   <a href="<?php echo $this->helper('customer')->getAccountUrl(); ?>" > <?php echo "Login"; ?></a>
<?php } ?>

Display Pagination On Product List Page in Magento

<div class="pager">
<?php echo $this->getToolbarBlock()->setHideSorter(false)->setHidePager(true)->toHtml();
?>
</div>

Get Products Final Price with Currency Symbol in Magento

<?php
 echo Mage::helper(‘core’)->currency($this->helper(‘tax’)->getPrice($_product, $_product->getFinalPrice()),true,false);
?>

Friday, 11 December 2015

Remove categories from product URLs in Magento

You can prevent these paths from being generated in the first place - there's a setting in the admin:

System > Configuration > Catalog > Catalog > Use Categories Path for Product URLs:

Wednesday, 9 December 2015

Custom search box in magento on homepage

//.phtml file

<?php echo $this->getLayout()->createBlock('core/template')->setTemplate('catalogsearch/form.mini.phtml')->toHtml(); ?>

// in CMS page

{{block type="core/template" name="top-search" as="top-search" template="catalogsearch/form.mini.phtml"}}

//customize search box as per you need

path         =   app/design/frontend/rwd/tt/template/catalogsearch/

filename  =    form.mini.phtml file 

Thursday, 3 December 2015

Get recently added product in Magento

 <?php
$_helper = $this->helper('catalog/output');
$_productCollection = Mage::getResourceModel('reports/product_collection')
                ->addAttributeToSelect('*')
                ->setVisibility(array(2,3,4))                
                ->setOrder('created_at', 'desc')
                ->setPageSize(10);
$count = $_productCollection->count();
?>

    <div class="item active">
    <?php
        $i=0;
        $flag=false;
        foreach($_productCollection as $product)
        {
            if($i<3)
            {
            ?>
         <a href="#">
                        <img src="<?php echo $product->getImageUrl();?>" alt="PHPCluster">
                    </a>
              <h3><a href="<?php echo $product->getUrlPath();?>"> <?php echo $product->getName();?></a></h3>
            <?php
$i++;
            } } ?>
</div>    

Tuesday, 1 December 2015

Get CMS Page details by Page Id in Magento

Get Page tilte


echo Mage::getModel('cms/page')->load(3)->getTitle();  // Here 3 is page id of about us CMS page


Get Page Url


echo Mage::helper('cms/page')->getPageUrl(3) ; // Here 3 is page id of about us CMS page


Get Page content


echo Mage::getModel('cms/page')->load(3)->getContent(); // Here 3 is page id of about us CMS page



Get excerpt


$content = Mage::getModel('cms/page')->load(3)->getContent(); //  Here 3 is page id of about us CMS page
$excerpt = strip_tags(substr($content,0,300));  // Here300 is character length.
echo $excerpt;

how to disable cache in magento

1> System > Cache Management
2> Disable all cache
3> click on submit button

Get list of main Category on listing page by default category ID in Magento

Get list of main Category on product listing page by passing default category ID
************************************************************************
<?php
$parentCategoryId = 2;
$children = Mage::getModel('catalog/category')->getCategories($parentCategoryId);
foreach ($children as $category) { ?>
   <li><a href="<?php echo $category->getURL(); ?>"><?php echo $category->getName(); ?></a></li>
    <?php
}

?>
************************************************************************

Wednesday, 3 December 2014

added slider extension in magento not appearing on home page

steps 
->set the start date for the banners one(1) day before than the day you created the slider.

Tuesday, 2 December 2014

solution of your design change for the specified store intersects with another one, please specify another date range.

solution of your design change for the specified store intersects with another one, please specify another date range. 



Follow these steps to get the solution:
Go to your phpMyAdmin page.

Open the phpMyAdmin portal from your hosting panel.

Select the database(magento)

Select the database where you’ve stored your magento data.

Find the table(Design Changes).

Find out the table named “design_change”. If you set any prefix while installing magento then the name of the table will be “yourprefix_design_change”.

Delete the records
Do not drop table.just delete all records.Click on GO

service temporarily unavailable in magento problem solution













Follow these steps to solve your problem:

          i> Go to magento root directory in www or htdocs.

         
          ii> Find the maintenance.flag file and delete it.

there has been an error processing your request message on installing Magento solution

Go and follow these steps to remove your error:

   i>  Navigate to the "errors" folder.

  ii>  Change local.xml.sample to local.xml

    You should now see a new list of crazy errors all over the Magento page - this is okay.

   iii> Open magento/lib/Zend/Cache/Backend/File.php and look for:
    protected $_options = array(
    'cache_dir' => 'null',
    Change it to:
    protected $_options = array(
    'cache_dir' => 'tmp/',

 iv>   Save it.
    Now the final step is to go create a tmp folder in the root Magento folder.
    That's it.