2

I've a PHP script that import products from an external XML File using AWS Fast Simple Import, a magento extension.

Every X minutes it call the XML and check if the product is modified or is new, then it updates or create a new product.

The problem is when a product become unavailable. I've already set up the configuration of magento to NOT SHOW the unavailable products but every time the script goes the unavailable products appear on the catalog page.

So I tried to reindex manually the catalog_product_price and if I refresh the catalog page it works correctly.

But when I do it from PHP using this code:

$process = Mage::getModel('index/indexer')->getProcessByCode('catalog_product_price');
$process->reindexAll();

It doesn't work. I mean if I look at the latest index time it works but in the catalog view I still see the unavailable products.

  • First, that indexer deals with product price only. Second, by unavailable, do you mean disabled, out of stock or visibility hidden? – Prateek Aug 7 '15 at 14:18
  • I mean out of stock. I tried to use other indexer but the only one that works in my case is the price one.. I don't know why. – Luca Coppola Aug 10 '15 at 8:36
  • Try reindexEverything() instead of reindexAll() method call, that's what core system call when you trigger indexing from admin. reindexEverything() also calls reindexAll() at the end of execution, so I guess it will also perform some additional tasks. Reason behind this, "I'm still looking into that". – Prateek Aug 10 '15 at 16:07
  • tried reindexEverything and nothing happened.. it's really annoying this magento issue. – Luca Coppola Aug 12 '15 at 11:44
1

I'd the same problem and I change

$process->reindexAll();

for

$process->reindexEverything();

Here is my code

public function reindex($string = 'all')
{
    /** @var $indexer Mage_Index_Model_Indexer */
    $indexer = Mage::getModel('index/indexer');

    $processes = array();

    if ($string == 'all') {
        $processes = $indexer->getProcessesCollection();
    } else {
        $codes = explode(',', $string);
        foreach ($codes as $code) {
            $process = $indexer->getProcessByCode(trim($code));
            if ($process) {
                $processes[] = $process;
            }
        }
    }

    /** @var $process Mage_Index_Model_Process */
    foreach ($processes as $process) {

        $status = $process->getStatus();

        if (($status!=Mage_Index_Model_Process::STATUS_RUNNING) AND !($process->isLocked())){

            //$process->reindexAll();
            $process->reindexEverything();

        }

    }

}
  • Thanks Claudio, I'll try since I still haven't resolved the problem. – Luca Coppola Jan 27 '16 at 9:38

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.