Version Notes
Stable release
Download this release
Release Info
Developer | Edvinas Stulpinas |
Extension | ES_Similarprod |
Version | 1.1.0 |
Comparing to | |
See all releases |
Version 1.1.0
- app/code/community/ES/Similarprod/Block/Products.php +57 -0
- app/code/community/ES/Similarprod/Helper/Data.php +6 -0
- app/code/community/ES/Similarprod/etc/adminhtml.xml +23 -0
- app/code/community/ES/Similarprod/etc/config.xml +60 -0
- app/code/community/ES/Similarprod/etc/system.xml +84 -0
- app/design/frontend/base/default/layout/similarprod.xml +11 -0
- app/design/frontend/base/default/template/similarprod/similarprod_left.phtml +33 -0
- app/design/frontend/base/default/template/similarprod/similarprod_right.phtml +33 -0
- app/etc/modules/ES_Similarprod.xml +9 -0
- package.xml +18 -0
app/code/community/ES/Similarprod/Block/Products.php
ADDED
@@ -0,0 +1,57 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
class ES_Similarprod_Block_Products extends Mage_Catalog_Block_Product_Abstract
|
3 |
+
{
|
4 |
+
protected $_currentProductId;
|
5 |
+
|
6 |
+
protected function getCategoryId()
|
7 |
+
{
|
8 |
+
if (!$this->_currentProductId) {
|
9 |
+
$productId = Mage::registry('current_product')->getId();
|
10 |
+
if (!is_numeric($productId))
|
11 |
+
return;
|
12 |
+
$this->_currentProductId = $productId;
|
13 |
+
}
|
14 |
+
|
15 |
+
$model = Mage::getModel('catalog/product'); //getting product model
|
16 |
+
$product = $model->load($this->_currentProductId);
|
17 |
+
$categoriesIds = $product->getCategoryIds();
|
18 |
+
if (count($categoriesIds) == 0)
|
19 |
+
return;
|
20 |
+
|
21 |
+
return $categoriesIds[0];
|
22 |
+
}
|
23 |
+
|
24 |
+
protected function getProductList()
|
25 |
+
{
|
26 |
+
$categoryId = $this->getCategoryId();
|
27 |
+
if (!is_numeric($categoryId))
|
28 |
+
return;
|
29 |
+
|
30 |
+
$category = Mage::getModel('catalog/category')->load($categoryId);
|
31 |
+
$productList = $category->getProductCollection()
|
32 |
+
->addIdFilter($this->_currentProductId, true)
|
33 |
+
->addAttributeToSelect('name')
|
34 |
+
->addAttributeToSelect('short_description')
|
35 |
+
->addAttributeToSelect('price')
|
36 |
+
->addAttributeToSelect('special_price')
|
37 |
+
->addAttributeToSelect('thumbnail')
|
38 |
+
->addAttributeToSelect('is_salable')
|
39 |
+
->setPageSize(Mage::getStoreConfig('similarprod/general/perblock'));
|
40 |
+
return $productList;
|
41 |
+
}
|
42 |
+
|
43 |
+
protected function getBlockTitle()
|
44 |
+
{
|
45 |
+
return Mage::getStoreConfig('similarprod/general/title');
|
46 |
+
}
|
47 |
+
|
48 |
+
protected function activeRightBlock()
|
49 |
+
{
|
50 |
+
return Mage::getStoreConfig('similarprod/general/blockright');
|
51 |
+
}
|
52 |
+
|
53 |
+
protected function activeLeftBlock()
|
54 |
+
{
|
55 |
+
return Mage::getStoreConfig('similarprod/general/blockleft');
|
56 |
+
}
|
57 |
+
}
|
app/code/community/ES/Similarprod/Helper/Data.php
ADDED
@@ -0,0 +1,6 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
|
3 |
+
class ES_Similarprod_Helper_Data extends Mage_Core_Helper_Abstract
|
4 |
+
{
|
5 |
+
|
6 |
+
}
|
app/code/community/ES/Similarprod/etc/adminhtml.xml
ADDED
@@ -0,0 +1,23 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?xml version="1.0" encoding="UTF-8"?>
|
2 |
+
<config>
|
3 |
+
<acl>
|
4 |
+
<resources>
|
5 |
+
<admin>
|
6 |
+
<children>
|
7 |
+
<system>
|
8 |
+
<children>
|
9 |
+
<config>
|
10 |
+
<children>
|
11 |
+
<similarprod translate="title" module="Similarprod">
|
12 |
+
<title>similarprod</title>
|
13 |
+
<sort_order>60</sort_order>
|
14 |
+
</similarprod>
|
15 |
+
</children>
|
16 |
+
</config>
|
17 |
+
</children>
|
18 |
+
</system>
|
19 |
+
</children>
|
20 |
+
</admin>
|
21 |
+
</resources>
|
22 |
+
</acl>
|
23 |
+
</config>
|
app/code/community/ES/Similarprod/etc/config.xml
ADDED
@@ -0,0 +1,60 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?xml version="1.0"?>
|
2 |
+
<config>
|
3 |
+
<global>
|
4 |
+
<modules>
|
5 |
+
<ES_Similarprod>
|
6 |
+
<version>1.1.0</version>
|
7 |
+
</ES_Similarprod>
|
8 |
+
</modules>
|
9 |
+
|
10 |
+
<blocks>
|
11 |
+
<similarprod>
|
12 |
+
<rewrite>
|
13 |
+
<similarprod>ES_Similarprod_Block_Products</similarprod>
|
14 |
+
</rewrite>
|
15 |
+
</similarprod>
|
16 |
+
</blocks>
|
17 |
+
|
18 |
+
<helpers>
|
19 |
+
<Similarprod>
|
20 |
+
<class>ES_Similarprod_Helper</class>
|
21 |
+
</Similarprod>
|
22 |
+
</helpers>
|
23 |
+
|
24 |
+
</global>
|
25 |
+
|
26 |
+
<frontend>
|
27 |
+
<routers>
|
28 |
+
<similarprod>
|
29 |
+
<use>standard</use>
|
30 |
+
<args>
|
31 |
+
<module>ES_Similarprod</module>
|
32 |
+
<frontName>similarprod</frontName>
|
33 |
+
</args>
|
34 |
+
</similarprod>
|
35 |
+
</routers>
|
36 |
+
<layout>
|
37 |
+
<updates>
|
38 |
+
<similarprod>
|
39 |
+
<file>similarprod.xml</file>
|
40 |
+
</similarprod>
|
41 |
+
</updates>
|
42 |
+
</layout>
|
43 |
+
</frontend>
|
44 |
+
|
45 |
+
<default>
|
46 |
+
<similarprod>
|
47 |
+
<general>
|
48 |
+
<perblock>2</perblock>
|
49 |
+
<showprice>1</showprice>
|
50 |
+
<showactions>1</showactions>
|
51 |
+
<title>Similar products</title>
|
52 |
+
<blockright>1</blockright>
|
53 |
+
<blockleft>1</blockleft>
|
54 |
+
</general>
|
55 |
+
</similarprod>
|
56 |
+
</default>
|
57 |
+
|
58 |
+
|
59 |
+
|
60 |
+
</config>
|
app/code/community/ES/Similarprod/etc/system.xml
ADDED
@@ -0,0 +1,84 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?xml version="1.0"?>
|
2 |
+
<config>
|
3 |
+
<tabs>
|
4 |
+
<es translate="label" module="Similarprod">
|
5 |
+
<label>MageTrend Extensions</label>
|
6 |
+
<sort_order>300</sort_order>
|
7 |
+
</es>
|
8 |
+
</tabs>
|
9 |
+
<sections>
|
10 |
+
<similarprod translate="label" module="Similarprod">
|
11 |
+
<label>Similar Products</label>
|
12 |
+
<tab>es</tab>
|
13 |
+
<frontend_type>text</frontend_type>
|
14 |
+
<sort_order>57</sort_order>
|
15 |
+
<show_in_default>1</show_in_default>
|
16 |
+
<show_in_website>1</show_in_website>
|
17 |
+
<show_in_store>1</show_in_store>
|
18 |
+
<groups>
|
19 |
+
<general translate="label">
|
20 |
+
<label>General</label>
|
21 |
+
<frontend_type>text</frontend_type>
|
22 |
+
<sort_order>10</sort_order>
|
23 |
+
<show_in_default>1</show_in_default>
|
24 |
+
<show_in_website>1</show_in_website>
|
25 |
+
<show_in_store>1</show_in_store>
|
26 |
+
<fields>
|
27 |
+
<title translate="label">
|
28 |
+
<label>Block Title</label>
|
29 |
+
<frontend_type>text</frontend_type>
|
30 |
+
<sort_order>1</sort_order>
|
31 |
+
<show_in_default>1</show_in_default>
|
32 |
+
<show_in_website>1</show_in_website>
|
33 |
+
<show_in_store>1</show_in_store>
|
34 |
+
</title>
|
35 |
+
<perblock translate="label">
|
36 |
+
<label>Products in block</label>
|
37 |
+
<frontend_type>text</frontend_type>
|
38 |
+
<sort_order>1</sort_order>
|
39 |
+
<show_in_default>1</show_in_default>
|
40 |
+
<show_in_website>1</show_in_website>
|
41 |
+
<show_in_store>1</show_in_store>
|
42 |
+
</perblock>
|
43 |
+
<showprice translate="label">
|
44 |
+
<label>Show price</label>
|
45 |
+
<frontend_type>select</frontend_type>
|
46 |
+
<sort_order>2</sort_order>
|
47 |
+
<show_in_default>1</show_in_default>
|
48 |
+
<show_in_website>1</show_in_website>
|
49 |
+
<show_in_store>1</show_in_store>
|
50 |
+
<source_model>adminhtml/system_config_source_yesno</source_model>
|
51 |
+
</showprice>
|
52 |
+
<showactions translate="label">
|
53 |
+
<label>Show Actions</label>
|
54 |
+
<frontend_type>select</frontend_type>
|
55 |
+
<sort_order>3</sort_order>
|
56 |
+
<show_in_default>1</show_in_default>
|
57 |
+
<show_in_website>1</show_in_website>
|
58 |
+
<show_in_store>1</show_in_store>
|
59 |
+
<source_model>adminhtml/system_config_source_yesno</source_model>
|
60 |
+
</showactions>
|
61 |
+
<blockleft translate="label">
|
62 |
+
<label>Block in left sidebar</label>
|
63 |
+
<frontend_type>select</frontend_type>
|
64 |
+
<sort_order>4</sort_order>
|
65 |
+
<show_in_default>1</show_in_default>
|
66 |
+
<show_in_website>1</show_in_website>
|
67 |
+
<show_in_store>1</show_in_store>
|
68 |
+
<source_model>adminhtml/system_config_source_yesno</source_model>
|
69 |
+
</blockleft>
|
70 |
+
<blockright translate="label">
|
71 |
+
<label>Block in right sidebar</label>
|
72 |
+
<frontend_type>select</frontend_type>
|
73 |
+
<sort_order>5</sort_order>
|
74 |
+
<show_in_default>1</show_in_default>
|
75 |
+
<show_in_website>1</show_in_website>
|
76 |
+
<show_in_store>1</show_in_store>
|
77 |
+
<source_model>adminhtml/system_config_source_yesno</source_model>
|
78 |
+
</blockright>
|
79 |
+
</fields>
|
80 |
+
</general>
|
81 |
+
</groups>
|
82 |
+
</similarprod>
|
83 |
+
</sections>
|
84 |
+
</config>
|
app/design/frontend/base/default/layout/similarprod.xml
ADDED
@@ -0,0 +1,11 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?xml version="1.0"?>
|
2 |
+
<layout version="0.1.0">
|
3 |
+
<catalog_product_view translate="label">
|
4 |
+
<reference name="right">
|
5 |
+
<block type="similarprod/similarprod" name="right.similarprod" template="similarprod/similarprod_right.phtml"></block>
|
6 |
+
</reference>
|
7 |
+
<reference name="left">
|
8 |
+
<block type="similarprod/similarprod" name="left.similarprod" template="similarprod/similarprod_left.phtml"></block>
|
9 |
+
</reference>
|
10 |
+
</catalog_product_view>
|
11 |
+
</layout>
|
app/design/frontend/base/default/template/similarprod/similarprod_left.phtml
ADDED
@@ -0,0 +1,33 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
if ($this->activeLeftBlock()):
|
3 |
+
$list = $this->getProductList();
|
4 |
+
if ($list) :
|
5 |
+
?>
|
6 |
+
<div class="block block-mostpopular block2">
|
7 |
+
<div class="block-title">
|
8 |
+
<strong>
|
9 |
+
<span><?php echo $this->getBlockTitle()?></span>
|
10 |
+
</strong>
|
11 |
+
</div>
|
12 |
+
<div class="block-content">
|
13 |
+
<ol class="mini-products-list" id="bestseller-sidebar">
|
14 |
+
<?php foreach($list as $_product): ?>
|
15 |
+
<?php $i++; ?>
|
16 |
+
<li class="item<?php if($i==sizeof($_products) ): ?> last<?php endif; ?>">
|
17 |
+
<a href="<?php echo $_product->getProductUrl() ?>" title="<?php echo $this->htmlEscape($_product->getName()) ?>" class="product-image"><img src="<?php echo $this->helper('catalog/image')->init($_product, 'thumbnail')->resize(50); ?>" width="50" alt="" /></a>
|
18 |
+
<div class="product-details">
|
19 |
+
<p class="product-name"><a href="<?php echo $this->getProductUrl($_product) ?>"><?php echo $this->htmlEscape($_product->getName()) ?></a></p>
|
20 |
+
<?php if (Mage::getStoreConfig('similarprod/general/showprice')):?>
|
21 |
+
<?php echo $this->getPriceHtml($_product, true) ?>
|
22 |
+
<?php endif; ?>
|
23 |
+
<?php if ($_product->getData('is_salable') && Mage::getStoreConfig('similarprod/general/showactions')):?>
|
24 |
+
<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>
|
25 |
+
<?php endif; ?>
|
26 |
+
</div>
|
27 |
+
</li>
|
28 |
+
<?php endforeach; ?>
|
29 |
+
</ol>
|
30 |
+
</div>
|
31 |
+
</div>
|
32 |
+
<?php endif;?>
|
33 |
+
<?php endif;?>
|
app/design/frontend/base/default/template/similarprod/similarprod_right.phtml
ADDED
@@ -0,0 +1,33 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
if ($this->activeRightBlock()):
|
3 |
+
$list = $this->getProductList();
|
4 |
+
if ($list) :
|
5 |
+
?>
|
6 |
+
<div class="block block-mostpopular block2">
|
7 |
+
<div class="block-title">
|
8 |
+
<strong>
|
9 |
+
<span><?php echo $this->getBlockTitle()?></span>
|
10 |
+
</strong>
|
11 |
+
</div>
|
12 |
+
<div class="block-content">
|
13 |
+
<ol class="mini-products-list" id="bestseller-sidebar">
|
14 |
+
<?php foreach($list as $_product): ?>
|
15 |
+
<?php $i++; ?>
|
16 |
+
<li class="item<?php if($i==sizeof($_products) ): ?> last<?php endif; ?>">
|
17 |
+
<a href="<?php echo $_product->getProductUrl() ?>" title="<?php echo $this->htmlEscape($_product->getName()) ?>" class="product-image"><img src="<?php echo $this->helper('catalog/image')->init($_product, 'thumbnail')->resize(50); ?>" width="50px" alt="" /></a>
|
18 |
+
<div class="product-details">
|
19 |
+
<p class="product-name"><a href="<?php echo $this->getProductUrl($_product) ?>"><?php echo $this->htmlEscape($_product->getName()) ?></a></p>
|
20 |
+
<?php if (Mage::getStoreConfig('similarprod/general/showprice')):?>
|
21 |
+
<?php echo $this->getPriceHtml($_product, true) ?>
|
22 |
+
<?php endif; ?>
|
23 |
+
<?php if ($_product->getData('is_salable') && Mage::getStoreConfig('similarprod/general/showactions')):?>
|
24 |
+
<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>
|
25 |
+
<?php endif; ?>
|
26 |
+
</div>
|
27 |
+
</li>
|
28 |
+
<?php endforeach; ?>
|
29 |
+
</ol>
|
30 |
+
</div>
|
31 |
+
</div>
|
32 |
+
<?php endif;?>
|
33 |
+
<?php endif;?>
|
app/etc/modules/ES_Similarprod.xml
ADDED
@@ -0,0 +1,9 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?xml version="1.0"?>
|
2 |
+
<config>
|
3 |
+
<modules>
|
4 |
+
<ES_Similarprod>
|
5 |
+
<active>true</active>
|
6 |
+
<codePool>community</codePool>
|
7 |
+
</ES_Similarprod>
|
8 |
+
</modules>
|
9 |
+
</config>
|
package.xml
ADDED
@@ -0,0 +1,18 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?xml version="1.0"?>
|
2 |
+
<package>
|
3 |
+
<name>ES_Similarprod</name>
|
4 |
+
<version>1.1.0</version>
|
5 |
+
<stability>stable</stability>
|
6 |
+
<license uri="http://opensource.org/licenses/osl-3.0.php">OSL</license>
|
7 |
+
<channel>community</channel>
|
8 |
+
<extends/>
|
9 |
+
<summary>This extension shows similar products in block which is in product view page sidebar. This extension is great way to suggest customer view more products. Similar products are from the same category as current viewed product.</summary>
|
10 |
+
<description>This extension shows similar products in block which is in product view page sidebar. This extension is great way to suggest customer view more products. Similar products are from the same category as current viewed product.</description>
|
11 |
+
<notes>Stable release</notes>
|
12 |
+
<authors><author><name>Edvinas Stulpinas</name><user>edas1</user><email>st.edvinas@gmail.com</email></author></authors>
|
13 |
+
<date>2013-02-09</date>
|
14 |
+
<time>09:51:12</time>
|
15 |
+
<contents><target name="magecommunity"><dir name="ES"><dir name="Similarprod"><dir name="Block"><file name="Products.php" hash="001b340b344d43b385d79cd0d4109bdd"/></dir><dir name="Helper"><file name="Data.php" hash="08394abcdfe632c3e615f27d4bcc7b58"/></dir><dir name="etc"><file name="adminhtml.xml" hash="d6357ffa60e9cf4a9e521681b147307b"/><file name="config.xml" hash="4e609ed4b04e07b8e578c34d80009216"/><file name="system.xml" hash="565f7a2d6bb19c467b19cfe02c62c153"/></dir></dir></dir></target><target name="mageetc"><dir name="modules"><file name="ES_Similarprod.xml" hash="d503759a45626bf906343718de6a6187"/></dir></target><target name="magedesign"><dir name="frontend"><dir name="base"><dir name="default"><dir name="layout"><file name="similarprod.xml" hash="5f41dba2bd884618a3fbf6c123fbe7b0"/></dir><dir name="template"><dir name="similarprod"><file name="similarprod_left.phtml" hash="8fa5fda059674a719fe4c77480432d29"/><file name="similarprod_right.phtml" hash="46f5bdfd9621b61a2599209efec8499c"/></dir></dir></dir></dir></dir></target></contents>
|
16 |
+
<compatible/>
|
17 |
+
<dependencies><required><php><min>5.0.0</min><max>6.0.0</max></php></required></dependencies>
|
18 |
+
</package>
|