Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

Magento featured products extension

  • Loading branch information...
commit 07b2ba19bf3c83f256eef10e0e94614213e864a4 1 parent a492453
@organicinternet authored
View
25 README
@@ -0,0 +1,25 @@
+Featured Products Extension For Magento
+---------------------------------------
+
+Inspired by this Magento wiki article: http://github.com/organicinternet/featured-products-magento/tree/master
+
+This extension allows products to be flagged as 'featured' along with a numerical order in which they should be featured, lowest first. The sidebar block shows all products from the currently visible category with a 'Featured Product Order' > 0, lowest number first. If the category 'Is Anchor' then featured products will be selected, still ordered numerically, from the current category and all its children.
+
+The latest release version of this extension should be installed from Magento Connect. If you would like to contribute or get the bleeding edge version, it is available on GitHub - http://github.com/organicinternet/featured-products-magento/tree/master
+
+Users
+-----
+
+Once installed, a new attribute - oi_featured_product_order will appear for all your products. Setting this to 0 or leaving blank will prevent a product being featured. Any other numerical value will feature the product.
+
+As with all things Magento if you wish to modify the behaviour or layout of this extension, override the phtml by copying into your own theme, or override the block using rewrites rather than modifying the original.
+
+Developers
+----------
+
+If you wish to install this extension in your local magento installation and still version control with git, symlink the following files and directories:
+
+app_code_community_OrganicInternet_FeaturedProducts -> app/code/community/OrganicInternet/FeaturedProducts
+app_design_frontend_default_default_layout_organicinternet_featuredproducts.xml -> app/design/frontend/default/default/layout/organicinternet_featuredproducts.xml
+app_design_frontend_default_default_template_organicinternet_featuredproducts -> app/design/frontend/default/default/template/organicinternet_featuredproducts
+app_etc_modules_OrganicInternet_FeaturedProducts.xml -> app/etc/modules/OrganicInternet_FeaturedProducts.xml
View
38 app_code_community_OrganicInternet_FeaturedProducts/Block/Featured/Products.php
@@ -0,0 +1,38 @@
+<?php
+
+class OrganicInternet_FeaturedProducts_Block_Featured_Products extends Mage_Catalog_Block_Product_Abstract
+{
+ protected $_itemCollection;
+ protected function _prepareData()
+ {
+ $collection = Mage::getResourceModel('catalog/product_collection');
+ Mage::getModel('catalog/layer')->prepareProductCollection($collection);
+
+ $collection->addAttributeToFilter('oi_featured_product_order', array('gt' => 0));
+ $collection->addCategoryFilter(Mage::getSingleton('catalog/layer')->getCurrentCategory());
+
+ $collection->load();
+ $this->_itemCollection = $collection;
+ return $this;
+ }
+
+ protected function _beforeToHtml()
+ {
+ $this->_prepareData();
+ return parent::_beforeToHtml();
+ }
+
+ public function getItems() {
+ return $this->_itemCollection;
+ }
+
+ public function getTopFeaturedItem() {
+ $collection = Mage::getResourceModel('catalog/product_collection');
+ Mage::getModel('catalog/layer')->prepareProductCollection($collection);
+
+ $collection->addAttributeToFilter('oi_featured_product_order', array('gt' => 0));
+ $collection->setPageSize(1);
+ $collection->load();
+ return $collection->getIterator()->current();
+ }
+}
View
5 app_code_community_OrganicInternet_FeaturedProducts/Model/Entity/Setup.php
@@ -0,0 +1,5 @@
+<?php
+
+class OrganicInternet_FeaturedProducts_Model_Entity_Setup extends Mage_Eav_Model_Entity_Setup {
+
+}
View
50 app_code_community_OrganicInternet_FeaturedProducts/etc/config.xml
@@ -0,0 +1,50 @@
+<?xml version="1.0"?>
+<config>
+ <modules>
+ <OrganicInternet_FeaturedProducts>
+ <version>0.0.1</version>
+ </OrganicInternet_FeaturedProducts>
+ </modules>
+ <global>
+ <blocks>
+ <organicinternet_featuredproducts>
+ <class>OrganicInternet_FeaturedProducts_Block</class>
+ </organicinternet_featuredproducts>
+ </blocks>
+ <resources>
+ <organicinternet_featuredproducts_setup>
+ <setup>
+ <module>OrganicInternet_FeaturedProducts</module>
+ <class>OrganicInternet_FeaturedProducts_Model_Entity_Setup</class>
+ </setup>
+ <connection>
+ <use>core_setup</use>
+ </connection>
+ </organicinternet_featuredproducts_setup>
+ <organicinternet_featuredproducts_write>
+ <use>core_write</use>
+ </organicinternet_featuredproducts_write>
+ <organicinternet_featuredproducts_read>
+ <use>core_read</use>
+ </organicinternet_featuredproducts_read>
+ </resources>
+ </global>
+ <frontend>
+ <translate>
+ <modules>
+ <OrganicInternet_FeaturedProducts>
+ <files>
+ <default>OrganicInternet_FeaturedProducts.csv</default>
+ </files>
+ </OrganicInternet_FeaturedProducts>
+ </modules>
+ </translate>
+ <layout>
+ <updates>
+ <organicinternet_featuredproducts>
+ <file>organicinternet_featuredproducts.xml</file>
+ </organicinternet_featuredproducts>
+ </updates>
+ </layout>
+ </frontend>
+</config>
View
16 ...ity_OrganicInternet_FeaturedProducts/sql/organicinternet_featuredproducts_setup/mysql4-install-0.0.1.php
@@ -0,0 +1,16 @@
+<?php
+
+$installer = $this;
+$installer->addAttribute('catalog_product', 'oi_featured_product_order', array(
+ 'type' => 'int',
+ 'backend_type' => 'int',
+ 'label' => 'Featured Product Order',
+ 'global' => true,
+ 'default' => null,
+ 'frontend_class' => 'validate-digits',
+ 'visible' => false,
+ 'required' => false,
+ 'user_defined' => false,
+));
+
+
View
19 app_design_frontend_default_default_layout_organicinternet_featuredproducts.xml
@@ -0,0 +1,19 @@
+<?xml version="1.0"?>
+<layout version="0.0.1">
+ <catalog_category_default>
+ <reference name="left">
+ <block type="organicinternet_featuredproducts/featured_products" name="oi_featuredproducts" as="oi_featuredproducts" template="organicinternet_featuredproducts/featured_products_sidebar.phtml" before="catalog.leftnav"/>
+ </reference>
+ <reference name="content">
+ <block type="organicinternet_featuredproducts/featured_products" name="oi_topfeaturedproduct" as="oi_topfeaturedproduct" template="organicinternet_featuredproducts/top_featured_product.phtml" before="category.products"/>
+ </reference>
+ </catalog_category_default>
+ <catalog_category_layered>
+ <reference name="left">
+ <block type="organicinternet_featuredproducts/featured_products" name="oi_featuredproducts" as="oi_featuredproducts" template="organicinternet_featuredproducts/featured_products_sidebar.phtml" before="catalog.leftnav"/>
+ </reference>
+ <reference name="content">
+ <block type="organicinternet_featuredproducts/featured_products" name="oi_topfeaturedproduct" as="oi_topfeaturedproduct" template="organicinternet_featuredproducts/top_featured_product.phtml" before="category.products"/>
+ </reference>
+ </catalog_category_layered>
+</layout>
View
30 ...esign_frontend_default_default_template_organicinternet_featuredproducts/featured_products_sidebar.phtml
@@ -0,0 +1,30 @@
+<?php if($this->getItems()->getSize()): ?>
+<div class="box base-mini mini-featured-products">
+ <div class="head">
+ <h4><?php echo $this->__('Featured Products') ?></h4>
+ </div>
+ <div class="content">
+ <ol>
+ <?php foreach($this->getItems() as $_item): ?>
+ <li<?php if($_item->isSuper() || !$_item->isSaleable()): ?> class="super-products"<?php endif; ?>>
+ <div class="product-images">
+ <a href="<?php echo $_item->getProductUrl() ?>"><img src="<?php echo $this->helper('catalog/image')->init($_item, 'thumbnail')->resize(50) ?>" alt="<?php echo $this->htmlEscape($_item->getName()) ?>" width="50" height="50" /></a>
+ </div>
+ <div class="product-details">
+ <a href="<?php echo $_item->getProductUrl() ?>"><?php echo $this->htmlEscape($_item->getName()) ?></a>
+ <?php echo $this->helper('catalog/product')->getPriceHtml($_item) ?>
+ <?php if($_item->isSuper()): ?>
+ <a href="<?php echo $_item->getProductUrl() ?>"><?php echo $this->__('View Details') ?></a><br/>
+ <?php else: ?>
+ <button class="form-button" onclick="setLocation('<?php echo $this->getAddToCartUrl($_item) ?>')"><span><?php echo $this->__('Add to Cart') ?></span></button>
+ <?php if ($this->helper('wishlist')->isAllow()) : ?>
+ <a href="<?php echo $this->getAddToWishlistUrl($_item) ?>" class="link-cart"><?php echo $this->__('Add to Wishlist') ?></a>
+ <?php endif; ?>
+ <?php endif; ?>
+ </div>
+ </li>
+ <?php endforeach ?>
+ </ol>
+ </div>
+</div>
+<?php endif ?>
View
23 app_design_frontend_default_default_template_organicinternet_featuredproducts/top_featured_product.phtml
@@ -0,0 +1,23 @@
+<?php if ($_item = $this->getTopFeaturedItem()): ?>
+<div class="product-info-box">
+ <div class="product-essential">
+ <div class="top-featured-product">
+ <div class="product-images">
+ <a href="<?php echo $_item->getProductUrl() ?>"><img src="<?php echo $this->helper('catalog/image')->init($_item, 'image')->resize(200,200) ?>" alt="<?php echo $this->htmlEscape($_item->getName()) ?>" width="200" height="200" /></a>
+ </div>
+ <div class="product-details">
+ <a href="<?php echo $_item->getProductUrl() ?>"><?php echo $this->htmlEscape($_item->getName()) ?></a>
+ <?php echo $this->helper('catalog/product')->getPriceHtml($_item) ?>
+ <?php if($_item->isSuper()): ?>
+ <a href="<?php echo $_item->getProductUrl() ?>"><?php echo $this->__('View Details') ?></a><br/>
+ <?php else: ?>
+ <button class="form-button" onclick="setLocation('<?php echo $this->getAddToCartUrl($_item) ?>')"><span><?php echo $this->__('Add to Cart') ?></span></button><br />
+ <?php if ($this->helper('wishlist')->isAllow()) : ?>
+ <a href="<?php echo $this->getAddToWishlistUrl($_item) ?>" class="link-cart"><?php echo $this->__('Add to Wishlist') ?></a>
+ <?php endif; ?>
+ <?php endif; ?>
+ </div>
+ </div>
+ </div>
+</div>
+<?php endif ?>
View
12 app_etc_modules_OrganicInternet_FeaturedProducts.xml
@@ -0,0 +1,12 @@
+<config>
+ <modules>
+ <OrganicInternet_FeaturedProducts>
+ <active>true</active>
+ <codePool>community</codePool>
+ <depends>
+ <Mage_Catalog />
+ </depends>
+ <version>0.0.1</version>
+ </OrganicInternet_FeaturedProducts>
+ </modules>
+</config>
Please sign in to comment.
Something went wrong with that request. Please try again.