New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Attempted to load class "IntegrationConfiguration" #114
Comments
Do we have solution to fix this? |
Made the changes in installer.php and it worked for me * @copyright Copyright (c) 2018 DIVANTE (https://divante.co) */ namespace Divante\MagentoIntegrationBundle\Migrations; use Divante\MagentoIntegrationBundle\Domain\IntegrationConfiguration\IntegrationHelper; use Doctrine\DBAL\Migrations\Version; use Doctrine\DBAL\Schema\Schema; use Pimcore\Cache; use Pimcore\Db\Connection; use Pimcore\Extension\Bundle\Installer\MigrationInstaller; use Pimcore\Migrations\MigrationManager; use Pimcore\Model\DataObject; use Pimcore\Model\Property\Predefined; use Symfony\Component\HttpKernel\Bundle\BundleInterface; use Symfony\Component\HttpKernel\Config\FileLocator; use Symfony\Component\Process\Process; use Pimcore\Model\DataObject\ClassDefinition; use Pimcore\Model\DataObject\ClassDefinition\Service; /** * Class Installer * @Package Divante\MagentoIntegrationBundle\Migrations */ class Installer extends MigrationInstaller { const CONFIGURATION_CLASS_NAME = 'IntegrationConfiguration'; /** @var FileLocator */ protected $fileLocator; private $installSourcesPath; /** * @var array */ private $classesToInstall = [ 'IntegrationConfiguration' => 'IntegrationConfiguration' ]; /** * @param BundleInterface $bundle * @param Connection $connection * @param MigrationManager $migrationManager * @param FileLocator $fileLocator */ public function __construct( BundleInterface $bundle, Connection $connection, MigrationManager $migrationManager, FileLocator $fileLocator ) { $this->fileLocator = $fileLocator; $this->installSourcesPath = __DIR__ . '/../Resources/install'; parent::__construct($bundle, $connection, $migrationManager); } /** * @param Schema $schema * @param Version $version */ public function migrateInstall(Schema $schema, Version $version): void { if (!Predefined::getByKey(IntegrationHelper::PRODUCT_TYPE_CONFIGURABLE_ATTRIBUTE) instanceof Predefined) { $propertyData = [ 'name' => 'Configurable Attributes', 'key' => IntegrationHelper::PRODUCT_TYPE_CONFIGURABLE_ATTRIBUTE, 'ctype' => 'object', 'type' => 'text', 'inheritable' => true ]; $property = Predefined::create(); $property->setValues($propertyData); $property->save(); } Cache::disable(); $this->installClasses(); // $classDefinition = $this->locateClassDefinitionFile(); // $command = ['bin/console', 'pimcore:definition:import:class', $classDefinition]; // $process = new Process($command, PIMCORE_PROJECT_ROOT); // $process->setTimeout(0); // $process->run(); // $this->outputWriter->write($process->getOutput()); Cache::enable(); if (!file_exists(PIMCORE_LOG_DIRECTORY . '/magento2-connector')) { mkdir(PIMCORE_LOG_DIRECTORY . '/magento2-connector', 0740); } $this->createSampleObject(); } /** * @return string */ protected function locateClassDefinitionFile(): string { $filename = '@DivanteMagentoIntegrationBundle/Resources/install/classes/class_IntegrationConfiguration_export.json'; return $this->fileLocator->locate($filename); } protected function createSampleObject() { $object = new DataObject\IntegrationConfiguration(); $object->setParent(DataObject\Service::createFolderByPath('/integration-configuration')); $object->setPublished(false); $object->setOmitMandatoryCheck(true); $object->setKey('magento-configuration'); $object->save(); } private function getClassesToInstall(): array { $result = []; foreach (array_keys($this->classesToInstall) as $className) { $filename = sprintf('class_%s_export.json', $className); $path = $this->installSourcesPath . '/classes/' . $filename; $path = realpath($path); if (false === $path || !is_file($path)) { throw new AbortMigrationException(sprintf( 'Class export for class "%s" was expected in "%s" but file does not exist', $className, $path )); } $result[$className] = $path; } return $result; } private function installClasses() { $classes = $this->getClassesToInstall(); $mapping = $this->classesToInstall; foreach ($classes as $key => $path) { $class = ClassDefinition::getByName($key); if ($class) { $this->outputWriter->write(sprintf( ' WARNING: Skipping class "%s" as it already exists', $key )); continue; } $class = new ClassDefinition(); $classId = $mapping[$key]; $class->setName($key); $class->setId($classId); $data = file_get_contents($path); $success = Service::importClassDefinitionFromJson($class, $data, false, true); if (!$success) { throw new AbortMigrationException(sprintf( 'Failed to create class "%s"', $key )); } } } /** * @param Schema $schema * @param Version $version */ public function migrateUninstall(Schema $schema, Version $version): void { Cache::disable(); $class = DataObject\ClassDefinition::getByName(static::CONFIGURATION_CLASS_NAME); if ($class) { $class->delete(); } Cache::enable(); rmdir(PIMCORE_LOG_DIRECTORY . '/magento2-connector'); } } |
@prince0212 Could you create Pull Request with changes? |
sure will do the needful |
I am getting the same error on an already running instance (since 2020). After running
I can't access the configuration object, as the error breaks the Pimcore UI. |
Related to #105 and #110, the package does not comply with PSR-4, so Composer 2 won't autoload the necessary classes. |
Using Pimcore 6.0
composer require divante-ltd/pimcore-magento2-bridge:dev-develop-v2
getting below error :
Attempted to load class "IntegrationConfiguration" from namespace "Pimcore\Model\DataObject".
Did you forget a "use" statement for "Divante\MagentoIntegrationBundle\Domain\DataObject\IntegrationConfiguration"?
The text was updated successfully, but these errors were encountered: