function getCurrentCmsPage() {
$pageId = Mage::getBlockSingleton('cms/page')->getPage()->getIdentifier();
return $pageId;
}
Hope it Helps... Thanks..
function getCurrentCmsPage() {
$pageId = Mage::getBlockSingleton('cms/page')->getPage()->getIdentifier();
return $pageId;
}
{{block type="catalog/product_list" name="home.catalog.product.list" alias="products_homepage" template="catalog/product/list.phtml"}}
{{block type="catalog/product_list" name="home.catalog.product.list" alias="products_homepage" category_id="4" template="catalog/product/list.phtml"}}
$customerAddressId = Mage::getSingleton('customer/session')->getCustomer()->getDefaultShipping();
if ($customerAddressId){
$address = Mage::getModel('customer/address')->load($customerAddressId);
}
else
{
$address = Mage::getSingleton('checkout/session')->getQuote()->getShippingAddress();
}
Hope it Helps .. Thanks....
<a href="#" onclick="popWin('<?php echo $this->getGalleryUrl($_image) ?>', 'gallery', 'width=300,height=300,left=50,top=50,location=no,status=yes,scrollbars=yes,resizable=yes'); return false;">
<!--nested img tag stays the same-->
</a>
<a href="<?php echo $this->helper('catalog/image')->init($this->getProduct(), 'image', $_image->getFile()); ?>" title="<?php echo $_product->getName();?>" onclick="$('image').src = this.href; return false;">
<!--nested img tag stays the same-->
</a>
$currentUrl = $this->helper('core/url')->getCurrentUrl();
// Gives the base url of your magento installation
$baseUrl = Mage::getBaseUrl();
// Gives the url of media directory inside your magento installation
$mediaUrl = Mage::getBaseUrl('media');
Another way to get current url$urlRequest = Mage::app()->getFrontController()->getRequest();
$urlPart = $urlRequest->getServer('ORIG_PATH_INFO');
if(is_null($urlPart))
{
$urlPart = $urlRequest->getServer('PATH_INFO');
}
$urlPart = substr($urlPart, 1 );
$currentUrl = $this->getUrl($urlPart);
public function getMostViewedProducts()
{
/**
* Number of products to display
* You may change it to your desired value
*/
$productCount = 5;
/**
* Get Store ID
*/
$storeId = Mage::app()->getStore()->getId();
/**
* Get most viewed product collection
*/
$products = Mage::getResourceModel('reports/product_collection')
->addAttributeToSelect('*')
->setStoreId($storeId)
->addStoreFilter($storeId)
->addViewsCount()
->setPageSize($productCount);
Mage::getSingleton('catalog/product_status')
->addVisibleFilterToCollection($products);
Mage::getSingleton('catalog/product_visibility')
->addVisibleInCatalogFilterToCollection($products);
return $products;
}
/**
* Get Top Rated Products
*
* @return array
*/
public function getTopRatedProduct() {
$limit = 5;
// get all visible products
$_products = Mage::getModel('catalog/product')->getCollection();
$_products->setVisibility(Mage::getSingleton('catalog/product_visibility')->getVisibleInCatalogIds());
$_products->addAttributeToSelect('*')->addStoreFilter();
$_rating = array();
foreach($_products as $_product) {
$storeId = Mage::app()->getStore()->getId();
// get ratings for individual product
$_productRating = Mage::getModel('review/review_summary')
->setStoreId($storeId)
->load($_product->getId());
$_rating[] = array(
'rating' => $_productRating['rating_summary'],
'product' => $_product
);
}
// sort in descending order of rating
arsort($_rating);
// returning limited number of products and ratings
return array_slice($_rating, 0, $limit);
}
<?php $topRatedProducts = $this->helper('yourModule')->getTopRatedProduct();?>
<ul>
<?php foreach($topRatedProducts as $_rating): ?>
<?php $_product = $_rating['product']; ?>
<li>
<img src="<?php echo $this->helper('catalog/image')->init($_product, 'small_image')->resize(150); ?>" alt="<?php echo $this->htmlEscape($this->getImageLabel($_product, 'small_image')) ?>" title="<?php echo $this->htmlEscape($this->getImageLabel($_product, 'small_image')) ?>" />
<a href="<?php echo $_product->getProductUrl() ?>" title="<?php echo $this->htmlEscape($this->getImageLabel($_product, 'small_image')) ?>">
<span>View Details</span>
</a>
</li>
</ul>
<?php endforeach; ?>
$visitorData = Mage::getSingleton('core/session')->getVisitorData();
// printing visitor information data
echo ""; print_r($visitorData); echo "
";
// user's ip address (visitor's ip address)
$remoteAddr = Mage::helper('core/http')->getRemoteAddr(true);
// server's ip address (where the current script is)
$serverAddr = Mage::helper('core/http')->getServerAddr(true);Ref : http://blog.chapagain.com.np/magento-track-visitors-information/
<?xml version="1.0"?> <config> <modules> <fido_example> <active>true</active> <codepool>local</codePool> </Fido_Example> </modules> </config>
<?xml version="1.0"?> <config> <modules> <fido_example> <version>0.1.0</version> </Fido_Example> </modules> <global> <blocks> <fido_example> <class>Fido_Example_Block</class> </fido_example> </blocks> </global> </config>
<?php
/**
* Example View block
*
* @codepool Local
* @category Fido
* @package Fido_Example
* @module Example
*/
class Fido_Example_Block_View extends Mage_Core_Block_Template
{
private $message;
private $att;
protected function createMessage($msg) {
$this->message = $msg;
}
public function receiveMessage() {
if($this->message != '') {
return $this->message;
} else {
$this->createMessage('Hello World');
return $this->message;
}
}
protected function _toHtml() {
$html = parent::_toHtml();
if($this->att = $this->getMyCustom() && $this->getMyCustom() != '') {
$html .= '
'.$this->att;
} else {
$html .= '
No Custom Attribute Found';
}
return $html;
}
}
<?php /** * Fido view template * * @see Fido_Example_Block_View * */ ?> <div> <span><strong>This is the output of the fido example:</strong></span> <span style="color:#FF9933;"> <?php echo $this->receiveMessage(); ?> </span> </div>
{{block type="fido_example/view" my_custom="Test" template="example/view.phtml" }}
<?php echo $this->helper('checkout')->formatPrice($_product->getPrice())
// For Special Price write this
echo $this->helper('checkout')->formatPrice($_product->getSpecialPrice()) ?>
Mohan Natarajan Powered by Blogger