Posts

Showing posts from May, 2014

how to add on sale stamp image on a product

<? php $specialprice = Mage :: getModel ( 'catalog/product' )-> load ( $_product -> getId ())-> getSpecialPrice (); if ( $specialprice ){?> <img src=" <? php echo $this -> getSkinUrl ( 'images/onsale-img.png' ) ?> "  width="68" height="68" class="onsaleicon" /> <? php } ?>

Submit Review’ button not working, instead add’s product to cart

Ok, please check your page html using firebug. the <form> tag for product add to cart and <form> tag should be different. I am thinking, in your theme, the <form> tag for review has gone inside the add to cart form. thats why ur facing this problem. you need to correct your html structure of theme.

Magento : Login/Logout Code in Header

<?php if (! Mage::getSingleton( 'customer/session' )->isLoggedIn()): ?> <a href= "<?php echo Mage::helper('customer')->getLoginUrl(); ?>" ><?php echo $this ->__( 'Login' ) ?></a> <?php else : ?> <a href= "<?php echo Mage::helper('customer')->getLogoutUrl(); ?>" ><?php echo $this ->__( 'Logout' ) ?></a> <?php endif ; ?>

to get the current url in magento

$current_url = $this->helper('core/url')->getCurrentUrl(); echo $current_url;

to get the product based on the category id programatically

$cat_id = 345 ; $category = Mage :: getModel ( 'catalog/category' )-> load ( $cat_id ); $collection = $category -> getProductCollection ()-> addAttributeToSort ( 'position' ); Mage :: getModel ( 'catalog/layer' )-> prepareProductCollection ( $collection ); foreach ( $collection as $product ) { var_dump ( $product -> getName () ); } you can get images <a href="#"><img src="http://buylifeionizers.com/media/catalog/product<?php echo $product->getThumbnail();?>" alt="img"/></a> <?php echo $product->getThumbnail();?> you can get the content using get method make sure after get the first letter must be capital for example(thumbnail as getThumbnail() )

To call a new page phtml file in cms

{{block type="core/template" name="a-name" template="page/home-page.phtml"}}

how to filter the products using code

<?php $val=$_GET['advertiser_id']; $collection = Mage::getModel('catalog/product')->getCollection() ->addAttributeToSelect('*') // select all attributes ->setPageSize(30) // limit number of results returned ->setCurPage(4) // set the offset (useful for pagination) ->addAttributeToFilter('advertiser_name', array('finset' => $val)); // we iterate through the list of products to get attribute values ?> <!--============================container-fluid=========================--> <div class="item-main container-fluid">     <?php //echo $this->getPagerHtml(); ?> <div class="row"> <?php foreach ($collection as $product) {   ?>   <div class="col-md-2">       <div class="border01">   <a href="<?php echo $product->getProductUrl(); ?>"><img src="<?php echo Mage::getBaseUrl(Mage_Core_Model_Store::URL_TYPE_MEDIA)....

magento codes to access module to any other pages like category,product details etc

$val=$_GET['advertiser_name'];    $a = Mage::getModel("storeband_storebrand/storebrands")->getCollection()->addAttributeToSelect('*'); //->addAttributeToFilter('advertiser_name');     here  Storeband_storebrand is module name and storebrands is model name u will get the moule in name of module/etc/config <config>     <modules>         <Storeband_Storebrand>             <version>1.0.0</version>         </Storeband_Storebrand>     </modules> and model name in  <models>             <storeband_storebrand>                 <class>Storeband_Storebrand_Model</class>  ...