http://www.magentocommerce.com/knowledge-base/entry/turning-on-off-magentos-content-blocks
Daily Archives: November 23, 2012
Display Edit Button on check page
<td>
<?php if ($isVisibleProduct): ?>
<a href=”<?php echo $this->getConfigureUrl() ?>” title=”<?php echo $this->__(‘Edit item parameters’) ?>”><?php echo $this->__(‘Edit1’) ?></a> <?php endif ?> </td>
Call all Custom Attribute’s as in a list
<?php
$product = Mage::getModel(‘catalog/product’);
$attributes = Mage::getResourceModel(‘eav/entity_attribute_collection’)->
setEntityTypeFilter($product->getResource()->getTypeId())->addFieldToFilter(‘attribute_code’, ‘your_clothes_brand’); // custome attribute code
$attribute = $attributes->getFirstItem()->setEntity($product->getResource());
$manufacturers = $attribute->getSource()->getAllOptions(false);
?>
<ul>
<?php foreach ($manufacturers as $manufacturer): ?>
<li><a href=”http://<?php echo $_SERVER[‘HTTP_HOST’];?>/catalogsearch/advanced/result/?manufacturer[]=<?php echo $manufacturer[‘value’] ?>”><?php echo $manufacturer[‘label’] ?></a></li>
<?php endforeach; ?>
Display all products
<?php
$collection = Mage::getModel(‘catalog/product’)->getCollection()
->addAttributeToSelect(‘*’) // select all attributes
->setPageSize(10) // limit number of results returned
->setCurPage(4); // set the offset (useful for pagination)
// we iterate through the list of products to get attribute values
foreach ($collection as $product) {
echo ‘<br />Name :’;
echo $product->getName(); //get name
echo ‘<br />Price : ‘;
echo (float) $product->getPrice(); //get price as cast to float
echo ‘<br />Description : ‘;
echo $product->getDescription(); //get description
echo ‘<br />Shor Description : ‘;
echo $product->getShortDescription(); //get short description
echo ‘<br /> Product type :’;
echo $product->getTypeId(); //get product type
echo ‘<br /> Product Status : ‘;
echo $product->getStatus(); //get product status
// getCategoryIds(); returns an array of category IDs associated with the product
foreach ($product->getCategoryIds() as $category_id) {
$category = Mage::getModel(‘catalog/category’)->load($category_id);
echo ‘<br />Category Name :’;
echo $category->getName();
echo ‘<br />Parent Category :’;
echo $category->getParentCategory()->getName(); // get parent of category
echo ‘<br />’;
}
//gets the image url of the product
echo ‘<br />Image URL :’;
echo Mage::getBaseUrl(Mage_Core_Model_Store::URL_TYPE_MEDIA).
‘catalog/product’.$product->getImage();
echo ‘<br />Special Price :’;
echo $product->getSpecialPrice();
echo ‘<br />Product URL :’;
echo $product->getProductUrl(); //gets the product url
echo ‘<br />’;
} ?>
Display Custom value on checkout page
<?php $_item = $this->getItem()?>
<?php $_product= Mage::getSingleton(‘catalog/product’)->load($_item->getProductId()) ?>
<?php echo $_product->getResource()->getAttribute(‘product_shipping’)->getFrontend()->getValue($_product); ?>
Display Attribute Name
<?php echo $this->htmlEscape($_product->getData(‘outdoor’)); ?>
<?php echo $_product->getAttributeText(‘shirt_size’) ?>
Product Short Description
<?php echo $_product->_data[‘short_description’]; ?>
Product Description
<?php $my_product = Mage::getModel(‘catalog/product’)->load($_product->getId());
echo $my_product->getDescription(); ?>