Skip to content

Instantly share code, notes, and snippets.

@petarBozovic
Created January 14, 2019 15:57
Show Gist options
  • Save petarBozovic/1a422cdc1e555721224215213e69f0e3 to your computer and use it in GitHub Desktop.
Save petarBozovic/1a422cdc1e555721224215213e69f0e3 to your computer and use it in GitHub Desktop.
Resave All Products (Magento1.9.x)
<?php
ini_set('memory_limit', '8192M');
require 'app/Mage.php';
Mage::app();
Mage::app()->setCurrentStore(Mage_Core_Model_App::ADMIN_STORE_ID);
$products = Mage::getResourceModel('catalog/product_collection')->addAttributeToSelect('*');
//->addAttributeToFilter('sku','testskuhere');
foreach ($products as $product) {
if ($product->getModshopVisibility() && !$product->isConfigurable()) {
echo 'Product: ' . $product->getId() . ' - ' . $product->getName() . "\xA";
if (Mage::app()->isSingleStoreMode()) {
$product->setWebsiteIds(array(Mage::app()->getStore(true)->getWebsite()->getId()));
}
$product->save();
}
else echo 'Skip ' . $product->getId() . "\xA";
}
?>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment