Version Notes
Rewrites category model, page model, category navigation block.
Download this release
Release Info
Developer | IteraResearch |
Extension | IteraResearch_PageToCategory |
Version | 1.0.0 |
Comparing to | |
See all releases |
Version 1.0.0
- app/code/community/IteraResearch/PageToCategory/Block/Adminhtml/Cms/Page/Edit/Tab/Categories.php +105 -0
- app/code/community/IteraResearch/PageToCategory/Block/Catalog/Navigation.php +49 -0
- app/code/community/IteraResearch/PageToCategory/Helper/Data.php +14 -0
- app/code/community/IteraResearch/PageToCategory/Model/Catalog/Category.php +59 -0
- app/code/community/IteraResearch/PageToCategory/Model/Observer.php +70 -0
- app/code/community/IteraResearch/PageToCategory/Model/Page.php +118 -0
- app/code/community/IteraResearch/PageToCategory/Model/Relation.php +94 -0
- app/code/community/IteraResearch/PageToCategory/Model/Resource/Relation.php +65 -0
- app/code/community/IteraResearch/PageToCategory/Model/Resource/Relation/Collection.php +21 -0
- app/code/community/IteraResearch/PageToCategory/controllers/Adminhtml/RelationController.php +62 -0
- app/code/community/IteraResearch/PageToCategory/etc/config.xml +105 -0
- app/code/community/IteraResearch/PageToCategory/etc/system.xml +47 -0
- app/code/community/IteraResearch/PageToCategory/sql/pagetocategory_setup/install-1.0.0.php +37 -0
- app/design/adminhtml/default/default/layout/iteraresearch/pagetocategory.xml +20 -0
- app/etc/modules/IteraResearch_PageToCategory.xml +19 -0
- package.xml +18 -0
app/code/community/IteraResearch/PageToCategory/Block/Adminhtml/Cms/Page/Edit/Tab/Categories.php
ADDED
@@ -0,0 +1,105 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
/**
|
3 |
+
* This file is part of PageToCategory extension.
|
4 |
+
*
|
5 |
+
* @category IteraResearch
|
6 |
+
* @package IteraResearch_PageToCategory
|
7 |
+
* @copyright Copyright (c) 2003-2015 Itera Research, Inc. All rights reserved. (http://www.itera-research.com/)
|
8 |
+
* @license http://www.gnu.org/licenses Lesser General Public License
|
9 |
+
*/
|
10 |
+
|
11 |
+
class IteraResearch_PageToCategory_Block_Adminhtml_Cms_Page_Edit_Tab_Categories
|
12 |
+
extends Mage_Adminhtml_Block_Catalog_Product_Edit_Tab_Categories
|
13 |
+
implements Mage_Adminhtml_Block_Widget_Tab_Interface
|
14 |
+
{
|
15 |
+
/**
|
16 |
+
* Checks when this block is readonly
|
17 |
+
*
|
18 |
+
* @return boolean
|
19 |
+
*/
|
20 |
+
public function isReadonly()
|
21 |
+
{
|
22 |
+
return false;
|
23 |
+
}
|
24 |
+
|
25 |
+
/**
|
26 |
+
* Retrieve currently edited page
|
27 |
+
*
|
28 |
+
* @return Mage_Cms_Model_Page
|
29 |
+
*/
|
30 |
+
public function getPage()
|
31 |
+
{
|
32 |
+
return Mage::registry('cms_page');
|
33 |
+
}
|
34 |
+
|
35 |
+
/**
|
36 |
+
* Return array with category IDs which the page is assigned to
|
37 |
+
*
|
38 |
+
* @return array
|
39 |
+
*/
|
40 |
+
protected function getCategoryIds()
|
41 |
+
{
|
42 |
+
$cids = array();
|
43 |
+
$page = $this->getPage();
|
44 |
+
if ($page) {
|
45 |
+
/* @var $relations IteraResearch_PageToCategory_Model_Resource_Relation_Collection */
|
46 |
+
$relations = Mage::getModel('pagetocategory/relation')->getCollection();
|
47 |
+
$relations->addFieldToFilter('page_id', $page->getId());
|
48 |
+
foreach ($relations as $relation) {
|
49 |
+
$cids[] = $relation->getCategoryId();
|
50 |
+
}
|
51 |
+
}
|
52 |
+
return $cids;
|
53 |
+
}
|
54 |
+
|
55 |
+
/**
|
56 |
+
* Returns URL for loading tree
|
57 |
+
*
|
58 |
+
* @param null $expanded
|
59 |
+
* @return string
|
60 |
+
*/
|
61 |
+
public function getLoadTreeUrl($expanded = null)
|
62 |
+
{
|
63 |
+
return $this->getUrl('pagetocategory/adminhtml_relation/categoriesJson', array('_current' => true));
|
64 |
+
}
|
65 |
+
|
66 |
+
/**
|
67 |
+
* Return Tab label
|
68 |
+
*
|
69 |
+
* @return string
|
70 |
+
*/
|
71 |
+
public function getTabLabel()
|
72 |
+
{
|
73 |
+
return Mage::helper('catalog')->__('Categories');
|
74 |
+
}
|
75 |
+
|
76 |
+
/**
|
77 |
+
* Return Tab title
|
78 |
+
*
|
79 |
+
* @return string
|
80 |
+
*/
|
81 |
+
public function getTabTitle()
|
82 |
+
{
|
83 |
+
return Mage::helper('catalog')->__('Categories');
|
84 |
+
}
|
85 |
+
|
86 |
+
/**
|
87 |
+
* Can show tab in tabs
|
88 |
+
*
|
89 |
+
* @return boolean
|
90 |
+
*/
|
91 |
+
public function canShowTab()
|
92 |
+
{
|
93 |
+
return true;
|
94 |
+
}
|
95 |
+
|
96 |
+
/**
|
97 |
+
* Tab is hidden
|
98 |
+
*
|
99 |
+
* @return boolean
|
100 |
+
*/
|
101 |
+
public function isHidden()
|
102 |
+
{
|
103 |
+
return false;
|
104 |
+
}
|
105 |
+
}
|
app/code/community/IteraResearch/PageToCategory/Block/Catalog/Navigation.php
ADDED
@@ -0,0 +1,49 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
/**
|
3 |
+
* This file is part of PageToCategory extension.
|
4 |
+
*
|
5 |
+
* @category IteraResearch
|
6 |
+
* @package IteraResearch_PageToCategory
|
7 |
+
* @copyright Copyright (c) 2003-2015 Itera Research, Inc. All rights reserved. (http://www.itera-research.com/)
|
8 |
+
* @license http://www.gnu.org/licenses Lesser General Public License
|
9 |
+
*/
|
10 |
+
|
11 |
+
class IteraResearch_PageToCategory_Block_Catalog_Navigation extends Mage_Catalog_Block_Navigation
|
12 |
+
{
|
13 |
+
protected $_relation;
|
14 |
+
|
15 |
+
protected function _getRelation()
|
16 |
+
{
|
17 |
+
if (!$this->_relation) {
|
18 |
+
$this->_relation = Mage::getModel('pagetocategory/relation');
|
19 |
+
}
|
20 |
+
return $this->_relation;
|
21 |
+
}
|
22 |
+
|
23 |
+
/**
|
24 |
+
* Retrieve child categories of current category
|
25 |
+
*
|
26 |
+
* @return Mage_Catalog_Model_Resource_Category_Collection
|
27 |
+
*/
|
28 |
+
public function getCurrentChildCategories()
|
29 |
+
{
|
30 |
+
if (null === $this->_currentChildCategories) {
|
31 |
+
$layer = Mage::getSingleton('catalog/layer');
|
32 |
+
$category = $layer->getCurrentCategory();
|
33 |
+
$this->_currentChildCategories = $category->getChildrenCategories();
|
34 |
+
if (!$this->_getRelation()->canShowInLeftNavigation()) {
|
35 |
+
// if category has assigned page, the category will be removed from left category navigation, depending on configuration
|
36 |
+
/* @var $this->_currentChildCategories Mage_Core_Model_Resource_Db_Collection_Abstract */
|
37 |
+
foreach ($this->_currentChildCategories as $cat) {
|
38 |
+
if ($this->_getRelation()->getPageByCategoryId($cat->getId())) {
|
39 |
+
$this->_currentChildCategories->removeItemByKey($cat->getId());
|
40 |
+
}
|
41 |
+
}
|
42 |
+
}
|
43 |
+
$productCollection = Mage::getResourceModel('catalog/product_collection');
|
44 |
+
$layer->prepareProductCollection($productCollection);
|
45 |
+
$productCollection->addCountToCategories($this->_currentChildCategories);
|
46 |
+
}
|
47 |
+
return $this->_currentChildCategories;
|
48 |
+
}
|
49 |
+
}
|
app/code/community/IteraResearch/PageToCategory/Helper/Data.php
ADDED
@@ -0,0 +1,14 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
/**
|
3 |
+
* This file is part of PageToCategory extension.
|
4 |
+
*
|
5 |
+
* @category IteraResearch
|
6 |
+
* @package IteraResearch_PageToCategory
|
7 |
+
* @copyright Copyright (c) 2003-2015 Itera Research, Inc. All rights reserved. (http://www.itera-research.com/)
|
8 |
+
* @license http://www.gnu.org/licenses Lesser General Public License
|
9 |
+
*/
|
10 |
+
|
11 |
+
class IteraResearch_PageToCategory_Helper_Data extends Mage_Core_Helper_Abstract
|
12 |
+
{
|
13 |
+
|
14 |
+
}
|
app/code/community/IteraResearch/PageToCategory/Model/Catalog/Category.php
ADDED
@@ -0,0 +1,59 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
/**
|
3 |
+
* This file is part of PageToCategory extension.
|
4 |
+
*
|
5 |
+
* @category IteraResearch
|
6 |
+
* @package IteraResearch_PageToCategory
|
7 |
+
* @copyright Copyright (c) 2003-2015 Itera Research, Inc. All rights reserved. (http://www.itera-research.com/)
|
8 |
+
* @license http://www.gnu.org/licenses Lesser General Public License
|
9 |
+
*/
|
10 |
+
|
11 |
+
class IteraResearch_PageToCategory_Model_Catalog_Category extends Mage_Catalog_Model_Category
|
12 |
+
{
|
13 |
+
protected $_relation;
|
14 |
+
|
15 |
+
protected function _getRelation()
|
16 |
+
{
|
17 |
+
if (!$this->_relation) {
|
18 |
+
$this->_relation = Mage::getModel('pagetocategory/relation');
|
19 |
+
}
|
20 |
+
return $this->_relation;
|
21 |
+
}
|
22 |
+
|
23 |
+
/**
|
24 |
+
* Get category url
|
25 |
+
*
|
26 |
+
* @return string
|
27 |
+
*/
|
28 |
+
public function getUrl()
|
29 |
+
{
|
30 |
+
if (!Mage::app()->getStore()->isAdmin()) {
|
31 |
+
if ($this->_getRelation()->getPageByCategoryId($this->getId())) {
|
32 |
+
return $this->_getRelation()->getPageUrlByCategoryId($this->getId());
|
33 |
+
}
|
34 |
+
}
|
35 |
+
return parent::getUrl();
|
36 |
+
}
|
37 |
+
|
38 |
+
/**
|
39 |
+
* Retrieve Name data wrapper
|
40 |
+
*
|
41 |
+
* @return string
|
42 |
+
*/
|
43 |
+
public function getName()
|
44 |
+
{
|
45 |
+
if (!Mage::app()->getStore()->isAdmin() && $this->_getRelation()->canUsePageTitle()) {
|
46 |
+
if ($this->_getRelation()->getPageByCategoryId($this->getId())) {
|
47 |
+
return $this->_getRelation()->getPageTitleByCategoryId($this->getId());
|
48 |
+
}
|
49 |
+
}
|
50 |
+
return parent::getName();
|
51 |
+
}
|
52 |
+
|
53 |
+
protected function _beforeDelete()
|
54 |
+
{
|
55 |
+
$this->_getRelation()->deleteByCategoryId($this->getId());
|
56 |
+
parent::_beforeDelete();
|
57 |
+
return $this;
|
58 |
+
}
|
59 |
+
}
|
app/code/community/IteraResearch/PageToCategory/Model/Observer.php
ADDED
@@ -0,0 +1,70 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
/**
|
3 |
+
* This file is part of PageToCategory extension.
|
4 |
+
*
|
5 |
+
* @category IteraResearch
|
6 |
+
* @package IteraResearch_PageToCategory
|
7 |
+
* @copyright Copyright (c) 2003-2015 Itera Research, Inc. All rights reserved. (http://www.itera-research.com/)
|
8 |
+
* @license http://www.gnu.org/licenses Lesser General Public License
|
9 |
+
*/
|
10 |
+
|
11 |
+
class IteraResearch_PageToCategory_Model_Observer
|
12 |
+
{
|
13 |
+
protected $_relation;
|
14 |
+
|
15 |
+
protected function _getCategoryIds($ids)
|
16 |
+
{
|
17 |
+
if (null !== $ids) {
|
18 |
+
if (empty($ids)) {
|
19 |
+
$ids = array();
|
20 |
+
}
|
21 |
+
if (is_string($ids)) {
|
22 |
+
$ids = explode(',', $ids);
|
23 |
+
} elseif (!is_array($ids)) {
|
24 |
+
Mage::throwException(Mage::helper('catalog')->__('Invalid category IDs.'));
|
25 |
+
}
|
26 |
+
foreach ($ids as $i => $v) {
|
27 |
+
if (empty($v)) {
|
28 |
+
unset($ids[$i]);
|
29 |
+
}
|
30 |
+
}
|
31 |
+
return array_unique($ids);
|
32 |
+
}
|
33 |
+
return array();
|
34 |
+
}
|
35 |
+
|
36 |
+
public function addPagesToTopmenuItems(Varien_Event_Observer $observer)
|
37 |
+
{
|
38 |
+
if ($this->_getRelation()->canUsePageTitle()) {
|
39 |
+
$menu = $observer->getMenu();
|
40 |
+
$this->_recurseTree($menu);
|
41 |
+
}
|
42 |
+
}
|
43 |
+
|
44 |
+
/**
|
45 |
+
* Replace category titles and URLs with CMS page titles and URLs.
|
46 |
+
*
|
47 |
+
* @param Varien_Data_Tree_Node $menuTree
|
48 |
+
*/
|
49 |
+
protected function _recurseTree(Varien_Data_Tree_Node $menuTree)
|
50 |
+
{
|
51 |
+
$children = $menuTree->getChildren();
|
52 |
+
foreach ($children as $child) {
|
53 |
+
$catId = (int)str_replace('category-node-', '', $child->getId());
|
54 |
+
if ($this->_getRelation()->getPageByCategoryId($catId)) {
|
55 |
+
$child->setName($this->_getRelation()->getPageTitleByCategoryId($catId));
|
56 |
+
}
|
57 |
+
if ($child->hasChildren()) {
|
58 |
+
$this->_recurseTree($child);
|
59 |
+
}
|
60 |
+
}
|
61 |
+
}
|
62 |
+
|
63 |
+
protected function _getRelation()
|
64 |
+
{
|
65 |
+
if (!$this->_relation) {
|
66 |
+
$this->_relation = Mage::getModel('pagetocategory/relation');
|
67 |
+
}
|
68 |
+
return $this->_relation;
|
69 |
+
}
|
70 |
+
}
|
app/code/community/IteraResearch/PageToCategory/Model/Page.php
ADDED
@@ -0,0 +1,118 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
/**
|
3 |
+
* This file is part of PageToCategory extension.
|
4 |
+
*
|
5 |
+
* @category IteraResearch
|
6 |
+
* @package IteraResearch_PageToCategory
|
7 |
+
* @copyright Copyright (c) 2003-2015 Itera Research, Inc. All rights reserved. (http://www.itera-research.com/)
|
8 |
+
* @license http://www.gnu.org/licenses Lesser General Public License
|
9 |
+
*/
|
10 |
+
|
11 |
+
class IteraResearch_PageToCategory_Model_Page extends Mage_Cms_Model_Page
|
12 |
+
{
|
13 |
+
/**
|
14 |
+
* Processing object after save data
|
15 |
+
*
|
16 |
+
* @return Mage_Core_Model_Abstract
|
17 |
+
*/
|
18 |
+
protected function _afterSave()
|
19 |
+
{
|
20 |
+
parent::_afterSave();
|
21 |
+
$this->_updateRelations();
|
22 |
+
return $this;
|
23 |
+
}
|
24 |
+
|
25 |
+
/**
|
26 |
+
* Processing object before delete data
|
27 |
+
*
|
28 |
+
* @return Mage_Core_Model_Abstract
|
29 |
+
*/
|
30 |
+
protected function _beforeDelete()
|
31 |
+
{
|
32 |
+
$relation = Mage::getModel('pagetocategory/relation');
|
33 |
+
$relation->deleteByPageId($this->getId());
|
34 |
+
parent::_beforeDelete();
|
35 |
+
return $this;
|
36 |
+
}
|
37 |
+
|
38 |
+
/**
|
39 |
+
* Get category IDs from string
|
40 |
+
*
|
41 |
+
* @param $ids
|
42 |
+
* @return array
|
43 |
+
*/
|
44 |
+
protected function _getCategoryIds($ids)
|
45 |
+
{
|
46 |
+
if (null !== $ids) {
|
47 |
+
if (empty($ids)) {
|
48 |
+
$ids = array();
|
49 |
+
}
|
50 |
+
if (is_string($ids)) {
|
51 |
+
$ids = explode(',', $ids);
|
52 |
+
} elseif (!is_array($ids)) {
|
53 |
+
Mage::throwException(Mage::helper('catalog')->__('Invalid category IDs.'));
|
54 |
+
}
|
55 |
+
foreach ($ids as $i => $v) {
|
56 |
+
if (empty($v)) {
|
57 |
+
unset($ids[$i]);
|
58 |
+
}
|
59 |
+
}
|
60 |
+
return array_unique($ids);
|
61 |
+
}
|
62 |
+
return array();
|
63 |
+
}
|
64 |
+
|
65 |
+
/**
|
66 |
+
* Create new or delete existing relation,
|
67 |
+
* check if category already has assigned page in the same store.
|
68 |
+
*/
|
69 |
+
protected function _updateRelations()
|
70 |
+
{
|
71 |
+
$request = Mage::app()->getRequest();
|
72 |
+
$categoryIds = $request->getParam('category_ids');
|
73 |
+
$cids = $this->_getCategoryIds($categoryIds);
|
74 |
+
$relationModel = Mage::getModel('pagetocategory/relation');
|
75 |
+
$relationModel->validateAssignment($this, $cids);
|
76 |
+
|
77 |
+
/* @var $relations IteraResearch_PageToCategory_Model_Resource_Relation_Collection */
|
78 |
+
$relations = $relationModel->getCollection();
|
79 |
+
$relations->addFieldToFilter('page_id', $this->getId());
|
80 |
+
|
81 |
+
if ($relations->count() && count($cids)) {
|
82 |
+
foreach ($cids as $cid) {
|
83 |
+
$cidExist = false;
|
84 |
+
foreach ($relations as $rel) {
|
85 |
+
if ($cid == $rel->getCategoryId()) {
|
86 |
+
$cidExist = true;
|
87 |
+
}
|
88 |
+
if (!in_array($rel->getCategoryId(), $cids)) {
|
89 |
+
// delete existing relation(s)
|
90 |
+
$rel->delete();
|
91 |
+
}
|
92 |
+
}
|
93 |
+
if (!$cidExist) {
|
94 |
+
// update existing or create new relation
|
95 |
+
$newRel = Mage::getModel('pagetocategory/relation');
|
96 |
+
$newRel
|
97 |
+
->setPageId($this->getId())
|
98 |
+
->setCategoryId($cid)
|
99 |
+
->save();
|
100 |
+
}
|
101 |
+
}
|
102 |
+
} elseif (count($cids)) {
|
103 |
+
// create new relation(s)
|
104 |
+
foreach ($cids as $cid) {
|
105 |
+
$newRelation = Mage::getModel('pagetocategory/relation');
|
106 |
+
$newRelation
|
107 |
+
->setPageId($this->getId())
|
108 |
+
->setCategoryId($cid)
|
109 |
+
->save();
|
110 |
+
}
|
111 |
+
} else if ($relations->count()) {
|
112 |
+
// delete existing relation(s)
|
113 |
+
foreach ($relations as $relation) {
|
114 |
+
$relation->delete();
|
115 |
+
}
|
116 |
+
}
|
117 |
+
}
|
118 |
+
}
|
app/code/community/IteraResearch/PageToCategory/Model/Relation.php
ADDED
@@ -0,0 +1,94 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
/**
|
3 |
+
* This file is part of PageToCategory extension.
|
4 |
+
*
|
5 |
+
* @category IteraResearch
|
6 |
+
* @package IteraResearch_PageToCategory
|
7 |
+
* @copyright Copyright (c) 2003-2015 Itera Research, Inc. All rights reserved. (http://www.itera-research.com/)
|
8 |
+
* @license http://www.gnu.org/licenses Lesser General Public License
|
9 |
+
*/
|
10 |
+
|
11 |
+
class IteraResearch_PageToCategory_Model_Relation extends Mage_Core_Model_Abstract
|
12 |
+
{
|
13 |
+
const XML_PATH_USE_PAGE_TITLE = 'cms/pagetocategory/use_page_title';
|
14 |
+
const XML_PATH_SHOW_IN_LEFT_NAV = 'cms/pagetocategory/show_in_left_navigation';
|
15 |
+
|
16 |
+
protected $_pages = array();
|
17 |
+
|
18 |
+
/**
|
19 |
+
* Initialize resource model
|
20 |
+
*
|
21 |
+
*/
|
22 |
+
protected function _construct()
|
23 |
+
{
|
24 |
+
$this->_init('pagetocategory/relation');
|
25 |
+
}
|
26 |
+
|
27 |
+
public function getPageByCategoryId($categoryId)
|
28 |
+
{
|
29 |
+
if (!isset($this->_pages[$categoryId])) {
|
30 |
+
$this->_pages[$categoryId] = $this->getResource()->getPageByCategoryId($categoryId);
|
31 |
+
}
|
32 |
+
return $this->_pages[$categoryId];
|
33 |
+
}
|
34 |
+
|
35 |
+
public function getPageTitleByCategoryId($categoryId)
|
36 |
+
{
|
37 |
+
return $this->_pages[$categoryId]['title'];
|
38 |
+
}
|
39 |
+
|
40 |
+
public function getPageUrlByCategoryId($categoryId)
|
41 |
+
{
|
42 |
+
return Mage::getUrl(null, array('_direct' => $this->_pages[$categoryId]['identifier']));
|
43 |
+
}
|
44 |
+
|
45 |
+
public function canShowInLeftNavigation()
|
46 |
+
{
|
47 |
+
return Mage::getStoreConfig(self::XML_PATH_SHOW_IN_LEFT_NAV);
|
48 |
+
}
|
49 |
+
|
50 |
+
public function canUsePageTitle()
|
51 |
+
{
|
52 |
+
return Mage::getStoreConfig(self::XML_PATH_USE_PAGE_TITLE);
|
53 |
+
}
|
54 |
+
|
55 |
+
public function deleteByCategoryId($categoryId)
|
56 |
+
{
|
57 |
+
$relations = $this->getCollection();
|
58 |
+
$relations->addFieldToFilter('category_id', $categoryId);
|
59 |
+
foreach ($relations as $relation) {
|
60 |
+
$relation->delete();
|
61 |
+
}
|
62 |
+
}
|
63 |
+
|
64 |
+
public function deleteByPageId($pageId)
|
65 |
+
{
|
66 |
+
$relations = $this->getCollection();
|
67 |
+
$relations->addFieldToFilter('page_id', $pageId);
|
68 |
+
foreach ($relations as $relation) {
|
69 |
+
$relation->delete();
|
70 |
+
}
|
71 |
+
}
|
72 |
+
|
73 |
+
/**
|
74 |
+
* Check if category already has assigned page in the same store.
|
75 |
+
*
|
76 |
+
* @param $page
|
77 |
+
* @param $categoryIds
|
78 |
+
*/
|
79 |
+
public function validateAssignment($page, $categoryIds)
|
80 |
+
{
|
81 |
+
$resourceModel = $this->getResource();
|
82 |
+
foreach ($categoryIds as $cid) {
|
83 |
+
if (!$resourceModel->canAssignPageToCategory($page, $cid)) {
|
84 |
+
$cat = Mage::getModel('catalog/category')->load($cid);
|
85 |
+
if (!Mage::app()->isSingleStoreMode()) {
|
86 |
+
$message = Mage::helper('pagetocategory')->__("Category '%s' (ID: %s) already has assigned page in selected store(s). Please assign page to another category or select another store(s).", $cat->getName(), $cid);
|
87 |
+
} else {
|
88 |
+
$message = Mage::helper('pagetocategory')->__("Category '%s' (ID: %s) already has assigned page. Please assign page to another category.", $cat->getName(), $cid);
|
89 |
+
}
|
90 |
+
Mage::throwException($message);
|
91 |
+
}
|
92 |
+
}
|
93 |
+
}
|
94 |
+
}
|
app/code/community/IteraResearch/PageToCategory/Model/Resource/Relation.php
ADDED
@@ -0,0 +1,65 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
/**
|
3 |
+
* This file is part of PageToCategory extension.
|
4 |
+
*
|
5 |
+
* @category IteraResearch
|
6 |
+
* @package IteraResearch_PageToCategory
|
7 |
+
* @copyright Copyright (c) 2003-2015 Itera Research, Inc. All rights reserved. (http://www.itera-research.com/)
|
8 |
+
* @license http://www.gnu.org/licenses Lesser General Public License
|
9 |
+
*/
|
10 |
+
|
11 |
+
class IteraResearch_PageToCategory_Model_Resource_Relation extends Mage_Core_Model_Resource_Db_Abstract
|
12 |
+
{
|
13 |
+
/**
|
14 |
+
* Initialize resource model
|
15 |
+
*
|
16 |
+
*/
|
17 |
+
protected function _construct()
|
18 |
+
{
|
19 |
+
$this->_init('pagetocategory/relation', 'relation_id');
|
20 |
+
}
|
21 |
+
|
22 |
+
public function getPageByCategoryId($categoryId)
|
23 |
+
{
|
24 |
+
$select = $this->_getReadAdapter()->select()
|
25 |
+
->from(array('cp' => $this->getTable('cms/page')), array('cp.title', 'cp.identifier'))
|
26 |
+
->join(
|
27 |
+
array('cps' => $this->getTable('cms/page_store')),
|
28 |
+
'cp.page_id = cps.page_id',
|
29 |
+
array())
|
30 |
+
->join(
|
31 |
+
array('r' => $this->getMainTable()),
|
32 |
+
'r.page_id = cp.page_id',
|
33 |
+
array())
|
34 |
+
->where('cp.is_active = ?', 1)
|
35 |
+
->where('r.category_id = ?', $categoryId)
|
36 |
+
->where('cps.store_id = ?', Mage::app()->getStore()->getId());
|
37 |
+
|
38 |
+
return $this->_getReadAdapter()->fetchRow($select);
|
39 |
+
}
|
40 |
+
|
41 |
+
public function canAssignPageToCategory($page, $categoryId)
|
42 |
+
{
|
43 |
+
$select = $this->_getReadAdapter()->select()
|
44 |
+
->from(array('r' => $this->getMainTable()), 'r.relation_id')
|
45 |
+
->join(
|
46 |
+
array('cp' => $this->getTable('cms/page')),
|
47 |
+
'r.page_id = cp.page_id',
|
48 |
+
array())
|
49 |
+
->join(
|
50 |
+
array('cps' => $this->getTable('cms/page_store')),
|
51 |
+
'cp.page_id = cps.page_id',
|
52 |
+
array())
|
53 |
+
->where('cp.is_active = ?', 1)
|
54 |
+
->where('r.category_id = ?', $categoryId)
|
55 |
+
->where('cp.page_id <> ?', $page->getId())
|
56 |
+
->where('cps.store_id IN (?)', $page->getStores());
|
57 |
+
|
58 |
+
$ids = $this->_getReadAdapter()->fetchCol($select);
|
59 |
+
if (count($ids)) {
|
60 |
+
return false;
|
61 |
+
}
|
62 |
+
return true;
|
63 |
+
}
|
64 |
+
}
|
65 |
+
|
app/code/community/IteraResearch/PageToCategory/Model/Resource/Relation/Collection.php
ADDED
@@ -0,0 +1,21 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
/**
|
3 |
+
* This file is part of PageToCategory extension.
|
4 |
+
*
|
5 |
+
* @category IteraResearch
|
6 |
+
* @package IteraResearch_PageToCategory
|
7 |
+
* @copyright Copyright (c) 2003-2015 Itera Research, Inc. All rights reserved. (http://www.itera-research.com/)
|
8 |
+
* @license http://www.gnu.org/licenses Lesser General Public License
|
9 |
+
*/
|
10 |
+
|
11 |
+
class IteraResearch_PageToCategory_Model_Resource_Relation_Collection extends Mage_Core_Model_Resource_Db_Collection_Abstract
|
12 |
+
{
|
13 |
+
/**
|
14 |
+
* Define resource model
|
15 |
+
*
|
16 |
+
*/
|
17 |
+
protected function _construct()
|
18 |
+
{
|
19 |
+
$this->_init('pagetocategory/relation', 'relation_id');
|
20 |
+
}
|
21 |
+
}
|
app/code/community/IteraResearch/PageToCategory/controllers/Adminhtml/RelationController.php
ADDED
@@ -0,0 +1,62 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
/**
|
3 |
+
* This file is part of PageToCategory extension.
|
4 |
+
*
|
5 |
+
* @category IteraResearch
|
6 |
+
* @package IteraResearch_PageToCategory
|
7 |
+
* @copyright Copyright (c) 2003-2015 Itera Research, Inc. All rights reserved. (http://www.itera-research.com/)
|
8 |
+
* @license http://www.gnu.org/licenses Lesser General Public License
|
9 |
+
*/
|
10 |
+
|
11 |
+
class IteraResearch_PageToCategory_Adminhtml_RelationController extends Mage_Adminhtml_Controller_Action
|
12 |
+
{
|
13 |
+
protected function _initPage()
|
14 |
+
{
|
15 |
+
$id = $this->getRequest()->getParam('page_id');
|
16 |
+
$model = Mage::getModel('cms/page');
|
17 |
+
if ($id) {
|
18 |
+
$model->load($id);
|
19 |
+
if (! $model->getId()) {
|
20 |
+
Mage::getSingleton('adminhtml/session')->addError(
|
21 |
+
Mage::helper('cms')->__('This page no longer exists.'));
|
22 |
+
$this->_redirect('*/*/');
|
23 |
+
return $model;
|
24 |
+
}
|
25 |
+
}
|
26 |
+
$data = Mage::getSingleton('adminhtml/session')->getFormData(true);
|
27 |
+
if (! empty($data)) {
|
28 |
+
$model->setData($data);
|
29 |
+
}
|
30 |
+
Mage::register('cms_page', $model);
|
31 |
+
return $model;
|
32 |
+
}
|
33 |
+
|
34 |
+
/**
|
35 |
+
* Product list page
|
36 |
+
*/
|
37 |
+
public function indexAction()
|
38 |
+
{
|
39 |
+
$this->_initPage();
|
40 |
+
$this->loadLayout();
|
41 |
+
$this->renderLayout();
|
42 |
+
}
|
43 |
+
|
44 |
+
/**
|
45 |
+
* Get categories fieldset block
|
46 |
+
*/
|
47 |
+
public function categoriesAction()
|
48 |
+
{
|
49 |
+
$this->_initPage();
|
50 |
+
$this->loadLayout();
|
51 |
+
$this->renderLayout();
|
52 |
+
}
|
53 |
+
|
54 |
+
public function categoriesJsonAction()
|
55 |
+
{
|
56 |
+
$page = $this->_initPage();
|
57 |
+
$this->getResponse()->setBody(
|
58 |
+
$this->getLayout()->createBlock('pagetocategory/adminhtml_cms_page_edit_tab_categories')
|
59 |
+
->getCategoryChildrenJson($this->getRequest()->getParam('category'))
|
60 |
+
);
|
61 |
+
}
|
62 |
+
}
|
app/code/community/IteraResearch/PageToCategory/etc/config.xml
ADDED
@@ -0,0 +1,105 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?xml version="1.0"?>
|
2 |
+
<!--
|
3 |
+
/**
|
4 |
+
* This file is part of PageToCategory extension.
|
5 |
+
*
|
6 |
+
* @category IteraResearch
|
7 |
+
* @package IteraResearch_PageToCategory
|
8 |
+
* @copyright Copyright (c) 2003-2015 Itera Research, Inc. All rights reserved. (http://www.itera-research.com/)
|
9 |
+
* @license http://www.gnu.org/licenses Lesser General Public License
|
10 |
+
*/
|
11 |
+
-->
|
12 |
+
<config>
|
13 |
+
<modules>
|
14 |
+
<IteraResearch_PageToCategory>
|
15 |
+
<version>1.0.0</version>
|
16 |
+
</IteraResearch_PageToCategory>
|
17 |
+
</modules>
|
18 |
+
<global>
|
19 |
+
<blocks>
|
20 |
+
<pagetocategory>
|
21 |
+
<class>IteraResearch_PageToCategory_Block</class>
|
22 |
+
</pagetocategory>
|
23 |
+
<catalog>
|
24 |
+
<rewrite>
|
25 |
+
<navigation>IteraResearch_PageToCategory_Block_Catalog_Navigation</navigation>
|
26 |
+
</rewrite>
|
27 |
+
</catalog>
|
28 |
+
</blocks>
|
29 |
+
<models>
|
30 |
+
<pagetocategory>
|
31 |
+
<class>IteraResearch_PageToCategory_Model</class>
|
32 |
+
<resourceModel>pagetocategory_resource</resourceModel>
|
33 |
+
</pagetocategory>
|
34 |
+
<pagetocategory_resource>
|
35 |
+
<class>IteraResearch_PageToCategory_Model_Resource</class>
|
36 |
+
<entities>
|
37 |
+
<relation>
|
38 |
+
<table>ir_page_category_relation</table>
|
39 |
+
</relation>
|
40 |
+
</entities>
|
41 |
+
</pagetocategory_resource>
|
42 |
+
<catalog>
|
43 |
+
<rewrite>
|
44 |
+
<category>IteraResearch_PageToCategory_Model_Catalog_Category</category>
|
45 |
+
</rewrite>
|
46 |
+
</catalog>
|
47 |
+
<cms>
|
48 |
+
<rewrite>
|
49 |
+
<page>IteraResearch_PageToCategory_Model_Page</page>
|
50 |
+
</rewrite>
|
51 |
+
</cms>
|
52 |
+
</models>
|
53 |
+
<helpers>
|
54 |
+
<pagetocategory>
|
55 |
+
<class>IteraResearch_PageToCategory_Helper</class>
|
56 |
+
</pagetocategory>
|
57 |
+
</helpers>
|
58 |
+
<resources>
|
59 |
+
<pagetocategory_setup>
|
60 |
+
<setup>
|
61 |
+
<module>IteraResearch_PageToCategory</module>
|
62 |
+
<class>Mage_Core_Model_Resource_Setup</class>
|
63 |
+
</setup>
|
64 |
+
</pagetocategory_setup>
|
65 |
+
</resources>
|
66 |
+
<events>
|
67 |
+
<page_block_html_topmenu_gethtml_before>
|
68 |
+
<observers>
|
69 |
+
<pagetocategory_add_topmenu_items>
|
70 |
+
<class>IteraResearch_PageToCategory_Model_Observer</class>
|
71 |
+
<method>addPagesToTopmenuItems</method>
|
72 |
+
</pagetocategory_add_topmenu_items>
|
73 |
+
</observers>
|
74 |
+
</page_block_html_topmenu_gethtml_before>
|
75 |
+
</events>
|
76 |
+
</global>
|
77 |
+
<adminhtml>
|
78 |
+
<layout>
|
79 |
+
<updates>
|
80 |
+
<pagetocategory>
|
81 |
+
<file>iteraresearch/pagetocategory.xml</file>
|
82 |
+
</pagetocategory>
|
83 |
+
</updates>
|
84 |
+
</layout>
|
85 |
+
</adminhtml>
|
86 |
+
<admin>
|
87 |
+
<routers>
|
88 |
+
<pagetocategory>
|
89 |
+
<use>admin</use>
|
90 |
+
<args>
|
91 |
+
<module>IteraResearch_PageToCategory</module>
|
92 |
+
<frontName>pagetocategory</frontName>
|
93 |
+
</args>
|
94 |
+
</pagetocategory>
|
95 |
+
</routers>
|
96 |
+
</admin>
|
97 |
+
<default>
|
98 |
+
<cms>
|
99 |
+
<pagetocategory>
|
100 |
+
<use_page_title>1</use_page_title>
|
101 |
+
<show_in_left_navigation>0</show_in_left_navigation>
|
102 |
+
</pagetocategory>
|
103 |
+
</cms>
|
104 |
+
</default>
|
105 |
+
</config>
|
app/code/community/IteraResearch/PageToCategory/etc/system.xml
ADDED
@@ -0,0 +1,47 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?xml version="1.0"?>
|
2 |
+
<!--
|
3 |
+
/**
|
4 |
+
* This file is part of PageToCategory extension.
|
5 |
+
*
|
6 |
+
* @category IteraResearch
|
7 |
+
* @package IteraResearch_PageToCategory
|
8 |
+
* @copyright Copyright (c) 2003-2015 Itera Research, Inc. All rights reserved. (http://www.itera-research.com/)
|
9 |
+
* @license http://www.gnu.org/licenses Lesser General Public License
|
10 |
+
*/
|
11 |
+
-->
|
12 |
+
<config>
|
13 |
+
<sections>
|
14 |
+
<cms>
|
15 |
+
<groups>
|
16 |
+
<pagetocategory translate="label">
|
17 |
+
<label>CMS Page Navigation Options</label>
|
18 |
+
<frontend_type>text</frontend_type>
|
19 |
+
<sort_order>200</sort_order>
|
20 |
+
<show_in_default>1</show_in_default>
|
21 |
+
<show_in_website>1</show_in_website>
|
22 |
+
<show_in_store>1</show_in_store>
|
23 |
+
<fields>
|
24 |
+
<use_page_title translate="label">
|
25 |
+
<label>Use Page Title Instead of Category Name</label>
|
26 |
+
<frontend_type>select</frontend_type>
|
27 |
+
<source_model>adminhtml/system_config_source_yesno</source_model>
|
28 |
+
<sort_order>1</sort_order>
|
29 |
+
<show_in_default>1</show_in_default>
|
30 |
+
<show_in_website>1</show_in_website>
|
31 |
+
<show_in_store>1</show_in_store>
|
32 |
+
</use_page_title>
|
33 |
+
<show_in_left_navigation translate="label">
|
34 |
+
<label>Show Page Categories in Left Navigation Block</label>
|
35 |
+
<frontend_type>select</frontend_type>
|
36 |
+
<source_model>adminhtml/system_config_source_yesno</source_model>
|
37 |
+
<sort_order>2</sort_order>
|
38 |
+
<show_in_default>1</show_in_default>
|
39 |
+
<show_in_website>1</show_in_website>
|
40 |
+
<show_in_store>1</show_in_store>
|
41 |
+
</show_in_left_navigation>
|
42 |
+
</fields>
|
43 |
+
</pagetocategory>
|
44 |
+
</groups>
|
45 |
+
</cms>
|
46 |
+
</sections>
|
47 |
+
</config>
|
app/code/community/IteraResearch/PageToCategory/sql/pagetocategory_setup/install-1.0.0.php
ADDED
@@ -0,0 +1,37 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
/**
|
3 |
+
* This file is part of PageToCategory extension.
|
4 |
+
*
|
5 |
+
* @category IteraResearch
|
6 |
+
* @package IteraResearch_PageToCategory
|
7 |
+
* @copyright Copyright (c) 2003-2015 Itera Research, Inc. All rights reserved. (http://www.itera-research.com/)
|
8 |
+
* @license http://www.gnu.org/licenses Lesser General Public License
|
9 |
+
*/
|
10 |
+
|
11 |
+
/* @var $installer Mage_Core_Model_Resource_Setup */
|
12 |
+
$installer = $this;
|
13 |
+
|
14 |
+
$installer->startSetup();
|
15 |
+
|
16 |
+
/**
|
17 |
+
* Create table 'pagetocategory/relation'
|
18 |
+
*/
|
19 |
+
$table = $installer->getConnection()
|
20 |
+
->newTable($installer->getTable('pagetocategory/relation'))
|
21 |
+
->addColumn('relation_id', Varien_Db_Ddl_Table::TYPE_INTEGER, null, array(
|
22 |
+
'identity' => true,
|
23 |
+
'unsigned' => true,
|
24 |
+
'nullable' => false,
|
25 |
+
'primary' => true,
|
26 |
+
), 'Page To Category Relation ID')
|
27 |
+
->addColumn('category_id', Varien_Db_Ddl_Table::TYPE_INTEGER, null, array(
|
28 |
+
'unsigned' => true,
|
29 |
+
'nullable' => true,
|
30 |
+
), 'Category ID')
|
31 |
+
->addColumn('page_id', Varien_Db_Ddl_Table::TYPE_SMALLINT, null, array(
|
32 |
+
'nullable' => true,
|
33 |
+
), 'Page ID')
|
34 |
+
->setComment('CMS Page to Catalog Category Linkage Table');
|
35 |
+
$installer->getConnection()->createTable($table);
|
36 |
+
|
37 |
+
$installer->endSetup();
|
app/design/adminhtml/default/default/layout/iteraresearch/pagetocategory.xml
ADDED
@@ -0,0 +1,20 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?xml version="1.0"?>
|
2 |
+
<!--
|
3 |
+
/**
|
4 |
+
* This file is part of PageToCategory extension.
|
5 |
+
*
|
6 |
+
* @category IteraResearch
|
7 |
+
* @package IteraResearch_PageToCategory
|
8 |
+
* @copyright Copyright (c) 2003-2015 Itera Research, Inc. All rights reserved. (http://www.itera-research.com/)
|
9 |
+
* @license http://www.gnu.org/licenses Lesser General Public License
|
10 |
+
*/
|
11 |
+
-->
|
12 |
+
|
13 |
+
<layout>
|
14 |
+
<adminhtml_cms_page_edit>
|
15 |
+
<reference name="cms_page_edit_tabs">
|
16 |
+
<block type="pagetocategory/adminhtml_cms_page_edit_tab_categories" name="cms_page_edit_tab_categories" />
|
17 |
+
<action method="addTab"><name>categories_section</name><block>cms_page_edit_tab_categories</block></action>
|
18 |
+
</reference>
|
19 |
+
</adminhtml_cms_page_edit>
|
20 |
+
</layout>
|
app/etc/modules/IteraResearch_PageToCategory.xml
ADDED
@@ -0,0 +1,19 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?xml version="1.0"?>
|
2 |
+
<!--
|
3 |
+
/**
|
4 |
+
* This file is part of PageToCategory extension.
|
5 |
+
*
|
6 |
+
* @category IteraResearch
|
7 |
+
* @package IteraResearch_PageToCategory
|
8 |
+
* @copyright Copyright (c) 2003-2015 Itera Research, Inc. All rights reserved. (http://www.itera-research.com/)
|
9 |
+
* @license http://www.gnu.org/licenses Lesser General Public License
|
10 |
+
*/
|
11 |
+
-->
|
12 |
+
<config>
|
13 |
+
<modules>
|
14 |
+
<IteraResearch_PageToCategory>
|
15 |
+
<active>true</active>
|
16 |
+
<codePool>community</codePool>
|
17 |
+
</IteraResearch_PageToCategory>
|
18 |
+
</modules>
|
19 |
+
</config>
|
package.xml
ADDED
@@ -0,0 +1,18 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?xml version="1.0"?>
|
2 |
+
<package>
|
3 |
+
<name>IteraResearch_PageToCategory</name>
|
4 |
+
<version>1.0.0</version>
|
5 |
+
<stability>stable</stability>
|
6 |
+
<license uri="http://www.gnu.org/licenses">Lesser General Public License</license>
|
7 |
+
<channel>community</channel>
|
8 |
+
<extends/>
|
9 |
+
<summary>Allow to assign CMS page to category navigation.</summary>
|
10 |
+
<description>Allow to assign CMS page to category navigation so categories can be used as CMS page navigation. CMS page URL and title will be output in the main menu instead of catalog category URL and title if category has assigned page.</description>
|
11 |
+
<notes>Rewrites category model, page model, category navigation block.</notes>
|
12 |
+
<authors><author><name>IteraResearch</name><user>IteraResearch</user><email>magentocommerce@itera-research.com</email></author></authors>
|
13 |
+
<date>2015-07-01</date>
|
14 |
+
<time>03:42:55</time>
|
15 |
+
<contents><target name="magecommunity"><dir name="IteraResearch"><dir name="PageToCategory"><dir name="Block"><dir name="Adminhtml"><dir name="Cms"><dir name="Page"><dir name="Edit"><dir name="Tab"><file name="Categories.php" hash="c4c3291a6926a0e18267240e0def3b58"/></dir></dir></dir></dir></dir><dir name="Catalog"><file name="Navigation.php" hash="8745f30b0aabce6b110baba9a8a4168b"/></dir></dir><dir name="Helper"><file name="Data.php" hash="afc424ef91c2b3f530649d73d38d6d9c"/></dir><dir name="Model"><dir name="Catalog"><file name="Category.php" hash="4e22e7dd4f8218dd4fe64432458a035d"/></dir><file name="Observer.php" hash="3cfec186dc9a3973ff319bf5c24dc8a0"/><file name="Page.php" hash="6e7aab822cf14e5284b8ecb37d64a150"/><file name="Relation.php" hash="af446ebd6ee264fc94cb4f332e9f0920"/><dir name="Resource"><dir name="Relation"><file name="Collection.php" hash="dd4fb735607195227152fcd69a646d78"/></dir><file name="Relation.php" hash="ec056a215866b382b87e4ad187977a4a"/></dir></dir><dir name="controllers"><dir name="Adminhtml"><file name="RelationController.php" hash="893782079355de138d42ee04ebd65209"/></dir></dir><dir name="etc"><file name="config.xml" hash="e31c6ac5477f1131a97f1634f5331779"/><file name="system.xml" hash="508f63527decf891dd19dbb669785a32"/></dir><dir name="sql"><dir name="pagetocategory_setup"><file name="install-1.0.0.php" hash="819207047a8777f9cd18bbf1e37e40a7"/></dir></dir></dir></dir></target><target name="mageetc"><dir name="modules"><file name="IteraResearch_PageToCategory.xml" hash="e6bc71a832ac1ae36ac35b5383c0ae52"/></dir></target><target name="magedesign"><dir name="adminhtml"><dir name="default"><dir name="default"><dir name="layout"><dir name="iteraresearch"><file name="pagetocategory.xml" hash="1e478b989b13df861f402fe915bd19c3"/></dir></dir></dir></dir></dir></target></contents>
|
16 |
+
<compatible/>
|
17 |
+
<dependencies><required><php><min>5.1.0</min><max>6.0.0</max></php><package><name>Mage_Core_Modules</name><channel>community</channel><min>1.6.2.0</min><max>1.9.1.0</max></package></required></dependencies>
|
18 |
+
</package>
|