Version Notes
default
Download this release
Release Info
| Developer | Magento Core Team |
| Extension | Mtoo_Related |
| Version | 0.0.2 |
| Comparing to | |
| See all releases | |
Version 0.0.2
app/code/community/Mtoo/Related/Block/Product/List.php
ADDED
|
@@ -0,0 +1,121 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
<?php
|
| 2 |
+
/**
|
| 3 |
+
* Magento
|
| 4 |
+
*
|
| 5 |
+
* NOTICE OF LICENSE
|
| 6 |
+
*
|
| 7 |
+
* This source file is subject to the Open Software License (OSL 3.0)
|
| 8 |
+
* that is bundled with this package in the file LICENSE.txt.
|
| 9 |
+
* It is also available through the world-wide-web at this URL:
|
| 10 |
+
* http://opensource.org/licenses/osl-3.0.php
|
| 11 |
+
* If you did not receive a copy of the license and are unable to
|
| 12 |
+
* obtain it through the world-wide-web, please send an email
|
| 13 |
+
* to license@magentocommerce.com so we can send you a copy immediately.
|
| 14 |
+
*
|
| 15 |
+
* DISCLAIMER
|
| 16 |
+
*
|
| 17 |
+
* Do not edit or add to this file if you wish to upgrade Magento to newer
|
| 18 |
+
* versions in the future. If you wish to customize Magento for your
|
| 19 |
+
* needs please refer to http://www.magentocommerce.com for more information.
|
| 20 |
+
*
|
| 21 |
+
* @category Mtoo
|
| 22 |
+
* @package Mtoo_Related
|
| 23 |
+
* @copyright Copyright (c) 2010 Magento Inc. (http://www.magentocommerce.com)
|
| 24 |
+
* @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
|
| 25 |
+
*/
|
| 26 |
+
|
| 27 |
+
|
| 28 |
+
/**
|
| 29 |
+
* override product list related block
|
| 30 |
+
* auto initialize related product According to the category
|
| 31 |
+
*
|
| 32 |
+
* @category Mtoo
|
| 33 |
+
* @package Mtoo_Related
|
| 34 |
+
* @author Magento Core Team <core@magentocommerce.com>
|
| 35 |
+
*/
|
| 36 |
+
class Mtoo_Related_Block_Product_List extends Mage_Catalog_Block_Product_List_Related
|
| 37 |
+
{
|
| 38 |
+
const XML_PATH_ENABLED = "catalog/frontend/auto_related_enabled";
|
| 39 |
+
const XML_PATH_SIZE ="catalog/frontend/auto_related_max_number";
|
| 40 |
+
|
| 41 |
+
public function getRelatedProduct()
|
| 42 |
+
{
|
| 43 |
+
$_product=$this->getProduct();
|
| 44 |
+
$categorys=$_product->getCategoryIds();
|
| 45 |
+
foreach ($categorys as $cat)
|
| 46 |
+
{
|
| 47 |
+
$category = Mage::getModel('catalog/category')->load($cat);
|
| 48 |
+
$curLevel=$category->getLevel();
|
| 49 |
+
|
| 50 |
+
$c[$category->getLevel()] = $cat ;
|
| 51 |
+
}
|
| 52 |
+
if (!empty($c))
|
| 53 |
+
{
|
| 54 |
+
ksort ($c);
|
| 55 |
+
$collection =Mage::getModel('catalog/category')->load(array_pop($c))->getProductCollection();
|
| 56 |
+
$collection->setPageSize($this->getPageSize());
|
| 57 |
+
return $collection;
|
| 58 |
+
}
|
| 59 |
+
return ;
|
| 60 |
+
}
|
| 61 |
+
/**
|
| 62 |
+
* Retrieve current product model
|
| 63 |
+
*
|
| 64 |
+
* @return Mage_Catalog_Model_Product
|
| 65 |
+
*/
|
| 66 |
+
public function getProduct()
|
| 67 |
+
{
|
| 68 |
+
return Mage::registry('product');
|
| 69 |
+
}
|
| 70 |
+
|
| 71 |
+
public function isEnabled()
|
| 72 |
+
{
|
| 73 |
+
return Mage::getStoreConfig(self::XML_PATH_ENABLED, $this->getStoreId());
|
| 74 |
+
}
|
| 75 |
+
public function getPageSize()
|
| 76 |
+
{
|
| 77 |
+
return Mage::getStoreConfig(self::XML_PATH_SIZE, $this->getStoreId());
|
| 78 |
+
}
|
| 79 |
+
public function getStoreId()
|
| 80 |
+
{
|
| 81 |
+
return Mage::app()->getStore()->getStoreId() ;
|
| 82 |
+
}
|
| 83 |
+
protected function _beforeToHtml()
|
| 84 |
+
{
|
| 85 |
+
$this->_prepareData();
|
| 86 |
+
return parent::_beforeToHtml();
|
| 87 |
+
}
|
| 88 |
+
|
| 89 |
+
public function getItems()
|
| 90 |
+
{
|
| 91 |
+
return $this->_itemCollection;
|
| 92 |
+
}
|
| 93 |
+
protected function _prepareData()
|
| 94 |
+
{
|
| 95 |
+
$product = $this->getProduct();
|
| 96 |
+
/* @var $product Mage_Catalog_Model_Product */
|
| 97 |
+
if ($this->getRelatedProduct() && $this->isEnabled())
|
| 98 |
+
$this->_itemCollection = $this->getRelatedProduct();
|
| 99 |
+
else
|
| 100 |
+
$this->_itemCollection = $product->getRelatedProductCollection();
|
| 101 |
+
$this->_itemCollection->addAttributeToSelect('required_options')
|
| 102 |
+
->addAttributeToSort('position', 'asc')
|
| 103 |
+
->addStoreFilter()
|
| 104 |
+
;
|
| 105 |
+
Mage::getResourceSingleton('checkout/cart')->addExcludeProductFilter($this->_itemCollection,
|
| 106 |
+
Mage::getSingleton('checkout/session')->getQuoteId()
|
| 107 |
+
);
|
| 108 |
+
$this->_addProductAttributesAndPrices($this->_itemCollection);
|
| 109 |
+
|
| 110 |
+
// Mage::getSingleton('catalog/product_status')->addSaleableFilterToCollection($this->_itemCollection);
|
| 111 |
+
Mage::getSingleton('catalog/product_visibility')->addVisibleInCatalogFilterToCollection($this->_itemCollection);
|
| 112 |
+
|
| 113 |
+
$this->_itemCollection->load();
|
| 114 |
+
|
| 115 |
+
foreach ($this->_itemCollection as $product) {
|
| 116 |
+
$product->setDoNotUseCategoryId(true);
|
| 117 |
+
}
|
| 118 |
+
|
| 119 |
+
return $this;
|
| 120 |
+
}
|
| 121 |
+
}
|
app/code/community/Mtoo/Related/Helper/Data.php
ADDED
|
@@ -0,0 +1,36 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
<?php
|
| 2 |
+
/**
|
| 3 |
+
* Magento
|
| 4 |
+
*
|
| 5 |
+
* NOTICE OF LICENSE
|
| 6 |
+
*
|
| 7 |
+
* This source file is subject to the Open Software License (OSL 3.0)
|
| 8 |
+
* that is bundled with this package in the file LICENSE.txt.
|
| 9 |
+
* It is also available through the world-wide-web at this URL:
|
| 10 |
+
* http://opensource.org/licenses/osl-3.0.php
|
| 11 |
+
* If you did not receive a copy of the license and are unable to
|
| 12 |
+
* obtain it through the world-wide-web, please send an email
|
| 13 |
+
* to license@magentocommerce.com so we can send you a copy immediately.
|
| 14 |
+
*
|
| 15 |
+
* DISCLAIMER
|
| 16 |
+
*
|
| 17 |
+
* Do not edit or add to this file if you wish to upgrade Magento to newer
|
| 18 |
+
* versions in the future. If you wish to customize Magento for your
|
| 19 |
+
* needs please refer to http://www.magentocommerce.com for more information.
|
| 20 |
+
*
|
| 21 |
+
* @category Find
|
| 22 |
+
* @package Find_Feed
|
| 23 |
+
* @copyright Copyright (c) 2010 Magento Inc. (http://www.magentocommerce.com)
|
| 24 |
+
* @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
|
| 25 |
+
*/
|
| 26 |
+
|
| 27 |
+
|
| 28 |
+
/**
|
| 29 |
+
* TheFind feed helper
|
| 30 |
+
*
|
| 31 |
+
* @category Find
|
| 32 |
+
* @package Find_Feed
|
| 33 |
+
*/
|
| 34 |
+
class Mtoo_Related_Helper_Data extends Mage_Core_Helper_Abstract
|
| 35 |
+
{
|
| 36 |
+
}
|
app/code/community/Mtoo/Related/etc/config.xml
ADDED
|
@@ -0,0 +1,43 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
<?xml version="1.0"?>
|
| 2 |
+
<!--
|
| 3 |
+
/**
|
| 4 |
+
* Magento
|
| 5 |
+
*
|
| 6 |
+
* NOTICE OF LICENSE
|
| 7 |
+
*
|
| 8 |
+
* This source file is subject to the Academic Free License (AFL 3.0)
|
| 9 |
+
* that is bundled with this package in the file LICENSE_AFL.txt.
|
| 10 |
+
* It is also available through the world-wide-web at this URL:
|
| 11 |
+
* http://opensource.org/licenses/afl-3.0.php
|
| 12 |
+
* If you did not receive a copy of the license and are unable to
|
| 13 |
+
* obtain it through the world-wide-web, please send an email
|
| 14 |
+
* to license@magentocommerce.com so we can send you a copy immediately.
|
| 15 |
+
*
|
| 16 |
+
* DISCLAIMER
|
| 17 |
+
*
|
| 18 |
+
* Do not edit or add to this file if you wish to upgrade Magento to newer
|
| 19 |
+
* versions in the future. If you wish to customize Magento for your
|
| 20 |
+
* needs please refer to http://www.magentocommerce.com for more information.
|
| 21 |
+
*
|
| 22 |
+
* @category Mtoo
|
| 23 |
+
* @package Mtoo_Related
|
| 24 |
+
* @copyright Copyright (c) 2010 Magento Inc. (http://www.magentocommerce.com)
|
| 25 |
+
* @license http://opensource.org/licenses/afl-3.0.php Academic Free License (AFL 3.0)
|
| 26 |
+
*/
|
| 27 |
+
-->
|
| 28 |
+
<config>
|
| 29 |
+
<modules>
|
| 30 |
+
<Mtoo_Related>
|
| 31 |
+
<version>0.0.2</version>
|
| 32 |
+
</Mtoo_Related>
|
| 33 |
+
</modules>
|
| 34 |
+
<global>
|
| 35 |
+
<blocks>
|
| 36 |
+
<catalog>
|
| 37 |
+
<rewrite>
|
| 38 |
+
<product_list_related>Mtoo_Related_Block_Product_List</product_list_related>
|
| 39 |
+
</rewrite>
|
| 40 |
+
</catalog>
|
| 41 |
+
</blocks>
|
| 42 |
+
</global>
|
| 43 |
+
</config>
|
app/code/community/Mtoo/Related/etc/system.xml
ADDED
|
@@ -0,0 +1,61 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
<?xml version="1.0"?>
|
| 2 |
+
<!--
|
| 3 |
+
/** * Magento * * NOTICE OF LICENSE * * This source file is subject to
|
| 4 |
+
the Academic Free License (AFL 3.0) * that is bundled with this
|
| 5 |
+
package in the file LICENSE_AFL.txt. * It is also available through
|
| 6 |
+
the world-wide-web at this URL: *
|
| 7 |
+
http://opensource.org/licenses/afl-3.0.php * If you did not receive a
|
| 8 |
+
copy of the license and are unable to * obtain it through the
|
| 9 |
+
world-wide-web, please send an email * to license@magentocommerce.com
|
| 10 |
+
so we can send you a copy immediately. * * DISCLAIMER * * Do not edit
|
| 11 |
+
or add to this file if you wish to upgrade Magento to newer * versions
|
| 12 |
+
in the future. If you wish to customize Magento for your * needs
|
| 13 |
+
please refer to http://www.magentocommerce.com for more information. *
|
| 14 |
+
* @category Mtoo * @package Mtoo_Related * @copyright Copyright (c)
|
| 15 |
+
2010 Magento Inc. (http://www.magentocommerce.com) * @license
|
| 16 |
+
http://opensource.org/licenses/afl-3.0.php Academic Free License (AFL
|
| 17 |
+
3.0) */
|
| 18 |
+
-->
|
| 19 |
+
<config>
|
| 20 |
+
<sections>
|
| 21 |
+
<catalog translate="label" module="catalog">
|
| 22 |
+
<class>separator-top</class>
|
| 23 |
+
<label>Catalog</label>
|
| 24 |
+
<tab>catalog</tab>
|
| 25 |
+
<frontend_type>text</frontend_type>
|
| 26 |
+
<sort_order>40</sort_order>
|
| 27 |
+
<show_in_default>1</show_in_default>
|
| 28 |
+
<show_in_website>1</show_in_website>
|
| 29 |
+
<show_in_store>1</show_in_store>
|
| 30 |
+
<groups>
|
| 31 |
+
<frontend translate="label">
|
| 32 |
+
<label>Frontend</label>
|
| 33 |
+
<frontend_type>text</frontend_type>
|
| 34 |
+
<sort_order>100</sort_order>
|
| 35 |
+
<show_in_default>1</show_in_default>
|
| 36 |
+
<show_in_website>1</show_in_website>
|
| 37 |
+
<show_in_store>1</show_in_store>
|
| 38 |
+
<fields>
|
| 39 |
+
<auto_related_enabled translate="label">
|
| 40 |
+
<label>Enabled Auto Related Product</label>
|
| 41 |
+
<source_model>adminhtml/system_config_source_yesno</source_model>
|
| 42 |
+
<frontend_type>select</frontend_type>
|
| 43 |
+
<sort_order>500</sort_order>
|
| 44 |
+
<show_in_default>1</show_in_default>
|
| 45 |
+
<show_in_website>1</show_in_website>
|
| 46 |
+
<show_in_store>1</show_in_store>
|
| 47 |
+
</auto_related_enabled>
|
| 48 |
+
<auto_related_max_number translate="label">
|
| 49 |
+
<label>Maximum Related Product Display On Product View Page</label>
|
| 50 |
+
<frontend_type>text</frontend_type>
|
| 51 |
+
<sort_order>501</sort_order>
|
| 52 |
+
<show_in_default>1</show_in_default>
|
| 53 |
+
<show_in_website>1</show_in_website>
|
| 54 |
+
<show_in_store>1</show_in_store>
|
| 55 |
+
</auto_related_max_number>
|
| 56 |
+
</fields>
|
| 57 |
+
</frontend>
|
| 58 |
+
</groups>
|
| 59 |
+
</catalog>
|
| 60 |
+
</sections>
|
| 61 |
+
</config>
|
app/etc/modules/Mtoo_Related.xml
ADDED
|
@@ -0,0 +1,35 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
<?xml version="1.0"?>
|
| 2 |
+
<!--
|
| 3 |
+
/**
|
| 4 |
+
* Magento
|
| 5 |
+
*
|
| 6 |
+
* NOTICE OF LICENSE
|
| 7 |
+
*
|
| 8 |
+
* This source file is subject to the Academic Free License (AFL 3.0)
|
| 9 |
+
* that is bundled with this package in the file LICENSE_AFL.txt.
|
| 10 |
+
* It is also available through the world-wide-web at this URL:
|
| 11 |
+
* http://opensource.org/licenses/afl-3.0.php
|
| 12 |
+
* If you did not receive a copy of the license and are unable to
|
| 13 |
+
* obtain it through the world-wide-web, please send an email
|
| 14 |
+
* to license@magentocommerce.com so we can send you a copy immediately.
|
| 15 |
+
*
|
| 16 |
+
* DISCLAIMER
|
| 17 |
+
*
|
| 18 |
+
* Do not edit or add to this file if you wish to upgrade Magento to newer
|
| 19 |
+
* versions in the future. If you wish to customize Magento for your
|
| 20 |
+
* needs please refer to http://www.magentocommerce.com for more information.
|
| 21 |
+
*
|
| 22 |
+
* @category Mtoo
|
| 23 |
+
* @package Mtoo_Related
|
| 24 |
+
* @copyright Copyright (c) 2010 Magento Inc. (http://www.magentocommerce.com)
|
| 25 |
+
* @license http://opensource.org/licenses/afl-3.0.php Academic Free License (AFL 3.0)
|
| 26 |
+
*/
|
| 27 |
+
-->
|
| 28 |
+
<config>
|
| 29 |
+
<modules>
|
| 30 |
+
<Mtoo_Related>
|
| 31 |
+
<active>true</active>
|
| 32 |
+
<codePool>community</codePool>
|
| 33 |
+
</Mtoo_Related>
|
| 34 |
+
</modules>
|
| 35 |
+
</config>
|
package.xml
ADDED
|
@@ -0,0 +1,18 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
<?xml version="1.0"?>
|
| 2 |
+
<package>
|
| 3 |
+
<name>Mtoo_Related</name>
|
| 4 |
+
<version>0.0.2</version>
|
| 5 |
+
<stability>stable</stability>
|
| 6 |
+
<license>www.magehelper.net</license>
|
| 7 |
+
<channel>community</channel>
|
| 8 |
+
<extends/>
|
| 9 |
+
<summary>auto general related product</summary>
|
| 10 |
+
<description>auto general related product</description>
|
| 11 |
+
<notes>default</notes>
|
| 12 |
+
<authors><author><name>Mtoo</name><user>auto-converted</user><email>sjgoodjob@gmail.com</email></author></authors>
|
| 13 |
+
<date>2012-03-10</date>
|
| 14 |
+
<time>08:43:50</time>
|
| 15 |
+
<contents><target name="mageetc"><dir name="modules"><file name="Mtoo_Related.xml" hash="3bc419b9c0930ddf926cd31e803c59ff"/></dir></target><target name="magecommunity"><dir name="Mtoo"><dir name="Related"><dir name="Block"><dir name="Product"><file name="List.php" hash="bfeddb0bd80b920ba2ea11718a0defa5"/></dir></dir><dir name="etc"><file name="config.xml" hash="0dc72cedff1f561e7ddd51f68250150c"/><file name="system.xml" hash="b6f602817c6ab5846857a7fe17098983"/></dir><dir name="Helper"><file name="Data.php" hash="e05105d665cfa4888a87f575d2ae1607"/></dir></dir></dir></target></contents>
|
| 16 |
+
<compatible/>
|
| 17 |
+
<dependencies/>
|
| 18 |
+
</package>
|
