Tags » Magento

Magento: Get Product Msrp if available.


<?php if ($_product->getMsrp()):  ?>
<div class="mrp"><span class="mrp-price"><?php echo $this->__('MRP'); ?>:</span><span class="mrsp-price"><?php echo $mrp; ?></span></div>
<?php endif; ?>

Magento

Magento: Get custom textarea attribute field if available on product page


<?php if ($_product->getWhatsincluded()): ?>// what is included is custom textarea attribute.
<?php echo $_helper->productAttribute($_product, $_product->getwhatsincluded(), 'whatsincluded') ?>
<?php endif;?>

Magento

Magento: On sale product listing by category

1-Create a new CMS page with content set to…


{{block type="catalog/product_list" template="onsale/sale.phtml"}}

2- and a template for listing your products
app/design/frontend/your_package/your_theme/template/inchoo/onsale/sale.phtml


<?php
$_productCollection = Mage::getModel('catalog/product')->getCollection();
$_productCollection->addAttributeToSelect(array(
'image',
'name',
'short_description'
))
->addFieldToFilter('visibility', array(
Mage_Catalog_Model_Product_Visibility::VISIBILITY_BOTH,
Mage_Catalog_Model_Product_Visibility::VISIBILITY_IN_CATALOG
)) //showing just products visible in catalog or both search and catalog
->addFinalPrice()
//                        ->addAttributeToSort('price', 'asc') //in case we would like to sort products by price
->getSelect()
->where('price_index.final_price < price_index.price')
//                        ->limit(30) //we can specify how many products we want to show on this page
//                        ->order(new Zend_Db_Expr('RAND()')) //in case we would like to sort products randomly
;

Mage::getModel('review/review')->appendSummary($_productCollection);

$_helper = $this->helper('catalog/output');
?>
//
<?php if(!$_productCollection->count()): ?>
<p class="note-msg"><?php echo $this->__('There are no products matching the selection.') ?></p>
<?php else: ?>
<div class="category-products">
<?php // List mode ?>
<?php $_iterator = 0; ?>
<ol class="products-list" id="products-list">
<?php foreach ($_productCollection as $_product): ?>
<li class="item<?php if( ++$_iterator == sizeof($_productCollection) ): ?> last<?php endif; ?>">
<?php // Product Image ?>
<a href="<?php echo $_product->getProductUrl() ?>" title="<?php echo $this->stripTags($this->getImageLabel($_product, 'small_image'), null, true) ?>" class="product-image"><img src="<?php echo $_product->getImageUrl(); ?>" width="135" height="135" alt="<?php echo $this->stripTags($this->getImageLabel($_product, 'small_image'), null, true) ?>" /></a>
<?php // Product description ?>
<div class="product-shop">
<div class="f-fix">
<?php $_productNameStripped = $this->stripTags($_product->getName(), null, true); ?>
<h2 class="product-name"><a href="<?php echo $_product->getProductUrl() ?>" title="<?php echo $_productNameStripped; ?>"><?php echo $_helper->productAttribute($_product, $_product->getName() , 'name'); ?></a></h2>
<?php if($_product->getRatingSummary()): ?>
<?php echo $this->getReviewsSummaryHtml($_product) ?>
<?php endif; ?>
<?php echo $this->getPriceHtml($_product, true) ?>
<?php if($_product->isSaleable()): ?>
<p><button type="button" title="<?php echo $this->__('Add to Cart') ?>" class="button btn-cart" onclick="setLocation('<?php echo $this->getAddToCartUrl($_product) ?>')"><span><span><?php echo $this->__('Add to Cart') ?></span></span></button></p>
<?php else: ?>
<p class="availability out-of-stock"><span><?php echo $this->__('Out of stock') ?></span></p>
<?php endif; ?>
<div class="desc std">
<?php echo $_helper->productAttribute($_product, $_product->getShortDescription(), 'short_description') ?>
<a href="<?php echo $_product->getProductUrl() ?>" title="<?php echo $_productNameStripped ?>" class="link-learn"><?php echo $this->__('Learn More') ?></a>
</div>
<ul class="add-to-links" style="margin:0; padding-left:0; list-style: none;">
<?php if ($this->helper('wishlist')->isAllow()) : ?>
<li><a href="<?php echo $this->helper('wishlist')->getAddUrl($_product) ?>" class="link-wishlist"><?php echo $this->__('Add to Wishlist') ?></a></li>
<?php endif; ?>
<?php if($_compareUrl=$this->getAddToCompareUrl($_product)): ?>
<li><span class="separator">|</span> <a href="<?php echo $_compareUrl ?>" class="link-compare"><?php echo $this->__('Add to Compare') ?></a></li>
<?php endif; ?>
</ul>
</div>
</div>
</li>
<?php endforeach; ?>
</ol>
<script type="text/javascript">decorateList('products-list', 'none-recursive')</script>
</div>
<?php endif; ?>

… 42 more words
Magento

Magento: custom sql Query example


$read = Mage::getSingleton( 'core/resource' )->getConnection( 'core_read' );
$pincode = Mage::getSingleton( 'core/resource' )->getTableName( 'available_pincodes' );
$query = "SELECT * FROM " . $pincode ;
$result = $read->query( $query );
while ( $row = $result->fetch() ) {
echo 'Pincode ID: ' . 6 more words
Magento

Magento: Pincode varification to add to cart.

1- Take the html layout where you want to the html layout.


<div class="pincode">
<input type="text" name="pincode" id='pincode1'  placeholder="Enter pincode to check dilivery option">
<div id='pincode'></div>
<input class="verify-button" type='button' onclick="checkForm()" value='Verify'>
</div>

… 240 more words
Magento

Magento: product slider

1-place the jquery.bxslider folder in magento root js folder.
From: http://bxslider.com/examples/carousel-dynamic-number-slides
2-And place the following code. in your product collection page For jquery:

<link rel="stylesheet" href="<?php echo $this->getJsUrl()?>jquery.bxslider/jquery.bxslider.css" type="text/css" />
<script src="<?php echo $this->getJsUrl()?>jquery.bxslider/jquery.bxslider.js"></script>
<script type="text/javascript">
jQuery(window).load(function(){
jQuery('.bxslider').bxSlider({
pager:false,
minSlides: 3,
maxSlides: 5,
slideWidth: 240,
slideMargin:10
});
})
</script>

… 568 more words
Magento

Magento: Left Category with jquery


<div class="left-category"><?php echo $this-> __('CATEGORIES')?></div>



<div class="maincategory">
<?php

$_helper = Mage::helper('catalog/category');
$_categories = $_helper->getStoreCategories();
$currentCategory = Mage::registry('current_category') ;

$rootCategoryId = Mage::app()->getStore()->getRootCategoryId();
$rootCategory = Mage::getModel('catalog/category')->load($rootCategoryId);

$childIds = explode(',',$rootCategory->getChildren());

if (count($childIds) > 0):

?>

<?php foreach($childIds as $_category):
$_category = Mage::getModel('catalog/category')->load($_category);
?>



<div class="maincatdiv">
<div class="catheader">
<span class="category_name">
<a href="<?php echo $_helper->getCategoryUrl($_category) ?>">
<?php echo $_category->getName() ?></a></span>
<?php if ($_category->getChildren() != ''){?><span class="caticon">+</span><?php } ?>
</div>
<div class="catcontent" style="display:none;"><?php

if ($_category->getChildren() != ''):

$allsubchild = explode(',',$_category->getChildren());
?>
<ul>
<?php foreach($allsubchild as $_sub):
$_subcategory = Mage::getModel('catalog/category')->load($_sub);
?>
<li>

<a href="<?php echo $_helper->getCategoryUrl($_subcategory) ?>">
<?php echo $_subcategory->getName() ?>
</a>
</li>
<?php endforeach; ?>
</ul>
<?php endif; ?></div>
</div>

<?php endforeach; ?>

<?php endif; ?>
</div>

<script type="text/javascript">
jQuery(window).load(function(){
jQuery('.caticon').click(function(){
var str = jQuery(this).closest('.maincatdiv').find('.catcontent').html().split(' ');
if(str[0] != '')
{
if(jQuery(this).attr('class').indexOf('active') != -1)
{
jQuery('.catcontent').slideUp();
jQuery('.caticon').removeClass('active');
jQuery('.caticon').html('+');
}
else{

jQuery('.catcontent').slideUp();
jQuery('.caticon').removeClass('active');
jQuery('.caticon').html('+');
jQuery(this).addClass('active');
jQuery(this).html('-');
jQuery(this).closest('.maincatdiv').find('.catcontent').slideDown();

}
}

});
})
</script>

Magento