akeneo / pim-community-dev

[Community Development Repository] The open source Product Information Management (PIM)
http://www.akeneo.com
Other
958 stars 518 forks source link

Bug: Product set family #4306

Closed a2xchip closed 8 years ago

a2xchip commented 8 years ago

I'm reporting a Bug

For versions: from at least 1.4 to master

Scenario:

Given I have family with code "camcorder". And its label in english is "Camcorder" And I enter family edit form page and change its label to "Видеокамеры" Then I enter product edit form and want to change its family to camcorder by label And I enter "Видео" and "Видеокамеры" in search result

It fails.

Resons

The reason is that in FamilySearchableRepository we have search params as where code and or where label.

    public function findBySearch($search = null, array $options = [])
    {
        $qb = $this->entityManager->createQueryBuilder()->select('f')->from($this->entityName, 'f');

        if (null !== $search && '' !== $search) {
            $qb->where('f.code like :search')->setParameter('search', '%' . $search . '%');
            if (isset($options['locale'])) {
                $qb->leftJoin('f.translations', 'ft');
                $qb->orWhere('ft.label like :search AND ft.locale = :locale');
                $qb->setParameter('search', '%' . $search . '%');
                $qb->setParameter('locale', $options['locale']);
            }
        }

But or where label depends on `options['locale']that is never transmitted byRest\FamilyController`` cause it does not recieves it.

    public function indexAction(Request $request)
    {
        $families = $this->familySearchableRepo->findBySearch(
            $request->query->get('search'),
            $request->query->get('options', ['limit' => 20])
        );

        $normalizedFamilies = [];
        foreach ($families as $family) {
            $normalizedFamilies[$family->getCode()] = $this->normalizer->normalize($family, 'json');
        }

        return new JsonResponse($normalizedFamilies);
    }

search url will be so

/configuration/family/rest?search=виде&options%5Blimit%5D=20&options%5Bpage%5D=1
juliensnz commented 8 years ago

Hello @a2xchip,

Thank you very much for this detailed issue report. You are very lucky because this bug was already registered on our bug tracker and I picked it this week ! Here is my PR which should be merged soon: https://github.com/akeneo/pim-community-dev/pull/4302

Kind regards,

Julien

a2xchip commented 8 years ago

@juliensnz Cool! :-)

I got appeal from our users today about this issue. We use different sources for families from romanian and russian sources and they are all imported automatically. It was ok till they were working on that from romanian cause codes and labels are both the same. But russian labels are sluggified to latin codes so they are different and bug came up. I lost some hours to figure out what happens and why it is not working but see that you fix it by javascript changes very easy. Thank you!!!

LaureBrosseau commented 8 years ago

Hello, the 1.5.2 has been released and it contains this fix. Best regards,

Laure