Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Cached image is not updated if the base file is replaced directly (without product save) #23

Open
alexkuk opened this issue May 21, 2015 · 2 comments

Comments

@alexkuk
Copy link

alexkuk commented May 21, 2015

I faced with this problem and I have a solution for it. Could you please review it and consider including it into the module?

The solution is to add an to override Mage_Catalog_Model_Product_Image::isCached() method in Netzarbeiter_NicerImageNames_Model_Image:

    public function isCached()
    {
        if (Mage::getStoreConfig("catalog/nicerimagenames/disable_ext")) {
            return parent::isCached();
        }

        if (!$this->_fileExists($this->_newFile)) {
            return false;
        }

        if (!file_exists($this->_baseFile)) {
            return true;
        }

        if (filemtime($this->_newFile) < filemtime($this->_baseFile)) {
            Mage::dispatchEvent('nicerimagenames_regenerate_image', array(
                'url' => $this->getUrl()
            ));
            return false;
        }

        return true;
    }

It checks the base file change time, and if cached file is older - we regenerate a cached file

@Vinai
Copy link
Owner

Vinai commented May 21, 2015

Hey, thanks for the idea. I'm very open to include the code in the extension. Can you please open a pull request? Would you be willing to includ the event observer, too?
One note: what do you think, maybe it would be better to name the event in a way that states the condition which just occured - maybe nicerimagenames_new_file_available or the like - since event names generally should not be in "command" form, but rather state things that happened.

alexkuk pushed a commit to alexkuk/nicer-image-names that referenced this issue May 22, 2015
… method in Netzarbeiter_NicerImageNames_Model_Image. It checks the base file change time, and if cached file is older - we regenerate a cached file
Vinai added a commit that referenced this issue May 22, 2015
Issue #23: override Mage_Catalog_Model_Product_Image::isCached() meth…
@Vinai
Copy link
Owner

Vinai commented Aug 5, 2016

Should be fixed by #34
Please validate

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants