1

So if you sort with best value it uses the products position attribute in the category to decide the position.

The lower the higher it appears on the catalog page and search page.

We have a custom sold-out attribute that on some products is yes.

On those products we would like the position to be 9999 for all categories it belongs to.

Is there a way to change it on a per product level or do you have to change it on each category?

If there is a programmatic way that would also be the next best prize.

3
  • 2
    You can take a look at this question and answer. It's kind of similar. When sorting by position, actually sort by some other attribute first and then by position. Maybe you can adapt it to fit your needs.
    – Marius
    Aug 31, 2016 at 15:03
  • Which Magento version are you using ? Aug 31, 2016 at 15:06
  • I am using Magento 1.9
    – tread
    Sep 1, 2016 at 6:41

1 Answer 1

1

My answer is assuming you're using Magento 1, let me know if you're on Magento 2

The positions are stored directly in the catalog_category_product table.

My suggestions would be to get the list of product ids that need to be updated with a code like this:

$collection = Mage::getResourceModel('catalog/product_collection')
         ->addAttributeToFilter('sold-out','yes');

foreach ($collection as $product) {
    echo $product->getProductId() . ",";
}

Once you got that list you can run a SQL query directly on your database that will look like this:

UPDATE catalog_category_product SET position = 9999 WHERE product_id IN (1,2,3)

1, 2 and 3 are for the example, just replace them with the list of product id you got from the code I pasted and separate them with commas.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.