Skip to content

Commit

Permalink
Initial commit
Browse files Browse the repository at this point in the history
  • Loading branch information
rarog committed May 7, 2014
1 parent cde9541 commit a76aaa8
Show file tree
Hide file tree
Showing 7 changed files with 190 additions and 201 deletions.
249 changes: 48 additions & 201 deletions LICENSE

Large diffs are not rendered by default.

3 changes: 3 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,3 +2,6 @@ CatalogTuning
=============

Magento catalog tuning extension

v1.0.0
- Option to enforce adding catalog breadcrumb to products if they were called directly.
18 changes: 18 additions & 0 deletions app/code/community/AndrejSinicyn/CatalogTuner/Helper/Data.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
<?php
/**
* Magento
*
* NOTICE OF LICENSE
*
* This source file is subject to the Open Software License (OSL 3.0)
* that is available through the world-wide-web at this URL:
* http://opensource.org/licenses/osl-3.0.php
*
* @category AndrejSinicyn
* @package AndrejSinicyn_CatalogTuner
* @copyright Copyright (c) 2014 Andrej Sinicyn
* @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
*/
class AndrejSinicyn_CatalogTuner_Helper_Data extends Mage_Core_Helper_Abstract
{
}
32 changes: 32 additions & 0 deletions app/code/community/AndrejSinicyn/CatalogTuner/Model/Observer.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
<?php
/**
* Magento
*
* NOTICE OF LICENSE
*
* This source file is subject to the Open Software License (OSL 3.0)
* that is available through the world-wide-web at this URL:
* http://opensource.org/licenses/osl-3.0.php
*
* @category AndrejSinicyn
* @package AndrejSinicyn_CatalogTuner
* @copyright Copyright (c) 2014 Andrej Sinicyn
* @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
*/
class AndrejSinicyn_CatalogTuner_Model_Observer
{
const XML_PATH_ADD_BREADCRUMBS = 'catalog/tuning/add_catalog_breadcrumbs_to_product';

public function onCatalogControllerProductInit(Varien_Event_Observer $observer)
{
if (Mage::getStoreConfig(self::XML_PATH_ADD_BREADCRUMBS) && !Mage::registry('current_category') && ($product = Mage::registry('current_product'))) {
$productCategories = $product->getCategoryIds();
if (count($productCategories) > 0) {
// Assigning the first product category as current category if no category was set previously.
$category = Mage::getModel('catalog/category')->load($productCategories[0]);
$product->setCategory($category);
Mage::register('current_category', $category);
}
}
}
}
50 changes: 50 additions & 0 deletions app/code/community/AndrejSinicyn/CatalogTuner/etc/config.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,50 @@
<?xml version="1.0"?>
<config>
<modules>
<AndrejSinicyn_CatalogTuner>
<version>1.0.0</version>
</AndrejSinicyn_CatalogTuner>
</modules>
<global>
<helpers>
<catalogtuner>
<class>AndrejSinicyn_CatalogTuner_Helper</class>
</catalogtuner>
</helpers>
<models>
<catalogtuner>
<class>AndrejSinicyn_CatalogTuner_Model</class>
<resourceModel>catalogtuner_mysql4</resourceModel>
</catalogtuner>
</models>
<events>
<catalog_controller_product_init>
<observers>
<catalog_controller_product_init_handler>
<type>model</type>
<class>catalogtuner/observer</class>
<method>onCatalogControllerProductInit</method>
</catalog_controller_product_init_handler>
</observers>
</catalog_controller_product_init>
</events>
</global>
<adminhtml>
<translate>
<modules>
<AndrejSinicyn_CatalogTuner>
<files>
<default>AndrejSinicyn_CatalogTuner.csv</default>
</files>
</AndrejSinicyn_CatalogTuner>
</modules>
</translate>
</adminhtml>
<default>
<catalog>
<tuning>
<add_catalog_breadcrumbs_to_product>0</add_catalog_breadcrumbs_to_product>
</tuning>
</catalog>
</default>
</config>
29 changes: 29 additions & 0 deletions app/code/community/AndrejSinicyn/CatalogTuner/etc/system.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
<?xml version="1.0"?>
<config>
<sections>
<catalog module="catalogtuner">
<groups>
<tuning translate="label">
<label>Tuning</label>
<frontend_type>text</frontend_type>
<sort_order>990</sort_order>
<show_in_default>1</show_in_default>
<show_in_website>1</show_in_website>
<show_in_store>1</show_in_store>
<fields>
<add_catalog_breadcrumbs_to_product translate="label comment">
<label>Force adding catalog breadcrumbs to product</label>
<frontend_type>select</frontend_type>
<source_model>adminhtml/system_config_source_yesno</source_model>
<sort_order>0</sort_order>
<show_in_default>1</show_in_default>
<show_in_website>1</show_in_website>
<show_in_store>1</show_in_store>
<comment>Tries to add catalog breadcrumbs to product, if it is called directly without category.</comment>
</add_catalog_breadcrumbs_to_product>
</fields>
</tuning>
</groups>
</catalog>
</sections>
</config>
10 changes: 10 additions & 0 deletions app/etc/modules/AndrejSinicyn_CatalogTuner.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
<?xml version="1.0"?>
<config>
<modules>
<AndrejSinicyn_CatalogTuner>
<active>true</active>
<codePool>community</codePool>
<version>1.0.0</version>
</AndrejSinicyn_CatalogTuner>
</modules>
</config>

0 comments on commit a76aaa8

Please sign in to comment.