Posting in the Magento forums has been disabled pending the implementation of a new and improved forum solution which should better serve the community.

For new questions please post at magento.stackexchange.com, the community-run support site for the Magento community. We will be providing updates on the new forum solution soon. For questions or concerns please email community@magento.com.

Magento Forum

ich bekomme es nicht hin die Navigation.php zu überschreiben. 
 
nico76
Sr. Member
 
Avatar
Total Posts:  76
Joined:  2007-09-06
Berlin
 

Hi,

ich bekomme es nicht hin die Navigation.php local zu überschreiben.

Ich habe diese Files angelegt:
/www/app/code/local/MyCompany/Catalog/Block/Navigation.php
/www/app/code/local/MyCompany/Catalog/etc/config.xml
/www/app/etc/modules/MyCompany_Catalog.xml

Navigation.php

* @author      Magento Core Team <core@magentocommerce.com>
 */
class 
MyCompany_Catalog_Block_Navigation extends Mage_Core_Block_Template

{
    
protected $_categoryInstance null;

    protected function 
_construct()
    
{
        $this
->addData(array(
            
'cache_lifetime'    => false,
            
'cache_tags'        => array(Mage_Catalog_Model_Category::CACHE_TAGMage_Core_Model_Store_Group::CACHE_TAG),
        ));
    
}


    
/**
     * Create a CSS appropriate ID from the category name
     *
     * @return Varien_Data_Tree_Node_Collection
     */

    
public function getCategoryID ($catname
    
{
        $replace 
= array(' ''!''@''#''$''%''^''&''*''('')''=''+'"'"'"'';'':''/''?'',''<''>''.''['']''{''}'"\\"'|''`''~');
        return 
strtolower(str_replace($replace'-'$catname));
    

    
public function getCacheKey()
    
{
        $key 
Mage::app()->getStore()->getId().'_CATALOG_NAVIGATION' md5($this->getTemplate());
        if (
$this->getCurrentCategory()) {
            $key
.=  md5($this->getCurrentCategory()->getPath());
        
}
        
return $key;
    
}

    
/**
     * Get catagories of current store
     *
     * @return Varien_Data_Tree_Node_Collection
     */
    
public function getStoreCategories()
    
{
        $helper 
Mage::helper('catalog/category');
        return 
$helper->getStoreCategories();
    
}

    
/**
     * Retrieve child categories of current category
     *
     * @return Varien_Data_Tree_Node_Collection
     */
    
public function getCurrentChildCategories()
    
{
        $layer 
Mage::getSingleton('catalog/layer');
        
$category   $layer->getCurrentCategory();
        
/* @var $category Mage_Catalog_Model_Category */
        
$collection Mage::getModel('catalog/category')->getCollection();
        
/* @var $collection Mage_Catalog_Model_Resource_Eav_Mysql4_Category_Collection */
        
$collection->addAttributeToSelect('url_key')
            ->
addAttributeToSelect('name')
            ->
addAttributeToSelect('is_anchor')
            ->
addAttributeToFilter('is_active'1)
            ->
addIdFilter($category->getChildren())
            ->
setOrder('position''ASC')
            ->
joinUrlRewrite()
            ->
load();

        
$productCollection Mage::getResourceModel('catalog/product_collection');
        
$layer->prepareProductCollection($productCollection);
        
$productCollection->addCountToCategories($collection);
        return 
$collection;
    
}

    
/**
     * Checkin activity of category
     *
     * @param   Varien_Object $category
     * @return  bool
     */
    
public function isCategoryActive($category)
    
{
        
if ($this->getCurrentCategory()) {
            
return in_array($category->getId(), $this->getCurrentCategory()->getPathIds());
        
}
        
return false;
    
}

    
protected function _getCategoryInstance()
    
{
        
if (is_null($this->_categoryInstance)) {
            $this
->_categoryInstance Mage::getModel('catalog/category');
        
}
.
.
.
config.xml
<?xml version="1.0"?>
<config>
    <
modules>
        <
MyCompany_Catalog>
            <
version>0.1.0</version>
        </
MyCompany_Catalog>
    </
modules>
    <global>
        <
blocks>
            <
catalog>
                <
rewrite>
                        <
Navigation>MyCompany_Catalog_Block_Navigation</Navigation>
                </
rewrite>
            </
catalog>
        </
blocks>
    </global>
</
config>

MyCompany_Catalog.xml

<config>
     <
modules>
        <
MyCompany_Catalog>
            <
active>true</active>
            <
codePool>local</codePool>
        </
MyCompany_Catalog>
     </
modules>
</
config>

Ich habe mich dabei an diesem Wikieintrag orientiert:
http://www.magentocommerce.com/wiki/groups/174/changing_and_customizing_magento_code

Kann mir jemand sagen, was ich falsch gemacht habe?

 
Magento Community Magento Community
Magento Community
Magento Community
 
mr_jingles
Member
 
Avatar
Total Posts:  42
Joined:  2009-01-05
Leipzig
 

Hallo,

probier mal <Navigation> klein zu schreiben:

<navigation>MyCompany_Catalog_Block_Navigation</navigation>

Meistens macht es übrigens Sinn von der überschriebenen Klasse abzuleiten, um redundanten Code zu vermeiden oder Änderungen and der Core-Datei zu berücksichtigen.

Gruß,
mr_jingles

 
Magento Community Magento Community
Magento Community
Magento Community
 
nico76
Sr. Member
 
Avatar
Total Posts:  76
Joined:  2007-09-06
Berlin
 

oooh verdammt, wie blind von mir!

Danke!!!!!

funktioniert jetzt.

 
Magento Community Magento Community
Magento Community
Magento Community
Magento Community
Magento Community
Back to top