I have inserted 4000 products and now our client want the inverse order so how to reorder them programatically? any help please
- Create a controller's action or a custom PHP file, so that you can run your custom script to change the position.
- Get all products collection order by position in decremental order and store it as an array having product IDs and position.
- From the array above, you can easily find the biggest position and the smallest position. Now loop through the products array and assign the new positions (for this step, start from the smallest position value and every time a product is assigned the new value, add 1 to the get a new position)
For faster execution of your script, you can use updateAttribute() function as shown in How to update product eav attribute in magento 2 link.
Please let me know if anything is unclear.