0

Pretty sure I'm a HUGE noob (sorry). So this is what I've got so far: app/code/local/Mage/ProductLogUpdate/etc/config.xml

<?xml version="1.0"?>
<config>
    <modules>
        <Mage_ProductLogUpdate>
            <version>0.0.1</version>
        </Mage_ProductLogUpdate>
    </modules>
    <global>
        <blocks>
            <adminhtml>
                <rewrite>
                    <catalog_category_tabs>Mage_ProductLogUpdate_Block_Catalog_Category_Tabs</catalog_category_tabs>
                </rewrite>
            </adminhtml>
        </blocks>
        <models>
            <mage_productlogupdate>
                <class>Mage_ProductLogUpdate_Model</class>
            </mage_productlogupdate>
        </models>
        <events>
            <catalog_product_save_after>
                <observers>
                    <mage_productlogupdate>
                        <class>mage_productlogupdate/observer</class>
                        <method>logUpdate</method>
                        <type>singleton</type>
                    </mage_productlogupdate>
                </observers>
            </catalog_product_save_after>
        </events>
    </global>
</config>

app/code/local/Mage/ProductLogUpdate/Block/Catalog/Category/Tabs.php:

<?php
class Mage_ProductLogUpdate_Block_Catalog_Category_Tabs extends Mage_Adminhtml_Block_Catalog_Category_Tabs {
    public function addTabsToCategory(){
        $this->addTab('idname', array(
                    'label'     => Mage::helper('catalog')->__('Tab name'),
                    'content'   => "<h2>tasdf</h2>"
            ));

        return parent::_prepareLayout();
    }
}

I used this model/observer from a tutorial to test if my code works app/code/local/Mage/ProductLogUpdate/Model/Observer.php:

<?php
/* Our class name should follow the directory structure of our Observer.php model, starting from the namespace, replacing directory separators with underscores. The directory of ousr Observer.php is following:
 app/code/local/Mage/ProductLogUpdate/Model/Observer.php */
class Mage_ProductLogUpdate_Model_Observer{
    // Magento passes a Varien_Event_Observer object as the first parameter of dispatched events.
    public function logUpdate(Varien_Event_Observer $observer){
        // Retrieve the product being updated from the event observer
        $product = $observer->getEvent()->getProduct();
        // Write a new line to var/log/product-updates.log
        $name = $product->getName();
        $sku = $product->getSku();
        Mage::log("{$name} ({$sku}) updated", null, 'product-updates.log');
    }
}
?>

And ofcourse this file app/etc/modules/Mage_ProductLogUpdate.xml:

<?xml version="1.0"?>
<config>
    <modules>
        <Mage_ProductLogUpdate>
            <active>true</active>
            <codePool>local</codePool>
        </Mage_ProductLogUpdate>
    </modules>
</config>

So I'm completely lost and don't know what to do, I can't even find a lot of information about this on google and stuff. I'm trying to use this answer, but I just don't know how to implement his code.

EDIT: Changed location names from app/code/Mage/ProductLogUpdate/.. to app/code/local/Mage/ProductLogUpdate/... Sadly enough, my problem is still not fixed.

To be clear, I'm trying to add a custom tab here.

0

Could you explain what you are trying to accomplish here?

Also try this:

app/code/Mage/ProductLogUpdate/Block/Catalog/Category/Tabs.php:
If you want to use the layout you should overrule the _prepareLayout() instead because addTabsToCategory() is never defined.

<?php
    class Mage_ProductLogUpdate_Block_Catalog_Category_Tabs extends Mage_Adminhtml_Block_Catalog_Category_Tabs {
        protected function _prepareLayout()
            parent::_prepareLayout();
            $this->addTab('idname', array(
                    'label'     => Mage::helper('catalog')->__('Tab name'),
                    'content'   => "<h2>Hello world!</h2>",
                ));

            return $this;  
        }
    }

Also note: Your files are located in the wrong location. You have placed your files under app/code/Mage.

Why is this the wrong location you ask? Look at this file: app/etc/modules/Mage_ProductLogUpdate.xml
It's telling you that the module is located in the codePool local.

This means that your files should be located under:
app/code/local/Mage/......

1

Your file path and class name are not matching for this - app/code/local/Mage/ProductLogUpdate/Block/Recentproducts.php:

class Mage_ProductLogUpdate_Block_Catalog_Category_Tabs extends Mage_Adminhtml_Block_Catalog_Category_Tabs {
    public function addTabsToCategory(){
        $this->addTab('idname', array(
                    'label'     => Mage::helper('catalog')->__('Tab name'),
                    'content'   => "<h2>tasdf</h2>"
            ));

        return parent::_prepareLayout();
    }
}

According to your class name your file name should be Tabs.php and path should be app/code/local/Mage/ProductLogUpdate/Block/Catalog/Category/Tabs.php

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.