Why I Stopped Trusting the OkayCMS Built-in Import for Price Updates
It was a Tuesday morning, 9:14 AM, when my phone started vibrating itself off the desk. It was Andrey, a client running a busy home appliances store on OkayCMS. His site was crawling. Pages were taking twelve seconds to load, and checkout attempts were timing out. Customers were abandoning their carts, and Andrey was losing real money by the minute.
The culprit? A cron job we had set up to run the native OkayCMS CSV import script. It was processing a fresh supplier feed of 18,400 items to update prices and stock levels. On paper, it should have worked. In reality, it was eating 100% of the server's CPU and locking the database tables.
That was the day I realized that relying on the built-in import tools for high-frequency automated updates is a trap. I had to rebuild the entire integration from scratch. Here is what I learned from that bottleneck, and how we solve it now.
The Illusion of the OkayCMS Demo
When you first play around with an okaycms demo, everything feels incredibly fast. You upload a CSV with fifty products, click import, and it finishes in three seconds. It looks perfect. But a clean demo environment with a handful of test products is a world away from a live production store with thousands of real SKUs, active visitors, and concurrent database queries.
The native import script in OkayCMS is designed for human administrators doing occasional manual updates. It does a lot of heavy lifting behind the scenes. For every single row in your CSV, the system fires up PHP, validates the data, checks category trees, processes images, recalculates currencies, and clears the Smarty template cache.
This overhead is fine for a weekly manual upload of a hundred new arrivals. It is fatal when you need to update prices and stock balances every single hour to match your suppliers. If you try to run this heavy PHP routine via cron, your server memory leaks, execution limits kick in, and your database tables lock up. While the script is struggling to process row 8,000, your real customers cannot even load the homepage.
Why the API Isn’t Always the Answer
Naturally, my first instinct after the Tuesday crash was to look at the okaycms api. APIs are supposed to be the clean, modern way to handle integrations. But we quickly hit another wall.
The standard API is great for pulling order data or updating a single product on the fly. However, updating 15,000 stock levels over HTTP requests is incredibly chatty. Making thousands of individual API calls takes a massive amount of network overhead. Even if you batch them, you are still forcing the CMS to boot up its entire application framework for every batch. It is simply too slow for high-frequency bulk updates. We needed a solution that bypassed the application layer entirely when dealing with raw data writes, without breaking the integrity of the store.
The Solution: Transaction-Safe SQL Updates
To fix Andrey’s store, we stopped trying to force OkayCMS to read files through its admin controllers. Instead, we moved the heavy lifting directly to the MySQL database, wrapping the entire process in a secure, transaction-safe routine.
Here is the architecture we built, which we now use for all our clients:
First, we upload the raw supplier CSV or XML to a secure staging directory. A lightweight background script parses the file and writes the raw data into a temporary staging table in the database. This step is incredibly fast because it is just raw data ingestion—no PHP application logic is running yet.
Second, we execute a direct SQL `UPDATE` join between our staging table and the live `s_variants` table. This is where the magic happens. MySQL can update 20,000 rows in less than half a second. By skipping the PHP ORM and updating the database directly, we avoid memory leaks and keep CPU usage close to zero.
But direct database writes are dangerous if you don't have guardrails. If your supplier’s feed suddenly glitches and sets all prices to zero, a direct SQL update will happily ruin your live store in a millisecond. That is why we built in a strict verification step.
Before we commit the transaction, our script runs a sanity check. It verifies that the updated prices are within a reasonable range (for example, no price can drop by more than 50% in a single update) and that the total count of updated items matches our expectations. If the checks pass, we commit the transaction. If something looks wrong, we trigger a rollback, keep the old data live, and send an alert. The site never goes down, and customers never see broken prices.
Keep Your Store Fast and Safe
If your e-commerce store is growing, you cannot afford to let background updates ruin your frontend performance. Every second of slowdown costs you sales. Stop relying on heavy admin-panel imports for your automated crons, and stop overloading your server with slow API loops.
If you are tired of database locks, slow loading times, and broken price updates on your store, we can help. At GuardLabs, we build custom, rock-solid sync engines that keep your data fresh without putting any load on your server. Learn more about our service and get your automation set up properly: Автообновление цен и остатков в OkayCMS.