0

I updated price by raw sql queries.but its not reflecting in front end.but its reflecting admin side. If i refresh page cache then its reflecting in the front end.

Mage::app()->getCacheInstance()->cleanType($type);

and my code to update price:

 $query= "SELECT entity_type_id  FROM ".$this->getTable('eav_entity_type')." WHERE entity_type_code = 'catalog_product'";
        $entityTypeId = $this->getConnection()->fetchOne($query);
        $query= "SELECT attribute_id FROM ".$this->getTable('eav_attribute')." WHERE entity_type_id = '".$entityTypeId."' AND attribute_code = 'price'";
        $attributeId = $this->getConnection()->fetchOne($query);
        if(count($Data)){
            foreach($Data as $key=>$value){
                $query= "SELECT entity_id  FROM ".$this->getTable('catalog_product_entity')." WHERE sku = '".$key."'";
                $entityId = $this->getConnection()->fetchOne($query);
                 if($entityId)
                 $this->getConnection()->query("UPDATE ".$this->getTable('catalog_product_entity_decimal')." SET value='".$value."' WHERE attribute_id='".$attributeId."' AND entity_id='".$entityId."'");
            }
        }

1 Answer 1

3

Over the CLI you can do the following

cache:clean
cache:disable
cache:enable
cache:flush
cache:status

To flush a specific cache type - for example full_page - run the following from the magento root in your CLI:

php bin/magento cache:flush full_page

to flush all caches:

php bin/magento cache:flush

To see available types, do:

php bin/magento cache:status

To do it in the code, you need to use

use Magento\Framework\App\Cache\Manager;

public function __construct(
    Manager $cacheManager
) {
    parent::__construct($cacheManager);
}

and do:

$this->cacheManager->flush($cacheTypes);

Please see

/vendor/magento/module-backend/Console/Command/AbstractCacheTypeManageCommand.php

and

/vendor/magento/module-backend/Console/Command/CacheFlushCommand.php
2
  • i need in php script.it should not be manual. Feb 19, 2016 at 12:54
  • Ok, you should have mentioned that =). I've edited my answer.
    – tecjam
    Feb 19, 2016 at 13:01

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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