Pim-community-dev: Adding attributes to family from >20th group

Created on 20 Apr 2017  ·  9Comments  ·  Source: akeneo/pim-community-dev

This may be related to issue #6054

Version 1.7.3

When adding attributes to an attribute family, any attribute that is in >20th attribute group in the system by sort_order fails and throws a javascript error.

attributes.js:109 Uncaught TypeError: Cannot read property 'sort_order' of undefined at child.<anonymous> (attributes.js:109) at underscore.js:380 at Function._.map._.collect (underscore.js:172) at Function._.sortBy (underscore.js:376) at child.<anonymous> (attributes.js:108) at Array.<anonymous> (jquery-1.10.2.js:3204) at fire (jquery-1.10.2.js:3048) at Object.add [as done] (jquery-1.10.2.js:3094) at Array.<anonymous> (jquery-1.10.2.js:3203) at Function.each (jquery-1.10.2.js:657)

As an example:

screen shot 2017-04-20 at 8 25 05 am

Here is the data dump from pim_catalog_attribute_group

screen shot 2017-04-20 at 8 31 44 am

Thanks!

bug has-PR

Most helpful comment

Hello @adamrandazzo, this issue is fixed in the 1.7.5 released on Friday!
Thanks

All 9 comments

Changing the FETCH_LIMIT in the following file fixes the issue, but I don't want to create a pull request as I am not sure of other implications in the system. https://github.com/akeneo/pim-community-dev/blob/494b2c108427556e2818a3c2f18ede40b585c144/src/Akeneo/Component/StorageUtils/Repository/SearchableRepositoryInterface.php

Hi @adamrandazzo, thanks for this feedback, our support team will take a look at it and keep you updated :)

Hi.
We have the same issue.
The problem is at Pim\Bundle\EnrichBundle\Controller\Rest\AttributeGroupController:76.

if (empty($options)) {
    $options = $request->request->get(
        'options',
        [
            'limit' => SearchableRepositoryInterface::FETCH_LIMIT,
            'locale' => null,
        ]
    );
}

The javascript application asks for the attribute groups to this controller.
It expects to retrieve ALL attribute groups but the controller limits the result to 20 items if the 'limit' parameter is not set.

I think the javascript application should know the result is paginated and it should do several http calls to retrive all attribute groups.

Waiting for the fix of this bug I extended and replaced the AttributeGroupController applying a workaround.

<?php

namespace Idrolab\Bundle\BugfixBundle\Enrich\Controller\Rest;

use Symfony\Component\HttpFoundation\Request;
use Pim\Bundle\EnrichBundle\Controller\Rest\AttributeGroupController as BaseAttributeGroupController;

class AttributeGroupController extends BaseAttributeGroupController
{
    public function indexAction(Request $request)
    {
        // In this way I avoid it will set the default limit of 20 items because the js app expects all items
        $options = $request->request->get('options', [
            // 'limit' => SearchableRepositoryInterface::FETCH_LIMIT,
            'locale' => null,
        ]);
        $request->request->set('options', $options);        
        return parent::indexAction($request);
    }
}

I hope it could help.

Hello @adamrandazzo, thank you for your feedback.

I'm really interested on a pull request @danielsan80 but before I think the way we should fix it (from the frontend side or the backend side) should be discussed with @SamirBoulil.

Regards,

@mickaelandrieu Something remembers me i was already fixing it somewhere in PIM-6196 https://github.com/akeneo/pim-community-dev/pull/5957

This issue should be handled in the SLA PIM-6416. I had even created a PR to fix this, but @a2xchip had already fix it in another PR. I've closed mine.

@LaurentPetard, @a2xchip thanks for the explanations, I link the pull request to the issue then :)

I close this issue because linked PR was merged !
Please feel free to re-open it if this not fits your needs ;)

Regards !
Pierre

Hello @adamrandazzo, this issue is fixed in the 1.7.5 released on Friday!
Thanks

Was this page helpful?
0 / 5 - 0 ratings

Related issues

pardahlman picture pardahlman  ·  4Comments

oliverde8 picture oliverde8  ·  3Comments

wakqasahmed picture wakqasahmed  ·  4Comments

lpxavi picture lpxavi  ·  4Comments

a2xchip picture a2xchip  ·  5Comments