0

Magento 2 while saving product from admin getting error as "Class Magento\ConfigurableProduct\Model\Product\VariationHandler does not exist". But this class is there in Vendor folder.

There is no use even after clearing generation files and re-compiling the code.

1 Answer 1

1

This is a strange issue.

Override getConstructor method in vendor/magento/framework/Code/Reader/ClassReader.php and change it to below

public function getConstructor($className)
{
    $class = new \ReflectionClass($className);
    $result = null;
    $constructor = $class->getConstructor();
    if ($constructor) {
        $result = [];
        /** @var $parameter \ReflectionParameter */
        foreach ($constructor->getParameters() as $parameter) {
            try {
                $result[] = [
                    $parameter->getName(),
                    $parameter->getClass() !== null ? $parameter->getClass()->getName() : null,
                    !$parameter->isOptional(),
                    $parameter->isOptional()
                        ? ($parameter->isDefaultValueAvailable() ? $parameter->getDefaultValue() : null)
                        : null,
                ];
            } catch (\ReflectionException $e) {
            if($parameter->getName() == 'variationHandler' ) {
                $result[] = [
                        $parameter->getName(),
                        $parameter->getClass() !== null ? $parameter->getClass()->getName() : null,
                        !$parameter->isOptional(),
                        $parameter->isOptional()
                            ? ($parameter->isDefaultValueAvailable() ? $parameter->getDefaultValue() : null)
                            : null,
                    ];
                    continue;
            }
                $message = $e->getMessage();
                throw new \ReflectionException($message, 0, $e);
            }
        }
    }

    return $result;
}
7
  • Is a static content deploy nescesarry after changing? Commented Dec 4, 2017 at 15:12
  • No need, as it is fetching the file directly from Vendor. For my need, I quickly did the change in the vendor itself and checked. It worked perfectly. Commented Dec 4, 2017 at 15:16
  • Not working here.... Maybe because of Redis? Commented Dec 4, 2017 at 18:28
  • Not sure about that, please disable all cache you have and try. Commented Dec 5, 2017 at 6:37
  • Not working with caches disabled.... Commented Dec 5, 2017 at 17:09

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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