odiseoteam / SyliusVendorPlugin

This is a Sylius Plugin that add vendors (brands) to your store. The vendors is an entity that sells products and are fully customizable by the admin.
https://odiseo.io
MIT License
59 stars 21 forks source link

Cannot declare class ProductRepository, because the name is already in use. #31

Closed GServices228 closed 2 weeks ago

GServices228 commented 2 weeks ago

Hello,Hope everything is well. I'm following the guide to install the plugin but i'm getting this `error Symfony\Component\ErrorHandler\Error\FatalError^ {#7876

message: "Compile Error: Cannot declare class ProductRepository, because the name is already in use"

code: 0

file: "./src/Repository/ProductRepository.php"

line: 9

-error: array:4 [ "type" => 64 "message" => "Cannot declare class ProductRepository, because the name is already in use" "file" => "/www/wwwroot/app.germinalservices.com/goteach/src/Repository/ProductRepository.php" "line" => 9 ] } ` every time.when trying php bin/console doctrine:migrations:migrate.

Actions i took: -Modify the class name in "src/Repository/ProductRepository.php" and config/packages/_sylius.yaml -restarted from top but it still blocking there.

Any help will be appreciated.Thanks in advance

bigboss86 commented 2 weeks ago

Hi @GServices228. Can you share the ProductRepository file?

GServices228 commented 2 weeks ago

Hello,thanks for the prompt reply. Here is the content:

<?php
// src/Repository/ProductRepository.php

// ...
use Odiseo\SyliusVendorPlugin\Repository\ProductRepositoryInterface;
use Odiseo\SyliusVendorPlugin\Repository\ProductRepositoryTrait;
use Sylius\Bundle\CoreBundle\Doctrine\ORM\ProductRepository as BaseProductRepository;

class ProductRepository extends BaseProductRepository implements ProductRepositoryInterface
{
    use ProductRepositoryTrait;

    // ...
}`
bigboss86 commented 2 weeks ago

You forgot to add the namespace of this file

GServices228 commented 2 weeks ago

oh thanks @bigboss86 .what it suppose to be? Because the Directory and the file were not present so i've created them manually. following the Product namespace,i've modified it as: `<?php

declare(strict_types=1);

namespace App\Repository\ProductRepository;

use Odiseo\SyliusVendorPlugin\Repository\ProductRepositoryInterface; use Odiseo\SyliusVendorPlugin\Repository\ProductRepositoryTrait; use Sylius\Bundle\CoreBundle\Doctrine\ORM\ProductRepository as BaseProductRepository;

class ProductRepository extends BaseProductRepository implements ProductRepositoryInterface { use ProductRepositoryTrait;

// ...

}` Running the command return same problem. What else should i do please.

bigboss86 commented 2 weeks ago

Should be "App\Repository"

<?php

declare(strict_types=1);

namespace App\Repository;

use Odiseo\SyliusVendorPlugin\Repository\ProductRepositoryInterface;
use Odiseo\SyliusVendorPlugin\Repository\ProductRepositoryTrait;
use Sylius\Bundle\CoreBundle\Doctrine\ORM\ProductRepository as BaseProductRepository;

class ProductRepository extends BaseProductRepository implements ProductRepositoryInterface
{
    use ProductRepositoryTrait;
}
GServices228 commented 2 weeks ago

Thanks @bigboss86. worked now.