Catalog Price Rule Magento Hilang di Tengah Malam

Kami bingung oleh masalah yang dihadapi oleh salah satu situs Magento klien kami.
Masalahnya adalah Catalog Price Rule selalu “mengatur ulang otomatis” setelah tengah malam.

Kredit untuk solusi jenius ini diposting di Stackoverflow dan Alexei Yerofeyev.

“Ya, ini adalah bug di Magento (atau logika di luar pemahaman saya). Ketika Magento menampilkan produk di frontend, ia memeriksa apakah ada catalog price rule untuk tanggal ini. Dan tanggal yang digunakan untuk pemeriksaan ini adalah GMT lokasi Anda, jadi di case GMT + 5. Namun, ketika catalog price rule sedang diterapkan, ia menggunakan tanggal GMT. Artinya bahwa Anda tidak dapat menerapkan catalog price rule sampai jam 5 pagi.

Masalahnya ada difungsi Mage_CatalogRule_Model_Action_Index_Refresh::execute() . Anda harus menulis ulang fungsi / kelas ini di ekstensi Anda, atau melalui versi local file. “

Cara Mengatasinya

Ganti kode pada baris 121 di : app/code/core/Mage/CatalogRule/Model/Action/Index/Refresh.php

(Tentu saja, mengikuti praktik terbaik Magento, Anda tidak boleh memodifikasi file core itu sendiri; tetapi salin file Refresh.php dari core , buat ulang struktur folder yang sama di local: app/local/Mage/CatalogRule/Model/Action/Index/Refresh.php)

$timestamp = $coreDate->gmtTimestamp('Today');

ganti dengan ini:

$timestamp = Mage::app()->getLocale()->date(null, null, null, true)->get(Zend_Date::TIMESTAMP);

Setelah melakukan perbaikan, catalog price rules harus berfungsi sebagaimana mestinya.



 

Magento Catalog Price Rule Dissapears at Midnight

We were baffled by the problem encountered by one of our client’s Magento site.
The problem was a Catalog Price Rule keeps “resetting itself off” after midnight.

Credits for this solution posted in Stackoverflow and Alexei Yerofeyev for the genius solution.

“Yes, this is a bug in Magento (or some logic beyond my understanding). When Magento displays products on frontend, it checks if there are catalog rules for this date. And the date used for this check is your local, so in your case GMT+5. However, when catalog rules are being applied, it uses GMT date. So that means that you aren’t able to apply rules until 5 AM.

The problem is in Mage_CatalogRule_Model_Action_Index_Refresh::execute() function. You will have to rewrite this function/class either in your extension, or via the local version of the file.”

The Fix

You have to replace line 121 here: app/code/core/Mage/CatalogRule/Model/Action/Index/Refresh.php

(Of course, following Magento’s best practice, you should not modify the core files itself; but copy Refresh.php file from the core, recreate same folder structures in local: app/local/Mage/CatalogRule/Model/Action/Index/Refresh.php)

$timestamp = $coreDate->gmtTimestamp('Today');

with this:

$timestamp = Mage::app()->getLocale()->date(null, null, null, true)->get(Zend_Date::TIMESTAMP);

After this fix, the catalog price rules should work as it should be.