Extend Controller for module development but didn't works in oxid 7

I am create one module like loggerdemo and now i am want to extends controller but didn’t get success.
My metadata.php like below

$aModule = array(
    'id'           => 'loggerdemo',
    'title'        => 'Oxid-Logger',
    'description'  => '',
    'thumbnail'    => 'logo.jpg',
    'version'      => '2.0',
    'author'       => 'OXID eSales AG',
    'controllers'  => [],
    'blocks' => [],
    'templates' => [],
    'extend' => [
        \OxidEsales\Eshop\Application\Model\Basket::class => \OxidEsales\LoggerDemo\Model\Basket::class,
        \OxidEsales\EshopCommunity\Core\Controller\Base\ShopControl::class => \OxidEsales\LoggerDemo\Controller\MyShopControl::class,
        OxidEsales\Eshop\Application\Controller\StartController::class => \OxidEsales\LoggerDemo\Controller\StartController::class,

    ],

MyShopController code is like below

<?php
namespace OxidEsales\LoggerDemo\Controller;
//namespace OxidEsales\LoggerDemo\Model;
use OxidEsales\EshopCommunity\Core\Controller\Base\ShopControl;
use OxidEsales\Eshop\Core\Registry;


class MyShopControl extends ShopControl_parent
{
    public function start($controllerKey = null, $function = null, $parameters = null, $viewsChain = null)
    {
        return 444;
    }
    public function init()
    {
        parent::init();

        // Log the class name
        $logger = Registry::getLogger();
        $logger->debug(__METHOD__ . ': Using ' . __CLASS__);
    }

}

This should be class MyShopControl extends MyShopControl_parent

Updated like this

class MyShopControl extends MyShopControl_parent

but still not get any changes.
And how can I verify that MyShopControl is now taking instead of ShopControl?

class StartController extends StartController_parent
{
    public function render()
    { return 999;
        if (Registry::getRequest()->getRequestEscapedParameter('showexceptionpage') == '1') {
            return 'message/exception';
        }
        parent::render();

        return $this->_sThisTemplate;
    }
}

I was put this code in MyShopcontrol so this will be give an error
but nothing happen changes as of now

Hey, we need a little more clarity on the problem you’re having. What exactly is not working? Are there any error messages in the admin area or in the log? Could it be that your LogLevel is not set to Debug?

Also, I wonder if your module is even active and if the current configuration is registered for it. Have you checked if your namespace is registered? Normally you get an error if your class can’t be found. You can also check in vendor/composer/autoload_psr4.php if your namespace is registered correctly.

It is also noticeable that you extend from EshopCommunity, although you should not do that, but Eshop. Otherwise it would break the inheritance chain, making your module not edition independent:

https://docs.oxid-esales.com/developer/en/latest/development/modules_components_themes/module/tutorials/extend_shop_class.html

Then this line in your metadata.php is missing an \ at the beginning:

OxidEsales\Eshop\Application\Controller\StartController::class => \OxidEsales\LoggerDemo\Controller\StartController::class,

If you are just starting to learn OXID anyway, an OXID developer training course might be an effective way to get started. This is sometimes offered in English. You can find this (academy) and other information here:
https://forum.oxid-esales.com/t/getting-started-for-user-seller-and-developer/98363

This topic was automatically closed 365 days after the last reply. New replies are no longer allowed.