<a href="https://console.cloud.google.com/apis/credentials">Get Your Api Credentials Here</a> <a href="https://calendar.google.com/calendar">Get your Calender ID</a> <?php include_once("wp-load.php"); function get_calender_events() { $params = array(); /*Get current date*/ $current_date = date('Y-m-d H:i:s'); /*Convert it to google calendar's rfc_format */ $rfc_format = date("c", strtotime($current_date)); $params[] = 'orderBy=startTime'; $params[] ='maxResults=100'; $params[] = 'timeMin='.urlencode($rfc_format); $url_param = ''; foreach($params as $param) { $url_param.= '&'.$param; } $calender_id = "calender_id"; $client_key = "client_key"; $url = "https://www.googleapis.com/calendar/v3/calendars/".$calender_id."/events?key=".$client_key."&singleEvents=true".$url_param; $list_events = wp_remote_post($url, ...
1.Create attribute with name "featured" with option yes/no
Catalog->Attributes->Manage Attributes->Add New Attribute
Attribute Code= featured
Catalog Input Type for Store Owner=Yes/no
Comparable on Front-end=Yes
Visible on Product View Page on Front-end=Yes
Manage Label / Options=Featured
2.Catalog->Attributes->Manage Attribute Sets->add this attribute in general.
3.CMS Page or Static Blocks
{{block type="core/template" name="featured" template="include/featured.phtml"}}
4.In app\design\frontend\default\default\template\include\featured.phtml
<div class="featured-product">
<h1 class="title">Featured products</h1>
<div class="featured-itemslider-wrapper">
<div class="featureitemslider">
<ul class="products-grid slides">
<?php
$_helper = $this->helper('catalog/output');
$storeId = Mage::app()->getStore()->getId();
$catalog = $this->getLayout()->createBlock('catalog/product_list')->setStoreId($storeId);
$collection = Mage::getModel('catalog/product')->getCollection();
$collection->addAttributeToSelect('featured');
$collection->addFieldToFilter(array(
array('attribute' => 'featured', 'eq' => true),
));
?>
<?php if (!$collection->count()) : ?>
<p class="note-msg"><?php echo $this->__('There are no new products at the moment.') ?></p>
<?php else : ?>
<?php $i=0; $j=0; foreach ($collection as $_product) :
$_product = Mage::getModel('catalog/product')->setStoreId($storeId)->load($_product->getId());
?>
<?php if($_product->getStatus()==1): ?>
<li>
<a class="product-image" href="<?php echo $_product->getProductUrl() ?>" title="<?php echo $this->stripTags($this->getImageLabel($_product, 'small_image'), null, true) ?>" class="product-image"><img src="<?php echo $this->helper('catalog/image')->init($_product, 'small_image')->resize(150,168); ?>" width="150" height="168" alt="<?php echo $this->stripTags($this->getImageLabel($_product, 'small_image'), null, true) ?>" /></a>
<h2 class="product-name"><a href="<?php echo $_product->getProductUrl() ?>"><?php echo $this->htmlEscape($_product->getName())?></a></h2>
<?php
$storeId = Mage::app()->getStore()->getId();
$summaryData = Mage::getModel('review/review_summary')->setStoreId($storeId) ->load($_product->getId());
$reviewData = Mage::getModel('review/review/summary');
//echo $reviewData->getTotalReviews($_product->getId());
if($reviewData->getTotalReviews($_product->getId()) == '0')
{
?>
<div class="ratings" style="visibility:hidden;">
<div class="rating-box">
<div class="rating" style="width:<?php echo $summaryData['rating_summary']; ?>%"></div>
</div>
<span class="amount">(<?php echo $reviewData->getTotalReviews($_product->getId()); ?>)</span>
</div>
<?php } else { ?>
<div class="ratings">
<div class="rating-box">
<div class="rating" style="width:<?php echo $summaryData['rating_summary']; ?>%"></div>
</div>
<span class="amount">(<?php echo $reviewData->getTotalReviews($_product->getId()); ?>)</span>
</div>
<?php } ?>
<?php
$_coreHelper = $this->helper('core');
$regularprice = $_coreHelper->currency(number_format($_product->getPrice(),2),true,false);
$specialprice = $_coreHelper->currency(number_format($_product->getSpecialPrice(),2),true,false);
$test=$_product->getSpecialPrice();
?>
<div class="price-box">
<?php if($test == '') { ?>
<div class="regular-price">
<div class="price"><?php echo $regularprice; ?></div>
</div>
<?php } else { ?>
<div class="old-price">
<div class="price"><?php echo $regularprice; ?></div>
</div>
<div class="special-price">
<div class="price"><?php echo $specialprice; ?></div>
</div>
<?php } ?>
</div>
<?if($_product->isSaleable()):?>
<button class="add2cart btn-cart button" onclick="setLocation('<?=$this->getAddToCartUrl($_product)?>')"><?=__('winkelwagen')?></button>
<?endif;?>
<!--<div class="actions">
<?php if ($this->helper('wishlist')->isAllow()) : ?>
<a class="add2wishlist" href="<?php echo $this->helper('wishlist')->getAddUrl($_product) ?>"><img src="<?php echo $this->getSkinUrl()?>/images/heart.png"></a>
<?php endif; ?>
<?php if($_compareUrl=$this->helper('catalog/product_compare')->getAddUrl($_product) ): ?>
<a class="compare" href="<?php echo $_compareUrl ?>"><img src="<?php echo $this->getSkinUrl()?>/images/comp-icon.png"></a>
<?php endif; ?>
</div> -->
</li>
<?php endif; ?>
<?php $j++; endforeach; ?>
<div class="cls"></div>
<?php endif ?>
</ul>
<!-- <div class="direction-nav">
<span class="next"><a href="#"></a></span>
<span class="prev"><a href="#"></a></span>
</div>-->
</div>
</div>
<div class="cls">
<script type="text/javascript">
//<![CDATA[
jQuery(function($) {
$('.featured-itemslider-wrapper .featureitemslider').flexslider({
namespace: "",
animation: "slide",
easing: "easeInQuart",
slideshow: false,
animationLoop: false,
animationSpeed: 300,
pauseOnHover: true,
controlNav: false,
controlsContainer: ".featured-itemslider-wrapper .nav-wrapper",
itemWidth: 150,
minItems: 4,
maxItems: 4,
move: 1 })
.data("showItems", 4 )
;
});
//]]>
</script>
</div>
</div>
Catalog->Attributes->Manage Attributes->Add New Attribute
Attribute Code= featured
Catalog Input Type for Store Owner=Yes/no
Comparable on Front-end=Yes
Visible on Product View Page on Front-end=Yes
Manage Label / Options=Featured
2.Catalog->Attributes->Manage Attribute Sets->add this attribute in general.
3.CMS Page or Static Blocks
{{block type="core/template" name="featured" template="include/featured.phtml"}}
4.In app\design\frontend\default\default\template\include\featured.phtml
<div class="featured-product">
<h1 class="title">Featured products</h1>
<div class="featured-itemslider-wrapper">
<div class="featureitemslider">
<ul class="products-grid slides">
<?php
$_helper = $this->helper('catalog/output');
$storeId = Mage::app()->getStore()->getId();
$catalog = $this->getLayout()->createBlock('catalog/product_list')->setStoreId($storeId);
$collection = Mage::getModel('catalog/product')->getCollection();
$collection->addAttributeToSelect('featured');
$collection->addFieldToFilter(array(
array('attribute' => 'featured', 'eq' => true),
));
?>
<?php if (!$collection->count()) : ?>
<p class="note-msg"><?php echo $this->__('There are no new products at the moment.') ?></p>
<?php else : ?>
<?php $i=0; $j=0; foreach ($collection as $_product) :
$_product = Mage::getModel('catalog/product')->setStoreId($storeId)->load($_product->getId());
?>
<?php if($_product->getStatus()==1): ?>
<li>
<a class="product-image" href="<?php echo $_product->getProductUrl() ?>" title="<?php echo $this->stripTags($this->getImageLabel($_product, 'small_image'), null, true) ?>" class="product-image"><img src="<?php echo $this->helper('catalog/image')->init($_product, 'small_image')->resize(150,168); ?>" width="150" height="168" alt="<?php echo $this->stripTags($this->getImageLabel($_product, 'small_image'), null, true) ?>" /></a>
<h2 class="product-name"><a href="<?php echo $_product->getProductUrl() ?>"><?php echo $this->htmlEscape($_product->getName())?></a></h2>
<?php
$storeId = Mage::app()->getStore()->getId();
$summaryData = Mage::getModel('review/review_summary')->setStoreId($storeId) ->load($_product->getId());
$reviewData = Mage::getModel('review/review/summary');
//echo $reviewData->getTotalReviews($_product->getId());
if($reviewData->getTotalReviews($_product->getId()) == '0')
{
?>
<div class="ratings" style="visibility:hidden;">
<div class="rating-box">
<div class="rating" style="width:<?php echo $summaryData['rating_summary']; ?>%"></div>
</div>
<span class="amount">(<?php echo $reviewData->getTotalReviews($_product->getId()); ?>)</span>
</div>
<?php } else { ?>
<div class="ratings">
<div class="rating-box">
<div class="rating" style="width:<?php echo $summaryData['rating_summary']; ?>%"></div>
</div>
<span class="amount">(<?php echo $reviewData->getTotalReviews($_product->getId()); ?>)</span>
</div>
<?php } ?>
<?php
$_coreHelper = $this->helper('core');
$regularprice = $_coreHelper->currency(number_format($_product->getPrice(),2),true,false);
$specialprice = $_coreHelper->currency(number_format($_product->getSpecialPrice(),2),true,false);
$test=$_product->getSpecialPrice();
?>
<div class="price-box">
<?php if($test == '') { ?>
<div class="regular-price">
<div class="price"><?php echo $regularprice; ?></div>
</div>
<?php } else { ?>
<div class="old-price">
<div class="price"><?php echo $regularprice; ?></div>
</div>
<div class="special-price">
<div class="price"><?php echo $specialprice; ?></div>
</div>
<?php } ?>
</div>
<?if($_product->isSaleable()):?>
<button class="add2cart btn-cart button" onclick="setLocation('<?=$this->getAddToCartUrl($_product)?>')"><?=__('winkelwagen')?></button>
<?endif;?>
<!--<div class="actions">
<?php if ($this->helper('wishlist')->isAllow()) : ?>
<a class="add2wishlist" href="<?php echo $this->helper('wishlist')->getAddUrl($_product) ?>"><img src="<?php echo $this->getSkinUrl()?>/images/heart.png"></a>
<?php endif; ?>
<?php if($_compareUrl=$this->helper('catalog/product_compare')->getAddUrl($_product) ): ?>
<a class="compare" href="<?php echo $_compareUrl ?>"><img src="<?php echo $this->getSkinUrl()?>/images/comp-icon.png"></a>
<?php endif; ?>
</div> -->
</li>
<?php endif; ?>
<?php $j++; endforeach; ?>
<div class="cls"></div>
<?php endif ?>
</ul>
<!-- <div class="direction-nav">
<span class="next"><a href="#"></a></span>
<span class="prev"><a href="#"></a></span>
</div>-->
</div>
</div>
<div class="cls">
<script type="text/javascript">
//<![CDATA[
jQuery(function($) {
$('.featured-itemslider-wrapper .featureitemslider').flexslider({
namespace: "",
animation: "slide",
easing: "easeInQuart",
slideshow: false,
animationLoop: false,
animationSpeed: 300,
pauseOnHover: true,
controlNav: false,
controlsContainer: ".featured-itemslider-wrapper .nav-wrapper",
itemWidth: 150,
minItems: 4,
maxItems: 4,
move: 1 })
.data("showItems", 4 )
;
});
//]]>
</script>
</div>
</div>
New product
--------------
<?php
$actualRootCategoryId = Mage::app()->getStore()->getRootCategoryId();
$object = new Mage_Catalog_Block_Navigation();
$actualCurrentCategoryId = $object->getCurrentCategory()->getId();
if($actualRootCategoryId!=$actualCurrentCategoryId)
{
$_productCollection = Mage::getResourceModel('catalog/product_collection')
->addAttributeToSelect(array('name', 'price', 'small_image', 'special_price', 'news_from_date', 'news_to_date'), 'inner')
->addCategoryFilter(Mage::getModel('catalog/category')->load($actualCurrentCategoryId))
->addAttributeToFilter('status', 1)
->addAttributeToSort('created_at', 'ASC')
->addAttributeToFilter('new_product', 1);
}
else
{
$_productCollection = Mage::getResourceModel('catalog/product_collection')
->addAttributeToSelect(array('name', 'price', 'small_image', 'special_price', 'news_from_date', 'news_to_date'), 'inner')
->addAttributeToFilter('status', 1)
->addAttributeToSort('created_at', 'ASC')
->addAttributeToFilter('new_product', 1);
}
?>
<h2 class="title"><span><?php echo $this->__('nieuw'); ?></span></h2>
<ul class="products-grid">
<?php foreach ($_productCollection as $_product): ?>
<li class="item">
<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 $this->helper('catalog/image')->init($_product, 'small_image')->resize(154, 165); ?>" width="154" height="165" alt="<?php echo $this->stripTags($this->getImageLabel($_product, 'small_image'), null, true) ?>" /></a>
<?php require('media_labels_listpage.phtml'); ?>
<h2 class="product-name"><a href="<?php echo $_product->getProductUrl() ?>"><?php $name = Mage::getResourceModel('catalog/product')->getAttributeRawValue($_product->getId(), 'name', $store_id); ?><?php echo $name; ?></a></h2>
<span class="catagory-name"></span>
<?php
$_product = Mage::getModel('catalog/product')->setStoreId($storeId)->load($_product->getId());
$_coreHelper = $this->helper('core');
$regularprice = $_coreHelper->currency($_product->getPrice(),true,false);
$specialprice = $_coreHelper->currency($_product->getSpecialPrice(),true,false);
$test = $_product->getSpecialPrice();
?>
<div class="price-box">
<?php if($test == '') { ?>
<div class="regular-price">
<div class="price"><?php echo $regularprice;?></div>
</div>
<?php } else { ?>
<div class="old-price">
<div class="price"><?php echo $regularprice;?></div>
</div>
<div class="special-price">
<div class="price"><?php echo $specialprice;?></div>
</div>
<?php } ?>
<div class="cls"></div>
</div>
<a class="more-info" href="<?php echo $_product->getProductUrl() ?>">meer</a>
<div class="cls"></div>
<div class="actions">
<button type="button" title="<?php echo $this->__('Add to Cart') ?>" class="btn-cart button" onclick="setLocation('<?php echo $_product->getProductUrl()?>')"><span><span><?php echo $this->__('Add to Cart') ?></span></span></button>
<ul class="add-to-links">
<?php //if($_compareUrl=$this->getAddToCompareUrl($_product)): ?>
<li><a href="<?php echo $_compareUrl ?>" class="link-compare"><?php //echo $this->__('Add to Compare') ?></a></li>
<?php //endif; ?>
<?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; ?>
</ul>
<div class="cls"></div>
</div>
</li>
<?php endforeach; ?>
</ul>
--------------
<?php
$actualRootCategoryId = Mage::app()->getStore()->getRootCategoryId();
$object = new Mage_Catalog_Block_Navigation();
$actualCurrentCategoryId = $object->getCurrentCategory()->getId();
if($actualRootCategoryId!=$actualCurrentCategoryId)
{
$_productCollection = Mage::getResourceModel('catalog/product_collection')
->addAttributeToSelect(array('name', 'price', 'small_image', 'special_price', 'news_from_date', 'news_to_date'), 'inner')
->addCategoryFilter(Mage::getModel('catalog/category')->load($actualCurrentCategoryId))
->addAttributeToFilter('status', 1)
->addAttributeToSort('created_at', 'ASC')
->addAttributeToFilter('new_product', 1);
}
else
{
$_productCollection = Mage::getResourceModel('catalog/product_collection')
->addAttributeToSelect(array('name', 'price', 'small_image', 'special_price', 'news_from_date', 'news_to_date'), 'inner')
->addAttributeToFilter('status', 1)
->addAttributeToSort('created_at', 'ASC')
->addAttributeToFilter('new_product', 1);
}
?>
<h2 class="title"><span><?php echo $this->__('nieuw'); ?></span></h2>
<ul class="products-grid">
<?php foreach ($_productCollection as $_product): ?>
<li class="item">
<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 $this->helper('catalog/image')->init($_product, 'small_image')->resize(154, 165); ?>" width="154" height="165" alt="<?php echo $this->stripTags($this->getImageLabel($_product, 'small_image'), null, true) ?>" /></a>
<?php require('media_labels_listpage.phtml'); ?>
<h2 class="product-name"><a href="<?php echo $_product->getProductUrl() ?>"><?php $name = Mage::getResourceModel('catalog/product')->getAttributeRawValue($_product->getId(), 'name', $store_id); ?><?php echo $name; ?></a></h2>
<span class="catagory-name"></span>
<?php
$_product = Mage::getModel('catalog/product')->setStoreId($storeId)->load($_product->getId());
$_coreHelper = $this->helper('core');
$regularprice = $_coreHelper->currency($_product->getPrice(),true,false);
$specialprice = $_coreHelper->currency($_product->getSpecialPrice(),true,false);
$test = $_product->getSpecialPrice();
?>
<div class="price-box">
<?php if($test == '') { ?>
<div class="regular-price">
<div class="price"><?php echo $regularprice;?></div>
</div>
<?php } else { ?>
<div class="old-price">
<div class="price"><?php echo $regularprice;?></div>
</div>
<div class="special-price">
<div class="price"><?php echo $specialprice;?></div>
</div>
<?php } ?>
<div class="cls"></div>
</div>
<a class="more-info" href="<?php echo $_product->getProductUrl() ?>">meer</a>
<div class="cls"></div>
<div class="actions">
<button type="button" title="<?php echo $this->__('Add to Cart') ?>" class="btn-cart button" onclick="setLocation('<?php echo $_product->getProductUrl()?>')"><span><span><?php echo $this->__('Add to Cart') ?></span></span></button>
<ul class="add-to-links">
<?php //if($_compareUrl=$this->getAddToCompareUrl($_product)): ?>
<li><a href="<?php echo $_compareUrl ?>" class="link-compare"><?php //echo $this->__('Add to Compare') ?></a></li>
<?php //endif; ?>
<?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; ?>
</ul>
<div class="cls"></div>
</div>
</li>
<?php endforeach; ?>
</ul>
Comments
Post a Comment