How to Contribute Code back to the OpenCart Project?
Posted: Tue Apr 03, 2012 11:53 am
Hi there,
We're using OpenCart for a whole range of client stores, and we're very happy with the way it's been going.
However there's quite a few places in the code where I'd really like the opportunity to clean things up, make everything more robust and flexible. The actual structure of the code is very clean and well laid out, however some of the content of the various functions is very difficult to follow and work with (especially the SQL, which doesn't seem to follow any particular coding standards). There's also quite a few needless queries which can easily be optimized and condensed down. The database structure itself I have no problem with, it's definitely one of the best I've used.
What would be involved in contributing these various changes back to the project? I'm not talking about adding any functionality, that's something I'd continue to do via vQMod. Part of my job as a PHP/MySQL developer involves rewriting code to keep things optimized and efficient, when you're running stores with 15,000+ products you can't afford to have slow SQL queries or duplicate code cluttering things up. We're quite serious about sticking with OpenCart and would love to share our work back with the project directly (leaving the main developers free to work on more interesting things like building new features!).
If you'd like, please send me a random filename from OpenCart and I'll be happy to rewrite it and show you what I'm talking about (with comments to explain what I'm trying to achieve at each stage).
File: /catalog/controller/product/all.php
Before:
After:
We're using OpenCart for a whole range of client stores, and we're very happy with the way it's been going.
However there's quite a few places in the code where I'd really like the opportunity to clean things up, make everything more robust and flexible. The actual structure of the code is very clean and well laid out, however some of the content of the various functions is very difficult to follow and work with (especially the SQL, which doesn't seem to follow any particular coding standards). There's also quite a few needless queries which can easily be optimized and condensed down. The database structure itself I have no problem with, it's definitely one of the best I've used.
What would be involved in contributing these various changes back to the project? I'm not talking about adding any functionality, that's something I'd continue to do via vQMod. Part of my job as a PHP/MySQL developer involves rewriting code to keep things optimized and efficient, when you're running stores with 15,000+ products you can't afford to have slow SQL queries or duplicate code cluttering things up. We're quite serious about sticking with OpenCart and would love to share our work back with the project directly (leaving the main developers free to work on more interesting things like building new features!).
If you'd like, please send me a random filename from OpenCart and I'll be happy to rewrite it and show you what I'm talking about (with comments to explain what I'm trying to achieve at each stage).

File: /catalog/controller/product/all.php
Before:
Code: Select all
<?php
if (isset($this->request->get['sort'])) {
$sort = $this->request->get['sort'];
} else {
$sort = 'pd.name';
}
if (isset($this->request->get['order'])) {
$order = $this->request->get['order'];
} else {
$order = 'ASC';
}
if (isset($this->request->get['page'])) {
$page = $this->request->get['page'];
} else {
$page = 1;
}
if (isset($this->request->get['limit'])) {
$limit = $this->request->get['limit'];
} else {
$limit = $this->config->get('config_catalog_limit');
}
?>
Code: Select all
<?php
$sort = isset($this->request->get['sort']) ? $this->request->get['sort'] : 'pd.name';
$order = isset($this->request->get['order']) ? $this->request->get['order'] : 'ASC';
$page = isset($this->request->get['page']) ? $this->request->get['page'] : 1;
$limit = isset($this->request->get['limit']) ? $this->request->get['limit'] : $this->config->get('config_catalog_limit');
?>