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

Potential issue: Wrong approach to default category position #281

Open
barbazul opened this issue Feb 2, 2016 · 9 comments · May be fixed by #384
Open

Potential issue: Wrong approach to default category position #281

barbazul opened this issue Feb 2, 2016 · 9 comments · May be fixed by #384

Comments

@barbazul
Copy link
Contributor

barbazul commented Feb 2, 2016

In https://github.com/avstudnitz/AvS_FastSimpleImport/blob/master/src/app/code/community/AvS/FastSimpleImport/Model/Import/Entity/Category.php#L477 you are setting the category position to 10000 when it is not specified.

I am currently tracking an issue that apparently relates to this.

The symptoms are, after an import whenever I rearrange a category within its parent the new position gets set to 10001, sending it to the bottom.

Afterwards whenever I rearrange another category in the same parent, the first category gets reverted back to 10000 and the new category gets assigned to 10001.

This is because of the logic inside Mage_Catalog_Model_Resource_Category::_processPositions

I am unsure about how best to approach this issue. Suggestions?

@barbazul
Copy link
Contributor Author

barbazul commented Feb 3, 2016

We have successfully confirmed this issue for different scenarios (changing parent, rearranging within the same parent and deleting categories with siblings).

I am still not sure what the bes approach would be. Perhaps preload the max(position) for each parent_id and then autoincrement it for each child that gets added?

@paales
Copy link
Collaborator

paales commented Feb 7, 2016

@barbazul Your suggested solution might solve the issue. Please create a PR to solve the issue :) You can create the PR on the develop branch.

@mbijnsdorp
Copy link

I ran into this as well and started thinking about preloading the max position. However that might prove difficult as you'd have to recalculate it if a category is moved to a new parent during the import.
Why is the position set to 10000 in the first place? If I remove that part, the category is imported just fine at position 0.

@barbazul
Copy link
Contributor Author

@mbijnsdorp I am not sure about leaving it at 0 would fix the issue. I think trouble beings when more than one category has a repeated position value, be it 0, 100000 or any other.

@paales I have some spare time right now, I'll work on a PR and try to commit later tonight

@barbazul barbazul linked a pull request Jun 7, 2017 that will close this issue
@barbazul
Copy link
Contributor Author

I created a new PR request with a more up to date version of @mbijnsdorp solution.

Please consider it for merging as this issue has been open for over a year now

@barbazul
Copy link
Contributor Author

I would love to have some feedback on this issue as I find myself with some spare time to work some more on this if needed

@barbazul
Copy link
Contributor Author

barbazul commented Jul 5, 2017

Should I change the PR base branch to develop?

@barbazul
Copy link
Contributor Author

barbazul commented Nov 8, 2017

@paales

@barbazul
Copy link
Contributor Author

@avstudnitz

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants