Turn OpenCart headless #13788
Replies: 3 comments
-
@danielkerr The idea is interesting, in my E-commerce it was 100% Vue.js + API. I consider Twig more powerful and I find it interesting to be able to use PHP, variables already filled in or API via JS, so the best one is used in each case. A problem with JS + API is that it will expose all API calls, unlike Twig which may come with certain values already filled in by PHP, depending on the API it is important not to be publicly exposed. Another point, there may be an excess of Requests, if a page needs to call about 5 resources, there will be 5 requests, so there is a delay in reaching the server, processing and returning, even though it can be worked in a more asynchronous way, a A good example of this occurs in Checkout, as it needs to be as realtime as possible, but in this case it makes sense to use more APIs with JS. You also have to analyze the use of modules, you will lose a lot of modules, a lot of themes will not be compatible and other details. Now I believe it is important for Opencart to have a good API, whether using HTML/JS or PHP + Twig. In the example mentioned, it is perhaps more efficient to use a cache in Redis or another type of cache, I noticed that Opencart has a lot of the same SQL calls, on a page I believe there are more than 20 calls, most of which are resources such as currency, countries, settings etc., and all this data could come from a cache or assembled in such a way that a call already pulls all the data and can then be used from the global variables. A good use of direct HTML I consider for Blog/CMS and Information Pages, in which it is possible to generate static pages, perhaps converting Markdown to HTML. As for pages that require a lot of resources and modules, I believe the current PHP + Twig standard with HTML and JS being used as needed is more advantageous. A cool use perhaps for HTML/JS + API would be for applications, perhaps a simplified version of Opencart for Mobile, but I believe it would require a lot of work and could be something to be focused on perhaps more by Modules or freelancer. If your example is more for some locations, it might make sense for optimization, but I believe that the final HTML could be generated directly without needing json, similar to static CMS pages, already generating the final result, like a store that doesn't have a module on the product page you could maybe use. In general, I consider Opencart to have excellent performance, we had fantastic results on a giant website with thousands of orders, which was at its peak consuming 10-16 CPU cores and thus slowing down the store, after using index in the database, Redis cache In general, the Redis session began to consume less than 1 CPU in the server's load average for the same demands, so Opencart can handle high demand very well with small optimizations. |
Beta Was this translation helpful? Give feedback.
-
what are the advantages ? |
Beta Was this translation helpful? Give feedback.
-
@FelipoAntonoff everything u have pointed out i agee with. so many issues with some of the frameworks liek even sea4rch engines will have issue indexing. i can make it html headless sites by caching all the main pages. certainly moving all the json to there own areas pre rendend will speed up sites a lot. |
Beta Was this translation helpful? Give feedback.
-
I'm planning on turning opencart headless.
i think i can get the system to generate the main catalog pages into headless html pages.
I could add a folder called html and another called json then use htacess to redirect to those pages if match seo keyword path found.
so should generate:
html/category-1/product-1.html
and
html/category-1/sort-asc/page-1/product-1.html
and for json we use just generate files like json/country.json.
Beta Was this translation helpful? Give feedback.
All reactions