Skip to content
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

Only 2 related products are showing in backend . #13720

Closed
dipind4u opened this issue Feb 19, 2018 · 19 comments · Fixed by #18207
Closed

Only 2 related products are showing in backend . #13720

dipind4u opened this issue Feb 19, 2018 · 19 comments · Fixed by #18207
Assignees
Labels
Component: Catalog Fixed in 2.2.x The issue has been fixed in 2.2 release line Fixed in 2.3.x The issue has been fixed in 2.3 release line Issue: Clear Description Gate 2 Passed. Manual verification of the issue description passed Issue: Confirmed Gate 3 Passed. Manual verification of the issue completed. Issue is confirmed Issue: Format is valid Gate 1 Passed. Automatic verification of issue format passed Issue: Ready for Work Gate 4. Acknowledged. Issue is added to backlog and ready for development Progress: PR Created Indicates that Pull Request has been created to fix issue Reproduced on 2.2.x The issue has been reproduced on latest 2.2 release Reproduced on 2.3.x The issue has been reproduced on latest 2.3 release

Comments

@dipind4u
Copy link

Preconditions

  1. Magento 2.2.2
  2. PHP 7.0.20
  3. MySQL version: 10.1.30-MariaDB

Steps to reproduce

  1. Update products related products using csv and update via magento default import.
  2. Flush the cache storage and reindexing .
  3. Check the frontend and backend

Expected result

  1. Updated related products should come in the frontend of product page and backend of product edit page

Actual result

  1. The update related products are showing in the frontend .But only 2 related products are showing in the backend
@magento-engcom-team magento-engcom-team added the Issue: Format is valid Gate 1 Passed. Automatic verification of issue format passed label Feb 19, 2018
@magento-engcom-team
Copy link
Contributor

Hello @dipind4u. Thanks for reporting. Probably we've missed something but currently we are not able to reproduce Your issue. Here is what we did in order to get it reproduced.
We had 16 products called S1, S2,...,S16. Then we related to some of them three others to each as follows:
S1 - related S16, S15, S14
S2 - related S15, S14, S13
S5 - related S12, S11, S10.
Then exported these products to CSV.
Then in CSV file we changed the names of S10-S16 to S10name-S16name relatively. So we updated a bit those products.
Then re-imported them. As a result all the products in both areas were correctly displayed.
So please tell us where we have misunderstand You.

@dipind4u
Copy link
Author

I will explain the issue with example .
Suppose i have 100 products named s1,s2,s3,s4 ...s100 .
I have to add related products to all of these products .For example ,s1's related products are s2,s3,s4,s5,s6 and s2's related products are s1,s3,s4,s5,s6 .For bulk update i am using default import option .If i am updating the related products using csv ,then only 2 related products will be shown in the backend (product edit page)and all 5 products will display in front end(product detail view page) .

@magento-engcom-team
Copy link
Contributor

Ok @dipind4u, We have recorded three videos where we were trying to reproduce Your issue. Sorry for its bad quality, but we hope You won't miss the essential things in it. As You will see we are still not able to reproduce Your issue. So please after You have watched the videos tell us what we do incorrectly not as You mean or what we've missed. Thank You.

Video1.zip
Video2.zip
Video3.zip

@magento-engcom-team
Copy link
Contributor

@dipind4u, we are closing this issue due to inactivity. If you'd like to update it, please reopen the issue.

@KrzysztofMoskalik
Copy link

KrzysztofMoskalik commented Apr 11, 2018

I have the same issue: only 2 related products are shown in admin. Below steps to reproduce:

  • add 4 products: P1 and 3 products related to P1: R1, R2, R3
  • in import file change "related_position" value to all 3 products (R1, R2, R3) to equal value (eg. 0)
  • make an import

After that only 2 products related to P1 will be shown in admin (in frontend everything is ok).
Bug is in class Magento\Catalog\Model\ProductLink\CollectionProvider on method getCollection

foreach ($output as $item) { $itemPosition = $item['position']; if (!isset($sorterItems[$itemPosition])) { $sorterItems[$itemPosition] = $item; } else { $newPosition = $itemPosition + 1; $sorterItems[$newPosition] = $item; } }

@magento-engcom-team Could you reopen this issue?

@gulshan-streammarket
Copy link

I have the same issue. I have migrated the data from M1 to M2.
@KrzysztofMoskalik is right. The problem is +1 that overrides value in the array $sorterItems.
Let me explain with example
P1 R1 0
P1 R2 1
P1 R3 1
P1 R4 2
P1 R5 2
Where P1 is main product R1-R5 is related product and numbers in last column is sort position.
And i am missing related product R4 in magento admin. By the logic in the code shown by @KrzysztofMoskalik $sorterItems array will look like at the end [0 => R1, 1=> R2, 2=> R3, 3=> R5]

@magento-engcom-team please reopen this issue.

@hostep hostep reopened this Apr 24, 2018
@hostep
Copy link
Contributor

hostep commented Apr 24, 2018

@magento-engcom-team: I've reopened the issue, since there is an update and some good information pointing towards the cause of this bug (I've seen this thing happen myself, but hadn't had the change yet to look into the problem, so thanks to @KrzysztofMoskalik & @gulshan-streammarket for the extra info!)

@robbertstevens
Copy link

robbertstevens commented May 16, 2018

I fixed this by doing this in the function @KrzysztofMoskalik said:

foreach ($output as $item) {
            $itemPosition = (int)$item['position'];
            while(true) {
                if (!isset($sorterItems[$itemPosition])) {
                    break;
                }
                $itemPosition += 1;
            }
            $sorterItems[$itemPosition] = $item;
        }

@hostep @gulshan-streammarket @dipind4u

@n0kit31
Copy link

n0kit31 commented Aug 27, 2018

What is the current status of this issue? Will it ever be merged into core?

@hostep
Copy link
Contributor

hostep commented Aug 27, 2018

I believe #15251 should be re-opened and re-evaluated because it was closed for an incorrect reason.

hostep added a commit to hostep/magento2 that referenced this issue Sep 1, 2018
…in the backend grids and in the correct order. Fixes magento#13720
@ghost ghost self-assigned this Sep 4, 2018
@ghost
Copy link

ghost commented Sep 4, 2018

@dipind4u, thank you for your report.
We've acknowledged the issue and added to our backlog.

@ghost ghost added Issue: Ready for Work Gate 4. Acknowledged. Issue is added to backlog and ready for development Component: Catalog Issue: Clear Description Gate 2 Passed. Manual verification of the issue description passed Issue: Confirmed Gate 3 Passed. Manual verification of the issue completed. Issue is confirmed labels Sep 4, 2018
@ghost ghost added Reproduced on 2.2.x The issue has been reproduced on latest 2.2 release Reproduced on 2.3.x The issue has been reproduced on latest 2.3 release labels Sep 4, 2018
@ghost ghost removed their assignment Sep 4, 2018
@AndrewPenry
Copy link

I think the problem here is that the import behavior will only add related skus, never remove them.

Let's start with 2 related skus already in the database:

SKU Position
OLD-1 1
OLD-2 2

If I upload this:

sku,related_skus,related_position
MYSKU,"NEW-1,NEW-2","1,2" 

I expect that the new skus would overwrite the old skus in their positions, like:

SKU Position
NEW-1 1
NEW-2 2

Instead it will only add skus to the list and trigger this bug, like:

SKU Position
OLD-1 1
OLD-2 2
NEW-1 1
NEW-2 2

Likewise, if I upload:

sku,related_skus,related_position
MYSKU,"","1,2" 

I'd expect the empty field to cause Magento to remove the related skus at positions 1 and 2. Instead, this simply does nothing.

@sidolov
Copy link
Contributor

sidolov commented Sep 22, 2018

Hi @dipind4u. Thank you for your report.
The issue has been fixed in #17885 by @hostep in 2.2-develop branch
Related commit(s):

The fix will be available with the upcoming 2.2.8 release.

@sidolov sidolov added the Fixed in 2.2.x The issue has been fixed in 2.2 release line label Sep 22, 2018
@sidolov sidolov closed this as completed Sep 22, 2018
hostep added a commit to hostep/magento2 that referenced this issue Sep 23, 2018
…ells) show up in the backend grids and in the correct order. Fixes magento#13720

(cherry picked from commit a3f1c38)
@sidolov
Copy link
Contributor

sidolov commented Sep 26, 2018

Hi @dipind4u. Thank you for your report.
The issue has been fixed in #18207 by @hostep in 2.3-develop branch
Related commit(s):

The fix will be available with the upcoming 2.3.1 release.

@sidolov sidolov added the Fixed in 2.3.x The issue has been fixed in 2.3 release line label Sep 26, 2018
@ameshca
Copy link

ameshca commented Nov 2, 2018

After i have added this fix in my Magento2.2.6 version all the related products are showing, but i cannot properly sort the related products from backend. Unable to move the position of related products.

@hostep
Copy link
Contributor

hostep commented Nov 21, 2018

@ameshca: indeed, you are correct, if some positions of those linked products in the database are non-unique you might have problems dragging the products in the grid correctly. But what can help is just randomly dragging multiple products in all kind of positions in the grid, until the grid has generated enough unique sorting positions that it starts working properly again. Which is a bit tedious to do, but it seems to work when I'm quickly trying this.

Or you can try to update the positions directly in your database so they are unique per linked product (but make sure you test this first on a local/staging environment and don't do this directly on production without proper testing).

@ameshca
Copy link

ameshca commented Nov 26, 2018

@ameshca: indeed, you are correct, if some positions of those linked products in the database are non-unique you might have problems dragging the products in the grid correctly. But what can help is just randomly dragging multiple products in all kind of positions in the grid, until the grid has generated enough unique sorting positions that it starts working properly again. Which is a bit tedious to do, but it seems to work when I'm quickly trying this.

Or you can try to update the positions directly in your database so they are unique per linked product (but make sure you test this first on a local/staging environment and don't do this directly on production without proper testing).

Yes, your are correct. I have updated the positions directly from database and now its working fine. Thanks @hostep

@ChintanKaneriya
Copy link

I fixed this by doing this in the function @KrzysztofMoskalik said:

foreach ($output as $item) {
            $itemPosition = (int)$item['position'];
            while(true) {
                if (!isset($sorterItems[$itemPosition])) {
                    break;
                }
                $itemPosition += 1;
            }
            $sorterItems[$itemPosition] = $item;
        }

@hostep @gulshan-streammarket @dipind4u

@robbertstevens Is this solution is safe to implement? Will it effect other data in admin?

@robbertstevens
Copy link

@ChintanKaneriya havent noticed any side effects

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Component: Catalog Fixed in 2.2.x The issue has been fixed in 2.2 release line Fixed in 2.3.x The issue has been fixed in 2.3 release line Issue: Clear Description Gate 2 Passed. Manual verification of the issue description passed Issue: Confirmed Gate 3 Passed. Manual verification of the issue completed. Issue is confirmed Issue: Format is valid Gate 1 Passed. Automatic verification of issue format passed Issue: Ready for Work Gate 4. Acknowledged. Issue is added to backlog and ready for development Progress: PR Created Indicates that Pull Request has been created to fix issue Reproduced on 2.2.x The issue has been reproduced on latest 2.2 release Reproduced on 2.3.x The issue has been reproduced on latest 2.3 release
Projects
None yet
Development

Successfully merging a pull request may close this issue.