How to manage time zone with DST for opencart? - opencart

My store location is Chichester, West Sussex, current local time is 7:30 AM, which is +1h DST,
But my store time is 6:30,
How to solve this?...
I need any of these solutions, from OpenCart dashboard/source code modification,
or
from cPanel
Current Version is 3.0.2.0

Enter the required timezone for the webserver.
In system/startup.php find below code :
find :
if (!ini_get('date.timezone')) {
date_default_timezone_set('UTC');
}
replace :
if (!ini_get('date.timezone')) {
date_default_timezone_set('DST');
}

date_default_timezone_set('Europe/London')
Worked

Related

Delete only old keys from elasticache

We had a leak in code which resulted in few keys not getting deleted in redis elasticache. We noticed it only when the number became > 3 million. We have fixed code around it, however we need to fix the redis as well. Now we cant flush all as it will delete all the keys. We only want to delete keys, lets say older than 15 days. I found few commands online like however how can I iterate over 3 million records without getting the system stuck. Please help.
Thank you in advance.
object idletime
del record
Anyone looking for similar problem as mine, the below code worked for me. It's not very efficient but does the work for me.
Iterable<String> iter = redissonClient.getKeys().getKeysByPattern(patternNew, scanLimit);
delList = new ArrayList<>();
for (String key : iter) {
RBucket<String> bucket = redissonClient.getBucket(key);
idletime = bucket.getIdleTime();
if (idletime > idletimeout) {
delList.add(key);
}
}
if (!delList.isEmpty()) {
recordsDeleted += delList.size();
count = redissonClient.getKeys().deleteAsync(delList.stream().toArray(String[]::new));
}
}
You can configure the maxmemory and set an eviction policy which will delete the keys based on the policy once maxmemory is hit.
https://docs.aws.amazon.com/whitepapers/latest/database-caching-strategies-using-redis/evictions.html

Local time zones with headless chrome in a lambda layer

I'm running headless chrome in a lambda layer (https://github.com/alixaxel/chrome-aws-lambda).
Issue is, I am trying to call .toLocaleString("en-AU"), but everything comes out as UTC/GMT regardless. I have read that node didn't always ship with internationalization options. I'm assuming something along those lines is what is going on here.
Any suggestions for how to work around this?
You can use moment.js for better control over time and time formats in NodeJS Lambda
https://momentjs.com/timezone/
var newYork = moment.tz("2014-06-01 12:00", "America/New_York");
var losAngeles = newYork.clone().tz("America/Los_Angeles");
var london = newYork.clone().tz("Europe/London");
newYork.format(); // 2014-06-01T12:00:00-04:00
losAngeles.format(); // 2014-06-01T09:00:00-07:00
london.format(); // 2014-06-01T17:00:00+01:00
Check their announcement about it's future and complications, including internationalization
https://momentjs.com/docs/

MoovWeb: Redirect desktop user to desktop site if they try to visit m.site.com

Using MoovWeb for a large eCommerce client. They want to block desktop users from visiting the mobile site. So basically, if a user is using a desktop browser and tries to visit (m.site.com) they will be redirected to (site.com).
Must do this in Tritium (most likely near the top of main.ts), because by the time JS runs, we'd be loading the site twice (once in m. then once again in www.)
I'm hesitant to go the route of using Regex to check $user_agent, because if we don't match EVERY POSSIBLE mobile agent, and the user goes to m. on their unmatched phone, they will get an endless redirect (m. > www. > m. > www. > m. > ...). I know there are very detailed Regex strings for user agents, however as detailed as they are, the only way we would find out that some phone out there is no longer matched is through loss of sales, which is not an option.
Here was my original Tritium test attempt, which causes redirect for mobile users that don't use Android or iPhone:
match($host,/^m\./) {
match($user_agent) {
not(/(Android|iPhone)/) {
$newHost = $host
$newHost {
replace(/^m\./,"")
}
$redirect = "http://"+$newHost+$path
export("Location",$redirect)
}
}
}
Moovweb provides redirection both client side and server side out-of-the-box. It's recommended that you implement server-side redirection which has the least amount of roundtrips.
Here is the official documentation:
https://moovwebconfluence.atlassian.net/wiki/display/DD/Mobile+Redirection#MobileRedirection-Server-SideRedirection
Best,
Juan C.
match($host,/m./) {
$newHost = $host
$newHost {
replace(/m./,"www.")
}
$redirect = "http://"+$newHost+$path
export("Location",$redirect)
}
Try this. Hope this will work you as this worked for me.

Glass Models and Sitecore ItemCache issue

We are using Glass Mapper models with Sitecore 7.1 (MVC Renderings), we recently deployed this project to live environment, but our client noticed that performance is degrading over time, for example, after 8~12 hours, some pages start to take 20 seconds to load.
After contacting sitecore Support and sending CPU/Memory Dumps, The support team responded :
"Due to Glass Mapper often resolving item paths Sitecore needs to update records in ItemPaths cache ( where every update "locks" the cache ). As this seems to happen often the application would encounter the situation when a few threads will be waiting for a single thread to finish updating ItemPaths cache."
So, have you encountered such issue before? is there anything i need to do with our Glass models to prevent this?
"Glass.Mapper" version="3.0.11.23"
"Glass.Mapper.Sc" version="3.1.10.31"
Thanks
The issue was in our base class which contains "Full Path" property:
public virtual string FullPath { get; set; }
This means that each time item is loaded by glass it will hit the path cache, which was causing the slowness.
I have updated the property to be more like 'Lazy Loaded' property:
[Glass.Mapper.Sc.Configuration.Attributes.SitecoreIgnore()]
public string FullPath {
get
{
return FullPath();\\This method retrieve FullPath from item.Paths.FullPath
}
}
This fixed the issue.

Categories are not appearing when editing products

I am using Magento Enterprise and only the top level category is available to choose when I am editing a product. All the sub categories are active and appear in the navigation menu, but not when editing a product.
Does anyone know how to fix this?
Chris
With 2 installs we had this issue. The 3rd time was done by downloading Magento directly from the server using wget command and then extracting and installing. Then it worked. I think whoever installed it the previous 2 times downloaded it to their desktop and then ftpd it up to the server.
Agreed - I had this issue after FTPing the Mage files.
After a wipe and re-install using hosts' script the issue is sorted. Shouldn't be necessary...
A matching flaw appears to exists in 1.5.0.1 of Community Edition, in the CE version its a regression in the getSelectedCategoriesPathIds() method of Mage_Adminhtml_Block_Catalog_Product_Edit_Tab_Categories
Reverting to the 1.4.* code for this method appears to fix it, all credit to rrroulio for tracking down this one on the magento boards: http://www.magentocommerce.com/boards/viewreply/316838/
The old 1.4 code for this method is as follows:
public function getSelectedCategoriesPathIds($rootId = false)
{
$ids = array();
$collection = Mage::getModel('catalog/category')->getCollection()
->addFieldToFilter('entity_id', array('in'=>$this->getCategoryIds()));
foreach ($collection as $item) {
if ($rootId && !in_array($rootId, $item->getPathIds())) {
continue;
}
foreach ($item->getPathIds() as $id) {
if (!in_array($id, $ids)) {
$ids[] = $id;
}
}
}
return $ids;
}