Magento – Magento programmatically force all products to save

attributesmagento-1.9magento-communityproducts

I have a magento installation that has a layered navigation to which attributes show and allow you to filter by.

I have an issue with the attributes showing on the filter, they wont show unless I go into each product and re-save them after I have imported the attribute data via CSV.

I have re-indexed the data and flushed all cache but still cant get them to show.

I need to find a way to force all products to re-save programatically.

Does anyone know of a script I can run via SSH to do this at all? I have tried a few I have found online, but they dont seem to execute correctly.

Any help would be greatly appreciated.

Thanks in advance,

Best Answer

Untested but something like this:

<?php
require 'app/Mage.php';


Mage::app();

$collection = Mage::getModel('catalog/product')->getCollection();

foreach ($collection as $product) {
    echo 'saving product '.$product->getData('sku').PHP_EOL;
    $product->save();
    echo 'saved'.PHP_EOL;
}
Related Topic