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

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;
}
  • Is a static content deploy nescesarry after changing? – Jilco Tigchelaar Dec 4 '17 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. – Kalyan Chakravarthi V Dec 4 '17 at 15:16
  • Not working here.... Maybe because of Redis? – Jilco Tigchelaar Dec 4 '17 at 18:28
  • Not sure about that, please disable all cache you have and try. – Kalyan Chakravarthi V Dec 5 '17 at 6:37
  • Not working with caches disabled.... – Jilco Tigchelaar Dec 5 '17 at 17:09

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.