Version Notes
Setting Related Products,Up-sell Products,Cross-sell Products easily,powerful assistant.
Download this release
Release Info
Developer | iifire |
Extension | advanced_related_product |
Version | 1.6.1 |
Comparing to | |
See all releases |
Code changes from version 1.6.0 to 1.6.1
- app/code/local/Mage/Catalog/Block/Product/List/Crosssell.php +121 -0
- app/code/local/Mage/Catalog/Block/Product/List/Related.php +101 -0
- app/code/local/Mage/Catalog/Block/Product/List/Upsell.php +189 -0
- app/design/adminhtml/default/default/layout/iifire_category.xml +17 -0
- app/design/adminhtml/default/default/template/iifire/category/categories.phtml +201 -0
- app/design/adminhtml/default/default/template/iifire/category/tree.phtml +499 -0
- app/etc/modules/Iifire_Category.xml +9 -0
- package.xml +4 -4
app/code/local/Mage/Catalog/Block/Product/List/Crosssell.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 Mage
|
22 |
+
* @package Mage_Catalog
|
23 |
+
* @copyright Copyright (c) 2011 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 |
+
* Catalog product related items block
|
30 |
+
*
|
31 |
+
* @category Mage
|
32 |
+
* @package Mage_Catalog
|
33 |
+
* @author Magento Core Team <core@magentocommerce.com>
|
34 |
+
*/
|
35 |
+
|
36 |
+
class Mage_Catalog_Block_Product_List_Crosssell extends Mage_Catalog_Block_Product_Abstract
|
37 |
+
{
|
38 |
+
/**
|
39 |
+
* Default MAP renderer type
|
40 |
+
*
|
41 |
+
* @var string
|
42 |
+
*/
|
43 |
+
protected $_mapRenderer = 'msrp_item';
|
44 |
+
|
45 |
+
/**
|
46 |
+
* Crosssell item collection
|
47 |
+
*
|
48 |
+
* @var Mage_Catalog_Model_Resource_Eav_Mysql4_Product_Link_Product_Collection
|
49 |
+
*/
|
50 |
+
protected $_itemCollection;
|
51 |
+
|
52 |
+
/**
|
53 |
+
* Prepare crosssell items data
|
54 |
+
*
|
55 |
+
* @return Mage_Catalog_Block_Product_List_Crosssell
|
56 |
+
*/
|
57 |
+
protected function _prepareData()
|
58 |
+
{
|
59 |
+
$product = Mage::registry('product');
|
60 |
+
/* @var $product Mage_Catalog_Model_Product */
|
61 |
+
$this->_itemCollection = $product->getCrossSellProductCollection();
|
62 |
+
if(!count($product->getCrossSellProductCollection())){
|
63 |
+
$helperIifireCategory = Mage::helper('icategory');
|
64 |
+
if ($product->getCategoryId()) {
|
65 |
+
$categoryId = $product->getCategoryId();
|
66 |
+
} else {
|
67 |
+
$categoryIdArray = $product->getCategoryIds();
|
68 |
+
shuffle($categoryIdArray);
|
69 |
+
$categoryId = $categoryIdArray[0];
|
70 |
+
}
|
71 |
+
$category = Mage::getModel('catalog/category')->load($categoryId);
|
72 |
+
$categoryIds = $helperIifireCategory->getCategoryIdString($category->getCrosssellCategories());
|
73 |
+
if ($categoryIds) {
|
74 |
+
$collection = $helperIifireCategory->getProductCollectionByCategoryIds($categoryIds,$product->getId());
|
75 |
+
$this->_itemCollection = $collection->setPageSize($helperIifireCategory->getCrosssellNum())
|
76 |
+
->load();
|
77 |
+
}
|
78 |
+
}
|
79 |
+
//$this->_itemCollection = $product->getCrossSellProductCollection()
|
80 |
+
$this->_itemCollection->addAttributeToSelect(Mage::getSingleton('catalog/config')->getProductAttributes())
|
81 |
+
->addAttributeToSort('position', 'asc')
|
82 |
+
->addStoreFilter()
|
83 |
+
;
|
84 |
+
|
85 |
+
// Mage::getSingleton('catalog/product_status')->addSaleableFilterToCollection($this->_itemCollection);
|
86 |
+
Mage::getSingleton('catalog/product_visibility')->addVisibleInCatalogFilterToCollection($this->_itemCollection);
|
87 |
+
|
88 |
+
$this->_itemCollection
|
89 |
+
->setPageSize(Mage::helper('icategory')->getCrosssellNum())
|
90 |
+
->load();
|
91 |
+
|
92 |
+
foreach ($this->_itemCollection as $product) {
|
93 |
+
$product->setDoNotUseCategoryId(true);
|
94 |
+
}
|
95 |
+
|
96 |
+
return $this;
|
97 |
+
}
|
98 |
+
|
99 |
+
/**
|
100 |
+
* Before rendering html process
|
101 |
+
* Prepare items collection
|
102 |
+
*
|
103 |
+
* @return Mage_Catalog_Block_Product_List_Crosssell
|
104 |
+
*/
|
105 |
+
protected function _beforeToHtml()
|
106 |
+
{
|
107 |
+
$this->_prepareData();
|
108 |
+
return parent::_beforeToHtml();
|
109 |
+
}
|
110 |
+
|
111 |
+
/**
|
112 |
+
* Retrieve crosssell items collection
|
113 |
+
*
|
114 |
+
* @return Mage_Catalog_Model_Resource_Eav_Mysql4_Product_Link_Product_Collection
|
115 |
+
*/
|
116 |
+
public function getItems()
|
117 |
+
{
|
118 |
+
return $this->_itemCollection;
|
119 |
+
}
|
120 |
+
|
121 |
+
}
|
app/code/local/Mage/Catalog/Block/Product/List/Related.php
ADDED
@@ -0,0 +1,101 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
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 Mage
|
22 |
+
* @package Mage_Catalog
|
23 |
+
* @copyright Copyright (c) 2011 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 |
+
* Catalog product related items block
|
30 |
+
*
|
31 |
+
* @category Mage
|
32 |
+
* @package Mage_Catalog
|
33 |
+
* @author Magento Core Team <core@magentocommerce.com>
|
34 |
+
*/
|
35 |
+
class Mage_Catalog_Block_Product_List_Related extends Mage_Catalog_Block_Product_Abstract
|
36 |
+
{
|
37 |
+
/**
|
38 |
+
* Default MAP renderer type
|
39 |
+
*
|
40 |
+
* @var string
|
41 |
+
*/
|
42 |
+
protected $_mapRenderer = 'msrp_noform';
|
43 |
+
|
44 |
+
protected $_itemCollection;
|
45 |
+
|
46 |
+
protected function _prepareData()
|
47 |
+
{
|
48 |
+
$product = Mage::registry('product');
|
49 |
+
/* @var $product Mage_Catalog_Model_Product */
|
50 |
+
|
51 |
+
$this->_itemCollection = $product->getRelatedProductCollection();
|
52 |
+
if(!count($product->getRelatedProductCollection())){
|
53 |
+
$helperIifireCategory = Mage::helper('icategory');
|
54 |
+
if ($product->getCategoryId()) {
|
55 |
+
$categoryId = $product->getCategoryId();
|
56 |
+
} else {
|
57 |
+
$categoryIdArray = $product->getCategoryIds();
|
58 |
+
shuffle($categoryIdArray);
|
59 |
+
$categoryId = $categoryIdArray[0];
|
60 |
+
}
|
61 |
+
$category = Mage::getModel('catalog/category')->load($categoryId);
|
62 |
+
$categoryIds = $helperIifireCategory->getCategoryIdString($category->getRelatedCategories());
|
63 |
+
if ($categoryIds) {
|
64 |
+
$collection = $helperIifireCategory->getProductCollectionByCategoryIds($categoryIds,$product->getId());
|
65 |
+
$this->_itemCollection = $collection->setPageSize($helperIifireCategory->getRelatedNum())
|
66 |
+
->load();
|
67 |
+
}
|
68 |
+
}
|
69 |
+
$this->_itemCollection->addAttributeToSelect('required_options')
|
70 |
+
->addAttributeToSort('position', Varien_Db_Select::SQL_ASC)
|
71 |
+
->addStoreFilter()
|
72 |
+
;
|
73 |
+
|
74 |
+
if (Mage::helper('catalog')->isModuleEnabled('Mage_Checkout')) {
|
75 |
+
Mage::getResourceSingleton('checkout/cart')->addExcludeProductFilter($this->_itemCollection,
|
76 |
+
Mage::getSingleton('checkout/session')->getQuoteId()
|
77 |
+
);
|
78 |
+
$this->_addProductAttributesAndPrices($this->_itemCollection);
|
79 |
+
}
|
80 |
+
// Mage::getSingleton('catalog/product_status')->addSaleableFilterToCollection($this->_itemCollection);
|
81 |
+
Mage::getSingleton('catalog/product_visibility')->addVisibleInCatalogFilterToCollection($this->_itemCollection);
|
82 |
+
|
83 |
+
$this->_itemCollection->load();
|
84 |
+
foreach ($this->_itemCollection as $product) {
|
85 |
+
$product->setDoNotUseCategoryId(true);
|
86 |
+
}
|
87 |
+
|
88 |
+
return $this;
|
89 |
+
}
|
90 |
+
|
91 |
+
protected function _beforeToHtml()
|
92 |
+
{
|
93 |
+
$this->_prepareData();
|
94 |
+
return parent::_beforeToHtml();
|
95 |
+
}
|
96 |
+
|
97 |
+
public function getItems()
|
98 |
+
{
|
99 |
+
return $this->_itemCollection;
|
100 |
+
}
|
101 |
+
}
|
app/code/local/Mage/Catalog/Block/Product/List/Upsell.php
ADDED
@@ -0,0 +1,189 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
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 Mage
|
22 |
+
* @package Mage_Catalog
|
23 |
+
* @copyright Copyright (c) 2011 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 |
+
* Catalog product related items block
|
29 |
+
*
|
30 |
+
* @category Mage
|
31 |
+
* @package Mage_Catalog
|
32 |
+
* @author Magento Core Team <core@magentocommerce.com>
|
33 |
+
*/
|
34 |
+
|
35 |
+
class Mage_Catalog_Block_Product_List_Upsell extends Mage_Catalog_Block_Product_Abstract
|
36 |
+
{
|
37 |
+
/**
|
38 |
+
* Default MAP renderer type
|
39 |
+
*
|
40 |
+
* @var string
|
41 |
+
*/
|
42 |
+
protected $_mapRenderer = 'msrp_noform';
|
43 |
+
|
44 |
+
protected $_columnCount = 4;
|
45 |
+
|
46 |
+
protected $_items;
|
47 |
+
|
48 |
+
protected $_itemCollection;
|
49 |
+
|
50 |
+
protected $_itemLimits = array();
|
51 |
+
|
52 |
+
protected function _prepareData()
|
53 |
+
{
|
54 |
+
$product = Mage::registry('product');
|
55 |
+
/* @var $product Mage_Catalog_Model_Product */
|
56 |
+
$this->_itemCollection = $product->getUpSellProductCollection();
|
57 |
+
if(!count($product->getUpSellProductCollection())){
|
58 |
+
$helperIifireCategory = Mage::helper('icategory');
|
59 |
+
if ($product->getCategoryId()) {
|
60 |
+
$categoryId = $product->getCategoryId();
|
61 |
+
} else {
|
62 |
+
$categoryIdArray = $product->getCategoryIds();
|
63 |
+
shuffle($categoryIdArray);
|
64 |
+
$categoryId = $categoryIdArray[0];
|
65 |
+
}
|
66 |
+
$category = Mage::getModel('catalog/category')->load($categoryId);
|
67 |
+
$categoryIds = $helperIifireCategory->getCategoryIdString($category->getUpsellCategories());
|
68 |
+
if ($categoryIds) {
|
69 |
+
$collection = $helperIifireCategory->getProductCollectionByCategoryIds($categoryIds,$product->getId());
|
70 |
+
$this->_itemCollection = $collection->setPageSize($helperIifireCategory->getCrosssellNum())
|
71 |
+
->load();
|
72 |
+
}
|
73 |
+
}
|
74 |
+
//$this->_itemCollection = $product->getUpSellProductCollection()
|
75 |
+
$this->_itemCollection->addAttributeToSort('position', Varien_Db_Select::SQL_ASC)
|
76 |
+
->addStoreFilter();
|
77 |
+
if (Mage::helper('catalog')->isModuleEnabled('Mage_Checkout')) {
|
78 |
+
Mage::getResourceSingleton('checkout/cart')->addExcludeProductFilter($this->_itemCollection,
|
79 |
+
Mage::getSingleton('checkout/session')->getQuoteId()
|
80 |
+
);
|
81 |
+
|
82 |
+
$this->_addProductAttributesAndPrices($this->_itemCollection);
|
83 |
+
}
|
84 |
+
// Mage::getSingleton('catalog/product_status')->addSaleableFilterToCollection($this->_itemCollection);
|
85 |
+
Mage::getSingleton('catalog/product_visibility')->addVisibleInCatalogFilterToCollection($this->_itemCollection);
|
86 |
+
|
87 |
+
if ($this->getItemLimit('upsell') > 0) {
|
88 |
+
$this->_itemCollection->setPageSize($this->getItemLimit('upsell'));
|
89 |
+
}
|
90 |
+
|
91 |
+
$this->_itemCollection
|
92 |
+
->setPageSize(Mage::helper('icategory')->getUpsellNum())
|
93 |
+
->load();
|
94 |
+
|
95 |
+
/**
|
96 |
+
* Updating collection with desired items
|
97 |
+
*/
|
98 |
+
Mage::dispatchEvent('catalog_product_upsell', array(
|
99 |
+
'product' => $product,
|
100 |
+
'collection' => $this->_itemCollection,
|
101 |
+
'limit' => $this->getItemLimit()
|
102 |
+
));
|
103 |
+
|
104 |
+
foreach ($this->_itemCollection as $product) {
|
105 |
+
$product->setDoNotUseCategoryId(true);
|
106 |
+
}
|
107 |
+
|
108 |
+
return $this;
|
109 |
+
}
|
110 |
+
|
111 |
+
protected function _beforeToHtml()
|
112 |
+
{
|
113 |
+
$this->_prepareData();
|
114 |
+
return parent::_beforeToHtml();
|
115 |
+
}
|
116 |
+
|
117 |
+
public function getItemCollection()
|
118 |
+
{
|
119 |
+
return $this->_itemCollection;
|
120 |
+
}
|
121 |
+
|
122 |
+
public function getItems()
|
123 |
+
{
|
124 |
+
if (is_null($this->_items)) {
|
125 |
+
$this->_items = $this->getItemCollection()->getItems();
|
126 |
+
}
|
127 |
+
return $this->_items;
|
128 |
+
}
|
129 |
+
|
130 |
+
public function getRowCount()
|
131 |
+
{
|
132 |
+
return ceil(count($this->getItemCollection()->getItems())/$this->getColumnCount());
|
133 |
+
}
|
134 |
+
|
135 |
+
public function setColumnCount($columns)
|
136 |
+
{
|
137 |
+
if (intval($columns) > 0) {
|
138 |
+
$this->_columnCount = intval($columns);
|
139 |
+
}
|
140 |
+
return $this;
|
141 |
+
}
|
142 |
+
|
143 |
+
public function getColumnCount()
|
144 |
+
{
|
145 |
+
return $this->_columnCount;
|
146 |
+
}
|
147 |
+
|
148 |
+
public function resetItemsIterator()
|
149 |
+
{
|
150 |
+
$this->getItems();
|
151 |
+
reset($this->_items);
|
152 |
+
}
|
153 |
+
|
154 |
+
public function getIterableItem()
|
155 |
+
{
|
156 |
+
$item = current($this->_items);
|
157 |
+
next($this->_items);
|
158 |
+
return $item;
|
159 |
+
}
|
160 |
+
|
161 |
+
/**
|
162 |
+
* Set how many items we need to show in upsell block
|
163 |
+
* Notice: this parametr will be also applied
|
164 |
+
*
|
165 |
+
* @param string $type
|
166 |
+
* @param int $limit
|
167 |
+
* @return Mage_Catalog_Block_Product_List_Upsell
|
168 |
+
*/
|
169 |
+
public function setItemLimit($type, $limit)
|
170 |
+
{
|
171 |
+
if (intval($limit) > 0) {
|
172 |
+
$this->_itemLimits[$type] = intval($limit);
|
173 |
+
}
|
174 |
+
return $this;
|
175 |
+
}
|
176 |
+
|
177 |
+
public function getItemLimit($type = '')
|
178 |
+
{
|
179 |
+
if ($type == '') {
|
180 |
+
return $this->_itemLimits;
|
181 |
+
}
|
182 |
+
if (isset($this->_itemLimits[$type])) {
|
183 |
+
return $this->_itemLimits[$type];
|
184 |
+
}
|
185 |
+
else {
|
186 |
+
return 0;
|
187 |
+
}
|
188 |
+
}
|
189 |
+
}
|
app/design/adminhtml/default/default/layout/iifire_category.xml
ADDED
@@ -0,0 +1,17 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?xml version="1.0"?>
|
2 |
+
<layout>
|
3 |
+
<adminhtml_iifire_category_index>
|
4 |
+
<reference name="content">
|
5 |
+
<block type="iifire_category/adminhtml_categories" name="iifire.categories" template="iifire/category/categories.phtml"/>
|
6 |
+
</reference>
|
7 |
+
<reference name="left">
|
8 |
+
<block name="category.tree" type="iifire_category/adminhtml_tree" template="iifire/category/tree.phtml" />
|
9 |
+
</reference>
|
10 |
+
|
11 |
+
</adminhtml_iifire_category_index>
|
12 |
+
<adminhtml_iifire_category_edit>
|
13 |
+
<reference name="content">
|
14 |
+
<block type="iifire_category/adminhtml_categories" name="iifire.categories" template="iifire/category/categories.phtml"/>
|
15 |
+
</reference>
|
16 |
+
</adminhtml_iifire_category_edit>
|
17 |
+
</layout>
|
app/design/adminhtml/default/default/template/iifire/category/categories.phtml
ADDED
@@ -0,0 +1,201 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<form action="<?php echo $this->getCategoriesSaveUrl(); ?>" method="post" id="category_edit_form">
|
2 |
+
<div id="category-edit-container">
|
3 |
+
<?php if($category = $this->getCategory()): ?>
|
4 |
+
<div class="content-header">
|
5 |
+
<h3 class="icon-head head-categories"><?php echo $category->getName();?> (ID: <?php echo $category->getId(); ?>)</h3>
|
6 |
+
<div class="content-buttons-placeholder" style="width: 0px; height: 14px;"><p class="content-buttons form-buttons" style="">
|
7 |
+
<button style="" onclick="iifireCategorySubmit('<?php echo $this->getSaveUrl(); ?>', true)" class="scalable save" type="button" id="id_008424b0a33735e6aa2104d576f2e71e"><span>Save Setting</span></button></p></div>
|
8 |
+
</div>
|
9 |
+
<?php endif; ?>
|
10 |
+
<div class="entry-edit">
|
11 |
+
<div class="entry-edit-head">
|
12 |
+
<h4 class="icon-head head-edit-form fieldset-legend"><?php echo Mage::helper('catalog')->__('Pw Categories Manager') ?></h4>
|
13 |
+
</div>
|
14 |
+
<div class="type_switcher_container">
|
15 |
+
<p class="switcher">
|
16 |
+
<label for="type_switcher">Choose Type</label>
|
17 |
+
<select name="type_switcher" id="type_categoy" <?php if($this->getCategory()): ?>onchange="updateContent('<?php echo $this->getReloadUrl(); ?>')"<?php endif; ?>>
|
18 |
+
<?php $options = Mage::helper('icategory')->getTypeOptions(); ?>
|
19 |
+
<?php foreach ($options as $key => $value): ?>
|
20 |
+
<option value="<?php echo $key; ?>" <?php if ($key==$this->getCategoryType()): ?> selected <?php endif; ?>><?php echo $value; ?></option>
|
21 |
+
<?php endforeach; ?>
|
22 |
+
</select>
|
23 |
+
</p>
|
24 |
+
</div>
|
25 |
+
<fieldset id="grop_fields">
|
26 |
+
<input type="hidden" name="category_id" id="category_id" value="<?php if ($this->getCategory()): echo $this->getCategory()->getId(); endif;?>" />
|
27 |
+
<input type="hidden" name="category_ids" id="product_categories" value="<?php echo $this->getIdsString() ?>">
|
28 |
+
<div id="product-categories" class="tree">
|
29 |
+
<?php if (!$this->getCategory()): ?>
|
30 |
+
<p><?php echo $this->__('Please select a category first'); ?></p>
|
31 |
+
<?php endif; ?>
|
32 |
+
</div>
|
33 |
+
</fieldset>
|
34 |
+
</div>
|
35 |
+
|
36 |
+
<?php if ($this->getCategory()): ?>
|
37 |
+
<script type="text/javascript">
|
38 |
+
|
39 |
+
</script>
|
40 |
+
<?php if($this->getRootNode() && $this->getRootNode()->hasChildren()): ?>
|
41 |
+
<script type="text/javascript">
|
42 |
+
|
43 |
+
Ext.EventManager.onDocumentReady(function() {
|
44 |
+
var categoryLoader = new Ext.tree.TreeLoader({
|
45 |
+
dataUrl: '<?php echo $this->getLoadTreeUrl()?>'
|
46 |
+
});
|
47 |
+
|
48 |
+
categoryLoader.createNode = function(config) {
|
49 |
+
config.uiProvider = Ext.tree.CheckboxNodeUI;
|
50 |
+
var node;
|
51 |
+
if (config.children && !config.children.length) {
|
52 |
+
delete(config.children);
|
53 |
+
node = new Ext.tree.AsyncTreeNode(config);
|
54 |
+
|
55 |
+
} else {
|
56 |
+
node = new Ext.tree.TreeNode(config);
|
57 |
+
}
|
58 |
+
return node;
|
59 |
+
};
|
60 |
+
|
61 |
+
categoryLoader.on("beforeload", function(treeLoader, node) {
|
62 |
+
treeLoader.baseParams.category = node.attributes.id;
|
63 |
+
});
|
64 |
+
|
65 |
+
categoryLoader.on("load", function(treeLoader, node, config) {
|
66 |
+
varienWindowOnload();
|
67 |
+
});
|
68 |
+
|
69 |
+
var tree = new Ext.tree.TreePanel('product-categories', {
|
70 |
+
animate:true,
|
71 |
+
loader: categoryLoader,
|
72 |
+
enableDD:false,
|
73 |
+
containerScroll: true,
|
74 |
+
rootUIProvider: Ext.tree.CheckboxNodeUI,
|
75 |
+
selModel: new Ext.tree.CheckNodeMultiSelectionModel(),
|
76 |
+
rootVisible: '<?php echo $this->getRootNode()->getIsVisible() ?>'
|
77 |
+
});
|
78 |
+
|
79 |
+
tree.on('check', function(node) {
|
80 |
+
if(node.attributes.checked) {
|
81 |
+
categoryAdd(node.id);
|
82 |
+
} else {
|
83 |
+
categoryRemove(node.id);
|
84 |
+
}
|
85 |
+
varienElementMethods.setHasChanges(node.getUI().checkbox);
|
86 |
+
}, tree);
|
87 |
+
|
88 |
+
// set the root node
|
89 |
+
var root = new Ext.tree.TreeNode({
|
90 |
+
text: '<?php echo $this->jsQuoteEscape($this->getRootNode()->getName()) ?>',
|
91 |
+
draggable:false,
|
92 |
+
checked:'<?php echo $this->getRootNode()->getChecked() ?>',
|
93 |
+
id:'<?php echo $this->getRootNode()->getId() ?>',
|
94 |
+
disabled: <?php echo ($this->getRootNode()->getDisabled() ? 'true' : 'false') ?>,
|
95 |
+
uiProvider: Ext.tree.CheckboxNodeUI
|
96 |
+
});
|
97 |
+
|
98 |
+
tree.setRootNode(root);
|
99 |
+
bildCategoryTree(root, <?php echo $this->getTreeJson() ?>);
|
100 |
+
tree.addListener('click', categoryClick.createDelegate(this));
|
101 |
+
|
102 |
+
// render the tree
|
103 |
+
tree.render();
|
104 |
+
//root.expand();
|
105 |
+
tree.expandAll();
|
106 |
+
});
|
107 |
+
|
108 |
+
function bildCategoryTree(parent, config){
|
109 |
+
if (!config) return null;
|
110 |
+
|
111 |
+
if (parent && config && config.length){
|
112 |
+
for (var i = 0; i < config.length; i++){
|
113 |
+
config[i].uiProvider = Ext.tree.CheckboxNodeUI;
|
114 |
+
var node;
|
115 |
+
var _node = Object.clone(config[i]);
|
116 |
+
if (_node.children && !_node.children.length) {
|
117 |
+
delete(_node.children);
|
118 |
+
node = new Ext.tree.AsyncTreeNode(_node);
|
119 |
+
|
120 |
+
} else {
|
121 |
+
node = new Ext.tree.TreeNode(config[i]);
|
122 |
+
}
|
123 |
+
parent.appendChild(node);
|
124 |
+
node.loader = node.getOwnerTree().loader;
|
125 |
+
if(config[i].children){
|
126 |
+
bildCategoryTree(node, config[i].children);
|
127 |
+
}
|
128 |
+
}
|
129 |
+
}
|
130 |
+
}
|
131 |
+
|
132 |
+
function categoryClick(node, e){
|
133 |
+
if (node.disabled) {
|
134 |
+
return;
|
135 |
+
}
|
136 |
+
node.getUI().check(!node.getUI().checked());
|
137 |
+
varienElementMethods.setHasChanges(Event.element(e), e);
|
138 |
+
};
|
139 |
+
function categoryAdd(id) {
|
140 |
+
var ids = $('product_categories').value.split(',');
|
141 |
+
ids.push(id);
|
142 |
+
$('product_categories').value = ids.join(',');
|
143 |
+
}
|
144 |
+
function categoryRemove(id) {
|
145 |
+
var ids = $('product_categories').value.split(',');
|
146 |
+
// bug #7654 fixed
|
147 |
+
while (-1 != ids.indexOf(id)) {
|
148 |
+
ids.splice(ids.indexOf(id), 1);
|
149 |
+
}
|
150 |
+
$('product_categories').value = ids.join(',');
|
151 |
+
}
|
152 |
+
</script>
|
153 |
+
<?php endif; ?>
|
154 |
+
<?php endif; ?>
|
155 |
+
</div>
|
156 |
+
|
157 |
+
|
158 |
+
|
159 |
+
</form>
|
160 |
+
<script type="text/javascript">
|
161 |
+
var iifireCategoryForm = new varienForm('category_edit_form');
|
162 |
+
function iifireCategorySubmit(url,useAjax)
|
163 |
+
{
|
164 |
+
var params = {};
|
165 |
+
var categoryContainer = $('category-edit-container');
|
166 |
+
var thisObj = this;
|
167 |
+
//alert(url);
|
168 |
+
<?php if(!Mage::app()->isSingleStoreMode()): ?>
|
169 |
+
var storeId = $('store_switcher').value;
|
170 |
+
<?php else: ?>
|
171 |
+
var storeId = <?php echo Mage::app()->getStore(true)->getId(); ?>
|
172 |
+
<?php endif; ?>
|
173 |
+
|
174 |
+
new Ajax.Request(url, {
|
175 |
+
parameters:{"store_id":storeId,"id":$('category_id').value,"category_ids":$('product_categories').value,"category_id":$('category_id').value,"type_switcher":$('type_categoy').value},
|
176 |
+
evalScripts: true,
|
177 |
+
onComplete: function () {
|
178 |
+
setTimeout(function() {
|
179 |
+
try {
|
180 |
+
//alert("<?php echo $this->__('Request timeout! Please refresh and try again.'); ?>");
|
181 |
+
} catch (e) {
|
182 |
+
alert(e.message);
|
183 |
+
};
|
184 |
+
}, 25);
|
185 |
+
},
|
186 |
+
onSuccess: function(transport) {
|
187 |
+
try {
|
188 |
+
if (transport.responseText) {
|
189 |
+
var baseUrl = '<?php echo $this->getEditUrl() ?>';
|
190 |
+
//alert(storeId)
|
191 |
+
var urlExt = (storeId?'store/'+storeId+'/':'')+'id/'+$('category_id').value+'/';
|
192 |
+
var url = parseSidUrl(baseUrl, urlExt);
|
193 |
+
updateContent(url);
|
194 |
+
}
|
195 |
+
} catch (e) {
|
196 |
+
alert(e.message);
|
197 |
+
}
|
198 |
+
}
|
199 |
+
})
|
200 |
+
}
|
201 |
+
</script>
|
app/design/adminhtml/default/default/template/iifire/category/tree.phtml
ADDED
@@ -0,0 +1,499 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<div class="categories-side-col">
|
2 |
+
<div class="content-header">
|
3 |
+
<h3 class="icon-head head-categories"><?php echo Mage::helper('catalog')->__('Categories') ?></h3>
|
4 |
+
</div>
|
5 |
+
<?php echo $this->getStoreSwitcherHtml();?>
|
6 |
+
|
7 |
+
<div class="tree-actions">
|
8 |
+
<?php if($this->getRoot()): ?>
|
9 |
+
<?php echo $this->getCollapseButtonHtml() ?>
|
10 |
+
<?php echo $this->getExpandButtonHtml() ?>
|
11 |
+
<a href="#" onclick="tree.collapseTree(); return false;"><?php echo Mage::helper('catalog')->__('Collapse All'); ?></a> <span class="separator">|</span> <a href="#" onclick="tree.expandTree(); return false;"><?php echo Mage::helper('catalog')->__('Expand All'); ?></a>
|
12 |
+
<?php endif; ?>
|
13 |
+
</div>
|
14 |
+
<?php if ($this->getRoot()): ?>
|
15 |
+
<div class="tree-holder">
|
16 |
+
<div id="tree-div" style="width:100%; overflow:auto;"></div>
|
17 |
+
</div>
|
18 |
+
</div>
|
19 |
+
<script type="text/javascript">
|
20 |
+
//<![CDATA[
|
21 |
+
var tree;
|
22 |
+
|
23 |
+
/**
|
24 |
+
* Fix ext compatibility with prototype 1.6
|
25 |
+
*/
|
26 |
+
Ext.lib.Event.getTarget = function(e) {
|
27 |
+
var ee = e.browserEvent || e;
|
28 |
+
return ee.target ? Event.element(ee) : null;
|
29 |
+
};
|
30 |
+
|
31 |
+
Ext.tree.TreePanel.Enhanced = function(el, config)
|
32 |
+
{
|
33 |
+
Ext.tree.TreePanel.Enhanced.superclass.constructor.call(this, el, config);
|
34 |
+
};
|
35 |
+
|
36 |
+
Ext.extend(Ext.tree.TreePanel.Enhanced, Ext.tree.TreePanel, {
|
37 |
+
|
38 |
+
loadTree : function(config, firstLoad)
|
39 |
+
{
|
40 |
+
var parameters = config['parameters'];
|
41 |
+
var data = config['data'];
|
42 |
+
|
43 |
+
this.storeId = parameters['store_id'];
|
44 |
+
|
45 |
+
if ( this.storeId != 0 && $('add_root_category_button')) {
|
46 |
+
$('add_root_category_button').hide();
|
47 |
+
}
|
48 |
+
|
49 |
+
if ((typeof parameters['root_visible']) != 'undefined') {
|
50 |
+
this.rootVisible = parameters['root_visible']*1;
|
51 |
+
}
|
52 |
+
|
53 |
+
var root = new Ext.tree.TreeNode(parameters);
|
54 |
+
|
55 |
+
this.nodeHash = {};
|
56 |
+
this.setRootNode(root);
|
57 |
+
|
58 |
+
if (firstLoad) {
|
59 |
+
this.addListener('click', this.categoryClick);
|
60 |
+
this.addListener('beforenodedrop', categoryMove.createDelegate(this));
|
61 |
+
}
|
62 |
+
|
63 |
+
this.loader.buildCategoryTree(root, data);
|
64 |
+
this.el.dom.innerHTML = '';
|
65 |
+
// render the tree
|
66 |
+
this.render();
|
67 |
+
if (true || parameters['expanded']) {
|
68 |
+
this.expandAll();
|
69 |
+
} else {
|
70 |
+
root.expand();
|
71 |
+
}
|
72 |
+
|
73 |
+
var selectedNode = this.getNodeById(parameters['category_id']);
|
74 |
+
if (selectedNode) {
|
75 |
+
this.currentNodeId = parameters['category_id'];
|
76 |
+
}
|
77 |
+
this.selectCurrentNode();
|
78 |
+
},
|
79 |
+
|
80 |
+
request : function(url, params)
|
81 |
+
{
|
82 |
+
if (!params) {
|
83 |
+
if (category_info_tabsJsTabs.activeTab) {
|
84 |
+
var params = {active_tab_id:category_info_tabsJsTabs.activeTab.id};
|
85 |
+
}
|
86 |
+
else {
|
87 |
+
var params = {};
|
88 |
+
}
|
89 |
+
}
|
90 |
+
if (!params.form_key) {
|
91 |
+
params.form_key = FORM_KEY;
|
92 |
+
}
|
93 |
+
var result = new Ajax.Request(
|
94 |
+
url + (url.match(new RegExp('\\?')) ? '&isAjax=true' : '?isAjax=true' ),
|
95 |
+
{
|
96 |
+
parameters: params,
|
97 |
+
method: 'post'
|
98 |
+
}
|
99 |
+
);
|
100 |
+
|
101 |
+
return result;
|
102 |
+
},
|
103 |
+
|
104 |
+
selectCurrentNode : function()
|
105 |
+
{
|
106 |
+
if (this.currentNodeId) {
|
107 |
+
var selectedNode = this.getNodeById(this.currentNodeId);
|
108 |
+
if ((typeof selectedNode.attributes.path)!='undefined') {
|
109 |
+
var path = selectedNode.attributes.path;
|
110 |
+
if (!this.storeId) {
|
111 |
+
path = '0/'+path;
|
112 |
+
}
|
113 |
+
this.selectPath(path);
|
114 |
+
} else {
|
115 |
+
this.getSelectionModel().select(selectedNode);
|
116 |
+
}
|
117 |
+
}
|
118 |
+
},
|
119 |
+
|
120 |
+
collapseTree : function()
|
121 |
+
{
|
122 |
+
this.collapseAll();
|
123 |
+
|
124 |
+
this.selectCurrentNode();
|
125 |
+
|
126 |
+
if (!this.collapsed) {
|
127 |
+
this.collapsed = true;
|
128 |
+
this.loader.dataUrl = '<?php echo $this->getLoadTreeUrl(false) ?>';
|
129 |
+
this.request(this.loader.dataUrl, false);
|
130 |
+
}
|
131 |
+
},
|
132 |
+
|
133 |
+
expandTree : function()
|
134 |
+
{
|
135 |
+
this.expandAll();
|
136 |
+
if (this.collapsed) {
|
137 |
+
this.collapsed = false;
|
138 |
+
this.loader.dataUrl = '<?php echo $this->getLoadTreeUrl(true) ?>';
|
139 |
+
this.request(this.loader.dataUrl, false);
|
140 |
+
}
|
141 |
+
},
|
142 |
+
|
143 |
+
categoryClick : function(node, e)
|
144 |
+
{
|
145 |
+
var baseUrl = '<?php echo $this->getEditUrl() ?>';
|
146 |
+
var urlExt = (this.storeId?'store/'+this.storeId+'/':'')+'id/'+node.id+'/';
|
147 |
+
var url = parseSidUrl(baseUrl, urlExt);
|
148 |
+
this.currentNodeId = node.id;
|
149 |
+
if (!this.useAjax) {
|
150 |
+
setLocation(url);
|
151 |
+
return;
|
152 |
+
}
|
153 |
+
updateContent(url);
|
154 |
+
}
|
155 |
+
});
|
156 |
+
|
157 |
+
function reRenderTree(event, switcher)
|
158 |
+
{
|
159 |
+
// re-render tree by store switcher
|
160 |
+
if (tree && event) {
|
161 |
+
var obj = event.target;
|
162 |
+
var newStoreId = obj.value * 1;
|
163 |
+
var storeParam = newStoreId ? 'store/'+newStoreId + '/' : '';
|
164 |
+
|
165 |
+
if (obj.switchParams) {
|
166 |
+
storeParam += obj.switchParams;
|
167 |
+
}
|
168 |
+
if (switcher.useConfirm) {
|
169 |
+
if (!confirm("<?php echo $this->__('Please confirm site switching. All data that hasn\'t been saved will be lost.') ?>")){
|
170 |
+
obj.value = '<?php echo (int) $this->getStoreId() ?>';
|
171 |
+
return false;
|
172 |
+
}
|
173 |
+
}
|
174 |
+
|
175 |
+
if ($('add_root_category_button')) {
|
176 |
+
if (newStoreId == 0) {
|
177 |
+
$('add_root_category_button').show();
|
178 |
+
}
|
179 |
+
else {
|
180 |
+
$('add_root_category_button').hide();
|
181 |
+
}
|
182 |
+
}
|
183 |
+
|
184 |
+
// retain current selected category id
|
185 |
+
storeParam = storeParam + 'id/' + tree.currentNodeId + '/';
|
186 |
+
var url = tree.switchTreeUrl + storeParam;
|
187 |
+
|
188 |
+
// load from cache
|
189 |
+
// load from ajax
|
190 |
+
new Ajax.Request(url + (url.match(new RegExp('\\?')) ? '&isAjax=true' : '?isAjax=true' ), {
|
191 |
+
parameters : {store: newStoreId, form_key: FORM_KEY},
|
192 |
+
method : 'post',
|
193 |
+
onComplete : function(transport) {
|
194 |
+
var response = eval('(' + transport.responseText + ')');
|
195 |
+
if (!response['parameters']) {
|
196 |
+
return false;
|
197 |
+
}
|
198 |
+
|
199 |
+
_renderNewTree(response, storeParam);
|
200 |
+
}
|
201 |
+
});
|
202 |
+
}
|
203 |
+
// render default tree
|
204 |
+
else {
|
205 |
+
_renderNewTree();
|
206 |
+
}
|
207 |
+
}
|
208 |
+
|
209 |
+
function _renderNewTree(config, storeParam)
|
210 |
+
{
|
211 |
+
if (!config) {
|
212 |
+
var config = defaultLoadTreeParams;
|
213 |
+
}
|
214 |
+
if (tree) {
|
215 |
+
tree.purgeListeners();
|
216 |
+
tree.el.dom.innerHTML = '';
|
217 |
+
}
|
218 |
+
tree = new Ext.tree.TreePanel.Enhanced('tree-div', newTreeParams);
|
219 |
+
tree.loadTree(config, true);
|
220 |
+
|
221 |
+
// try to select current category
|
222 |
+
var selectedNode = tree.getNodeById(config.parameters.category_id);
|
223 |
+
if (selectedNode) {
|
224 |
+
tree.currentNodeId = config.parameters.category_id;
|
225 |
+
}
|
226 |
+
tree.selectCurrentNode();
|
227 |
+
|
228 |
+
// update content area
|
229 |
+
var url = tree.editUrl;
|
230 |
+
if (storeParam) {
|
231 |
+
url = url + storeParam;
|
232 |
+
}
|
233 |
+
<?php if ($this->isClearEdit()):?>
|
234 |
+
if (selectedNode) {
|
235 |
+
url = url + 'id/' + config.parameters.category_id;
|
236 |
+
}
|
237 |
+
<?php endif;?>
|
238 |
+
updateContent(url);
|
239 |
+
}
|
240 |
+
|
241 |
+
Ext.onReady(function()
|
242 |
+
{
|
243 |
+
categoryLoader = new Ext.tree.TreeLoader({
|
244 |
+
dataUrl: '<?php echo $this->getLoadTreeUrl() ?>'
|
245 |
+
});
|
246 |
+
|
247 |
+
categoryLoader.createNode = function(config) {
|
248 |
+
var node;
|
249 |
+
var _node = Object.clone(config);
|
250 |
+
if (config.children && !config.children.length) {
|
251 |
+
delete(config.children);
|
252 |
+
node = new Ext.tree.AsyncTreeNode(config);
|
253 |
+
} else {
|
254 |
+
node = new Ext.tree.TreeNode(config);
|
255 |
+
}
|
256 |
+
|
257 |
+
return node;
|
258 |
+
};
|
259 |
+
|
260 |
+
categoryLoader.buildCategoryTree = function(parent, config)
|
261 |
+
{
|
262 |
+
if (!config) return null;
|
263 |
+
|
264 |
+
if (parent && config && config.length){
|
265 |
+
for (var i = 0; i < config.length; i++) {
|
266 |
+
var node;
|
267 |
+
var _node = Object.clone(config[i]);
|
268 |
+
if (_node.children && !_node.children.length) {
|
269 |
+
delete(_node.children);
|
270 |
+
node = new Ext.tree.AsyncTreeNode(_node);
|
271 |
+
} else {
|
272 |
+
node = new Ext.tree.TreeNode(config[i]);
|
273 |
+
}
|
274 |
+
parent.appendChild(node);
|
275 |
+
node.loader = node.getOwnerTree().loader;
|
276 |
+
if (_node.children) {
|
277 |
+
this.buildCategoryTree(node, _node.children);
|
278 |
+
}
|
279 |
+
}
|
280 |
+
}
|
281 |
+
};
|
282 |
+
|
283 |
+
categoryLoader.buildHash = function(node)
|
284 |
+
{
|
285 |
+
var hash = {};
|
286 |
+
|
287 |
+
hash = this.toArray(node.attributes);
|
288 |
+
|
289 |
+
if (node.childNodes.length>0 || (node.loaded==false && node.loading==false)) {
|
290 |
+
hash['children'] = new Array;
|
291 |
+
|
292 |
+
for (var i = 0, len = node.childNodes.length; i < len; i++) {
|
293 |
+
if (!hash['children']) {
|
294 |
+
hash['children'] = new Array;
|
295 |
+
}
|
296 |
+
hash['children'].push(this.buildHash(node.childNodes[i]));
|
297 |
+
}
|
298 |
+
}
|
299 |
+
|
300 |
+
return hash;
|
301 |
+
};
|
302 |
+
|
303 |
+
categoryLoader.toArray = function(attributes) {
|
304 |
+
var data = {form_key: FORM_KEY};
|
305 |
+
for (var key in attributes) {
|
306 |
+
var value = attributes[key];
|
307 |
+
data[key] = value;
|
308 |
+
}
|
309 |
+
|
310 |
+
return data;
|
311 |
+
};
|
312 |
+
|
313 |
+
categoryLoader.on("beforeload", function(treeLoader, node) {
|
314 |
+
treeLoader.baseParams.id = node.attributes.id;
|
315 |
+
treeLoader.baseParams.store = node.attributes.store;
|
316 |
+
treeLoader.baseParams.form_key = FORM_KEY;
|
317 |
+
});
|
318 |
+
|
319 |
+
categoryLoader.on("load", function(treeLoader, node, config) {
|
320 |
+
varienWindowOnload();
|
321 |
+
});
|
322 |
+
|
323 |
+
if ((typeof varienStoreSwitcher)!='undefined') {
|
324 |
+
varienStoreSwitcher.storeSelectorClickCallback = reRenderTree;
|
325 |
+
}
|
326 |
+
|
327 |
+
newTreeParams = {
|
328 |
+
animate : false,
|
329 |
+
loader : categoryLoader,
|
330 |
+
enableDD : true,
|
331 |
+
containerScroll : true,
|
332 |
+
selModel : new Ext.tree.CheckNodeMultiSelectionModel(),
|
333 |
+
rootVisible : '<?php echo $this->getRoot()->getIsVisible() ?>',
|
334 |
+
useAjax : <?php echo $this->getUseAjax() ?>,
|
335 |
+
switchTreeUrl : '<?php echo $this->getSwitchTreeUrl() ?>',
|
336 |
+
editUrl : '<?php echo $this->getEditUrl() ?>',
|
337 |
+
currentNodeId : <?php echo (int) $this->getCategoryId() ?>
|
338 |
+
};
|
339 |
+
|
340 |
+
defaultLoadTreeParams = {
|
341 |
+
parameters : {
|
342 |
+
text : '<?php echo htmlentities($this->getRoot()->getName()) ?>',
|
343 |
+
draggable : false,
|
344 |
+
allowDrop : <?php if ($this->getRoot()->getIsVisible()): ?>true<?php else : ?>false<?php endif; ?>,
|
345 |
+
id : <?php echo (int) $this->getRoot()->getId() ?>,
|
346 |
+
expanded : <?php echo (int) $this->getIsWasExpanded() ?>,
|
347 |
+
store_id : <?php echo (int) $this->getStore()->getId() ?>,
|
348 |
+
category_id : <?php echo (int) $this->getCategoryId() ?>
|
349 |
+
},
|
350 |
+
data : <?php echo $this->getTreeJson() ?>
|
351 |
+
};
|
352 |
+
|
353 |
+
reRenderTree();
|
354 |
+
});
|
355 |
+
|
356 |
+
function addNew(url, isRoot)
|
357 |
+
{
|
358 |
+
if (isRoot) {
|
359 |
+
tree.currentNodeId = tree.root.id;
|
360 |
+
}
|
361 |
+
|
362 |
+
if (/store\/\d+/.test(url)) {
|
363 |
+
url = url.replace(/store\/\d+/, "store/" + tree.storeId);
|
364 |
+
}
|
365 |
+
else {
|
366 |
+
url+= "store/" + tree.storeId + "/";
|
367 |
+
}
|
368 |
+
|
369 |
+
url+= 'parent/'+tree.currentNodeId;
|
370 |
+
updateContent(url);
|
371 |
+
}
|
372 |
+
|
373 |
+
function categoryMove(obj)
|
374 |
+
{
|
375 |
+
var data = {id: obj.dropNode.id, form_key: FORM_KEY};
|
376 |
+
|
377 |
+
data.point = obj.point;
|
378 |
+
switch (obj.point) {
|
379 |
+
case 'above' :
|
380 |
+
data.pid = obj.target.parentNode.id;
|
381 |
+
data.paid = obj.dropNode.parentNode.id;
|
382 |
+
if (obj.target.previousSibling) {
|
383 |
+
data.aid = obj.target.previousSibling.id;
|
384 |
+
} else {
|
385 |
+
data.aid = 0;
|
386 |
+
}
|
387 |
+
break;
|
388 |
+
case 'below' :
|
389 |
+
data.pid = obj.target.parentNode.id;
|
390 |
+
data.aid = obj.target.id;
|
391 |
+
break;
|
392 |
+
case 'append' :
|
393 |
+
data.pid = obj.target.id;
|
394 |
+
data.paid = obj.dropNode.parentNode.id;
|
395 |
+
if (obj.target.lastChild) {
|
396 |
+
data.aid = obj.target.lastChild.id;
|
397 |
+
} else {
|
398 |
+
data.aid = 0;
|
399 |
+
}
|
400 |
+
break;
|
401 |
+
default :
|
402 |
+
obj.cancel = true;
|
403 |
+
return obj;
|
404 |
+
}
|
405 |
+
|
406 |
+
var success = function(o) {
|
407 |
+
try {
|
408 |
+
if(o.responseText){
|
409 |
+
if(o.responseText==='SUCCESS'){
|
410 |
+
categoryForm.refreshPath();
|
411 |
+
} else {
|
412 |
+
alert(o.responseText);
|
413 |
+
location.reload();
|
414 |
+
}
|
415 |
+
}
|
416 |
+
}
|
417 |
+
catch(e) {
|
418 |
+
}
|
419 |
+
};
|
420 |
+
|
421 |
+
var failure = function(o) {
|
422 |
+
try {
|
423 |
+
console.log(o.statusText);
|
424 |
+
} catch (e2) {
|
425 |
+
alert(o.statusText);
|
426 |
+
}
|
427 |
+
location.reload();
|
428 |
+
};
|
429 |
+
|
430 |
+
var pd = [];
|
431 |
+
for(var key in data) {
|
432 |
+
pd.push(encodeURIComponent(key), "=", encodeURIComponent(data[key]), "&");
|
433 |
+
}
|
434 |
+
pd.splice(pd.length-1,1);
|
435 |
+
new Ajax.Request(
|
436 |
+
'<?php echo $this->getMoveUrl() ?>',
|
437 |
+
{
|
438 |
+
method: 'POST',
|
439 |
+
parameters: pd.join(""),
|
440 |
+
onSuccess : success,
|
441 |
+
onFailure : failure
|
442 |
+
}
|
443 |
+
);
|
444 |
+
}
|
445 |
+
function updateContent(url, refreshTree) {
|
446 |
+
|
447 |
+
var categoryContainer = $('category-edit-container');
|
448 |
+
var messagesContainer = $('messages');
|
449 |
+
var thisObj = this;
|
450 |
+
var type = $('type_categoy').value;
|
451 |
+
new Ajax.Request(url + (url.match(new RegExp('\\?')) ? '&isAjax=true&type='+type : '?isAjax=true&type='+type ), {
|
452 |
+
|
453 |
+
evalScripts: true,
|
454 |
+
onComplete: function () {
|
455 |
+
setTimeout(function() {
|
456 |
+
try {
|
457 |
+
if (refreshTree) {
|
458 |
+
thisObj.refreshTreeArea();
|
459 |
+
}
|
460 |
+
toolbarToggle.start();
|
461 |
+
} catch (e) {
|
462 |
+
alert(e.message);
|
463 |
+
};
|
464 |
+
}, 25);
|
465 |
+
},
|
466 |
+
onSuccess: function(transport) {
|
467 |
+
try {
|
468 |
+
if (transport.responseText.isJSON()) {
|
469 |
+
var response = transport.responseText.evalJSON();
|
470 |
+
var needUpdate = true;
|
471 |
+
if (response.error) {
|
472 |
+
alert(response.message);
|
473 |
+
needUpdate = false;
|
474 |
+
}
|
475 |
+
if(response.ajaxExpired && response.ajaxRedirect) {
|
476 |
+
setLocation(response.ajaxRedirect);
|
477 |
+
needUpdate = false;
|
478 |
+
}
|
479 |
+
if (needUpdate){
|
480 |
+
if (response.content){
|
481 |
+
$(categoryContainer).update(response.content);
|
482 |
+
}
|
483 |
+
if (response.messages){
|
484 |
+
$(messagesContainer).update(response.messages);
|
485 |
+
}
|
486 |
+
}
|
487 |
+
} else {
|
488 |
+
$(categoryContainer).update(transport.responseText);
|
489 |
+
}
|
490 |
+
}
|
491 |
+
catch (e) {
|
492 |
+
$(categoryContainer).update(transport.responseText);
|
493 |
+
}
|
494 |
+
}
|
495 |
+
});
|
496 |
+
}
|
497 |
+
//]]>
|
498 |
+
</script>
|
499 |
+
<?php endif; ?>
|
app/etc/modules/Iifire_Category.xml
ADDED
@@ -0,0 +1,9 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?xml version="1.0"?>
|
2 |
+
<config>
|
3 |
+
<modules>
|
4 |
+
<Iifire_Category>
|
5 |
+
<active>true</active>
|
6 |
+
<codePool>community</codePool>
|
7 |
+
</Iifire_Category>
|
8 |
+
</modules>
|
9 |
+
</config>
|
package.xml
CHANGED
@@ -1,7 +1,7 @@
|
|
1 |
<?xml version="1.0"?>
|
2 |
<package>
|
3 |
<name>advanced_related_product</name>
|
4 |
-
<version>1.6.
|
5 |
<stability>stable</stability>
|
6 |
<license>GPL</license>
|
7 |
<channel>community</channel>
|
@@ -10,9 +10,9 @@
|
|
10 |
<description>Setting Related Products,Up-sell Products,Cross-sell Products easily,powerful assistant. </description>
|
11 |
<notes>Setting Related Products,Up-sell Products,Cross-sell Products easily,powerful assistant. </notes>
|
12 |
<authors><author><name>iifire</name><user>yanggaojiao</user><email>yanggaojiao@qq.com</email></author></authors>
|
13 |
-
<date>2012-08-
|
14 |
-
<time>
|
15 |
-
<contents><target name="magecommunity"><dir name="Iifire"><dir name="Category"><dir name="Block"><dir name="Adminhtml"><file name="Categories.php" hash="13c06a1861bfb610fe8a2ae1c31afebc"/><file name="Category.php" hash="b046d615f2426ed5a00de317830c3b4e"/><file name="Tree.php" hash="eb49dacd0ad5f3eca85097da4318f240"/></dir></dir><dir name="Helper"><file name="Data.php" hash="93c1babf8b71c1dbc87dde2ddefc8bbc"/><file name="Toolbar.php" hash="ab4290052ac7606a50bd623a3f81d75a"/><file name="leida.php" hash="eae93a61413da53309ffa45537251d33"/></dir><dir name="controllers"><dir name="Adminhtml"><dir name="Iifire"><file name="CategoryController.php" hash="fcbfc421a411f28b2ed3235e860bfc43"/></dir></dir></dir><dir name="etc"><file name="adminhtml.xml" hash="05318c219ada2a3d9008ff4f0a425945"/><file name="config.xml" hash="9489027ab8ffc7faf6cf31ee9b6e5df3"/><file name="system.xml" hash="8faa2639c867c5f8e68d28f9ea6ddf2d"/></dir><file name="install.php" hash="82d8d90abfdd0b1a47acdeeb4ec49395"/><dir name="sql"><dir name="iifire_category_setup"><file name="mysql4-install-1.6.0.php" hash="78201731438f248a16d0f44d6ae55908"/></dir></dir></dir></dir></target></contents>
|
16 |
<compatible/>
|
17 |
<dependencies><required><php><min>5.1.0</min><max>6.0.0</max></php></required></dependencies>
|
18 |
</package>
|
1 |
<?xml version="1.0"?>
|
2 |
<package>
|
3 |
<name>advanced_related_product</name>
|
4 |
+
<version>1.6.1</version>
|
5 |
<stability>stable</stability>
|
6 |
<license>GPL</license>
|
7 |
<channel>community</channel>
|
10 |
<description>Setting Related Products,Up-sell Products,Cross-sell Products easily,powerful assistant. </description>
|
11 |
<notes>Setting Related Products,Up-sell Products,Cross-sell Products easily,powerful assistant. </notes>
|
12 |
<authors><author><name>iifire</name><user>yanggaojiao</user><email>yanggaojiao@qq.com</email></author></authors>
|
13 |
+
<date>2012-08-18</date>
|
14 |
+
<time>00:35:33</time>
|
15 |
+
<contents><target name="magecommunity"><dir name="Iifire"><dir name="Category"><dir name="Block"><dir name="Adminhtml"><file name="Categories.php" hash="13c06a1861bfb610fe8a2ae1c31afebc"/><file name="Category.php" hash="b046d615f2426ed5a00de317830c3b4e"/><file name="Tree.php" hash="eb49dacd0ad5f3eca85097da4318f240"/></dir></dir><dir name="Helper"><file name="Data.php" hash="93c1babf8b71c1dbc87dde2ddefc8bbc"/><file name="Toolbar.php" hash="ab4290052ac7606a50bd623a3f81d75a"/><file name="leida.php" hash="eae93a61413da53309ffa45537251d33"/></dir><dir name="controllers"><dir name="Adminhtml"><dir name="Iifire"><file name="CategoryController.php" hash="fcbfc421a411f28b2ed3235e860bfc43"/></dir></dir></dir><dir name="etc"><file name="adminhtml.xml" hash="05318c219ada2a3d9008ff4f0a425945"/><file name="config.xml" hash="9489027ab8ffc7faf6cf31ee9b6e5df3"/><file name="system.xml" hash="8faa2639c867c5f8e68d28f9ea6ddf2d"/></dir><file name="install.php" hash="82d8d90abfdd0b1a47acdeeb4ec49395"/><dir name="sql"><dir name="iifire_category_setup"><file name="mysql4-install-1.6.0.php" hash="78201731438f248a16d0f44d6ae55908"/></dir></dir></dir></dir></target><target name="mageetc"><dir name="modules"><file name="Iifire_Category.xml" hash="3f779eea8792b8e8a55e7a13297e56d8"/></dir></target><target name="magelocal"><dir name="Mage"><dir name="Catalog"><dir name="Block"><dir name="Product"><dir name="List"><file name="Crosssell.php" hash="75a2634f8ca857bd2bbafce1d8b73f50"/><file name="Related.php" hash="3889379d3b52be153a02d1018fde239b"/><file name="Upsell.php" hash="233b2617a993b4c93c259991ee32469c"/></dir></dir></dir></dir></dir></target><target name="magedesign"><dir name="adminhtml"><dir name="default"><dir name="default"><dir name="layout"><file name="iifire_category.xml" hash="00330d5a22cc55da333f2f78e54635db"/></dir><dir name="template"><dir name="iifire"><dir name="category"><file name="categories.phtml" hash="02dc35950d88d5e5005aed020a849ce7"/><file name="tree.phtml" hash="a512d74b76406a1bdd6db45e621923c2"/></dir></dir></dir></dir></dir></dir></target></contents>
|
16 |
<compatible/>
|
17 |
<dependencies><required><php><min>5.1.0</min><max>6.0.0</max></php></required></dependencies>
|
18 |
</package>
|