The class Magento\Indexer\Model\Indexer\State serves for keeping index state, and column updated is modified with this piece of code.
public function beforeSave()
{
$this->setUpdated(time());
return parent::beforeSave();
}
It will be triggered on (almost) every save() call. It happens in Magento\Indexer\Model\Indexer within reindexAll(), reindexRow(), reindexList() methods.
When $this->getState()->save()
is called from one of those three methods, then save() method from \Magento\Framework\Model\ResourceModel\Db\AbstractDb will be called:
public function save(\Magento\Framework\Model\AbstractModel $object)
{
...
try {
if (!$this->isModified($object)) {
$this->processNotModifiedSave($object);
$this->commit();
$object->setHasDataChanges(false);
return $this;
}
$object->validateBeforeSave();
$object->beforeSave();
...
What is "the issue" here?
Well, if you call $this->getState()->save()
(as it's done in reindexRow() and reindexList()), then because of if (!$this->isModified($object))
- beforeSave() will never be triggerred. It further means that new updated time will not be set.
In case you call full reindex from command line, it will execute reindexAll(). The difference here is that there is a piece of code which sets status STATUS_WORKING:
public function reindexAll()
{
if ($this->getState()->getStatus() != StateInterface::STATUS_WORKING) {
$state = $this->getState();
$state->setStatus(StateInterface::STATUS_WORKING);
$state->save();
...
Since here data is changed, then beforeSave() will be triggered, and new updated time will be set.
The real question at the end is:
Is it a bug or a feature?