I am customising Oxidshop for one of my clients. I want to customise the "changebasket" function in BasketComponent file to add more validations to it. For this purpose I have also created a custom module. I am trying to extend the class using metadata file.
'extend' => array(
'oxcmp_basket' => \MyVendor\Basket\Application\Components\BasketComponent::class,
),
The BasketComponent file has following code,
<?php
namespace MyVendor\Basket\Application\Components;
/**
* Class LinslinSliderMain.
*/
class BasketComponent extends BasketComponent_parent
{
/**
* @param null $sProductId
* @param null $dAmount
* @param null $aSel
* @param null $aPersParam
* @param bool $blOverride
*/
public function changebasket($sProductId = null, $dAmount = null, $aSel = null, $aPersParam = null, $blOverride = true)
{
echo 'call success';exit;
parent::changebasket($sProductId, $dAmount, $aSel, $aPersParam, $blOverride);
}
}
The gets activated. However, when I refresh any page in frontend, it gets deactivated automatically. I don't know, what's wrong with the code.
EDIT: I am getting this error in oxideshop.log file
Module class MyVendor\Basket\Application\Components\BauerBasketComponent not found. Module ID basket disabled.
depending on your OXID eShop version it might be a different line, but the error message you are stating originates from
OxidEsales\EshopCommunity\Core\Module\ModuleChainsGenerator::onModuleExtensionCreationError
.When activating your module, the system tries to generate the class chain with your
BasketComponent
class in it. As your class is a namespaced class, OXID tries to check if it can find the class via the composer autoload file, if not, the shop throws this exception.So I assume the module is not installed via composer, at least the namespace seems unknown to composer. You can check in the module documentation on how this should be achieved
Hope I could help
/Flo