Replacing a protected function of Backend Article Controller through Hook

Hello Guys, 

I am trying to replace the function “Shopware\Controllers\Backend\Article::prepareVariantData” through plugin however I am even not started my journey. I created a plugin and under “Subscriber” of my plugin I create a file in which 

public static function getSubscribedEvents()
    {
        return [
            ‘Shopware\Controllers\Backend\Article::prepareVariantData::replace’ => ‘replacedPrepareVariantData’
        ];
    }

 

public function replacedPrepareVariantData(\Enlight_Hook_HookArgs $args)
    {

        $args->setReturn($args);

        $controller = $args->getSubject();

        $view = $controller->View();
        $request = $controller->Request();

        \Doctrine\Common\Util\Debug::dump($request, 2, true, false);
        //var_dump($result);

        $variant = $request->getParam(‘variant’);
        $detailData = $request->getParam(‘detailData’);
        $counter = $request->getParam(‘counter’);
        $dependencies = $request->ggetParamet(‘dependencies’);
        $priceVariations = $request->getParamet(‘priceVariations’);
        $allOptions = $request->getParam(‘allOptions’);
        $originals = $request->getParam(‘originals’);
        $article = $request->getParam(‘article’);
        $mergeType = $request->getParam(‘mergeType’);

        $optionsModels = ;
        $tax = $article->getTax();
        $optionIds = ;

        //iterate the original ids to get the new variant name
        foreach ($originals as $id) {
            $optionId = $variant[‘o’ . $id . ‘Id’];

            //first we push the option ids in an one dimensional array to check
            $optionIds = $optionId;

            $optionsModels = $allOptions[$optionId];
        }

        $abortVariant = false;
        foreach ($dependencies as $dependency) {
            if (in_array($dependency[‘parentId’], $optionIds) && in_array($dependency[‘childId’], $optionIds)) {
                $abortVariant = true;
            }
        }

        //if the user selects the “merge variants” generation type, we have to check if the current variant already exist.
        if ($mergeType === 2 && $abortVariant === false) {
            $query = $this->getRepository()->getDetailsForOptionIdsQuery($article->getId(), $optionsModels);
            $exist = $query->getArrayResult();
            $abortVariant = !empty($exist);
        }

        if ($abortVariant) {
            return false;
        }

        //create the new variant data
        $variantData = [
            ‘active’ => 1,
            ‘configuratorOptions’ => $optionsModels,
            ‘purchasePrice’ => $detailData[‘purchasePrice’],
            ‘lastStock’ => $detailData[‘lastStock’],
        ];

        if ($mergeType == 1 && $counter == 0) {
            $variantData[‘number’] = $detailData[‘number’];
            ++$counter;
        } else {
            do {
                $variantData[‘kind’] = 2;
                $variantData[‘number’] = $detailData[‘number’] . ‘.’ . $counter;
                ++$counter;
            } while ($this->orderNumberExist($variantData[‘number’]));
        }

        $prices = $this->prepareVariantPrice($detailData, $priceVariations, $optionIds, $tax);
        if ($prices) {
            $variantData[‘prices’] = $prices;
        }

        return $variantData;
    }

 

I have to alter the function but I am not confirmed weather it is working or not because It is not throughing dump also in proxy class it is not creating the hook entry. Please help.

Try writing the event name with underscores Shopware_Controllers_…