Page 1 of 1
quick question about override files
Posted: Tue Nov 07, 2023 6:29 am
by Portman
Hi,
I want to make changes to the following files and save them as overridden files;
includes/system/segments/checkout/update_stock.php
includes/system/segments/checkout/check_stock.php
where would I save the updated files - I have tried a number of options and none of them seem to work, or can I not override these files? maybe it is a job for hooks.
Re: quick question about override files
Posted: Tue Nov 07, 2023 7:09 am
by heatherbell
Re: quick question about override files
Posted: Wed Nov 08, 2023 1:37 am
by Portman
thanks @heatherbell
So I have assumed from what you sent me that I really need to use hooks .. so I tried this instead of the modifications I made to;
includes/system/segments/checkout/update_stock.php
I am trying to set up a mod that allows me to count stock movements on some items only. I have added a switch to the products field that lets me choose if I count stock for each seperate product.
my original mod to update_stock.php was essentially a basic If statement that said...
IF the product stock needs to be counted then deduct sale from products_quantity - otherwise no deduction...
IF I make a hook that basically does the same thing then it does what the hook tells it to do, but it also runs through includes/system/segments/checkout/update_stock.php resulting in stock figures deducting twice for items that I want to count stock figures for (once from the hook and once from update_stock.php) and once for the items that I dont want to count (done in update_stock.php)...
Am I missing something? is there a way for me to essentially disable (or negate) includes/system/segments/checkout/update_stock.php from the hook?
Re: quick question about override files
Posted: Wed Nov 08, 2023 7:15 am
by Kofod95
Why not just add the stock back, for the items that doesn't need to be counted? Either that, or disable stock globaly in admin->configuration and only count stock with your new hook.
//Daniel
Re: quick question about override files
Posted: Fri Nov 10, 2023 11:21 pm
by Portman
thanks @Kofod95, for your lateral thinking, you are a genious!!
Re: quick question about override files
Posted: Mon Nov 13, 2023 9:12 am
by Denzel
I'll chime in here: Is it now possible to change admin/catalog/views/default.php without changing the code? I changed the order of the displayed articles (at that time in admin/categories.php) - i.e. the product query. Now I'm looking for a way to do this in catalog.php. Can this file be overwritten?
Regards,
Denzel
Re: quick question about override files
Posted: Mon Nov 13, 2023 10:27 am
by burt
Admin doesn't have override architecture. It might come in the future.
Some pages can be changed in the way you describe (ie, change the SQL to make the list of items display in a different way), these pages are where the list of items is powered by the paginated_table component. EG: admin/products_expected.php
UNfortunately, catalog.php is not powered by the paginated_table.
Making more use of the paginated_table is something I've been looking at for some future time and space.
Re: quick question about override files
Posted: Mon Nov 13, 2023 7:50 pm
by Denzel
Maybe something like this:
Code: Select all
if (isset($_GET['search'])) {
$products_query_raw = "SELECT p.*, pd.*, p2c.categories_id FROM products p, products_description pd, products_to_categories p2c WHERE p.products_id = pd.products_id AND pd.language_id = " . (int)$_SESSION['languages_id'] . " AND p.products_id = p2c.products_id AND ((pd.products_name LIKE '%" . $db->escape($search) . "%') || (p.products_model LIKE '%" . $db->escape($search) . "%') || (p.products_gtin LIKE '%" . $db->escape($search) . "%')) ORDER BY pd.products_name";
} else {
$products_query_raw = "SELECT p.*, pd.* FROM products p, products_description pd, products_to_categories p2c WHERE p.products_id = pd.products_id AND pd.language_id = " . (int)$_SESSION['languages_id'] . " AND p.products_id = p2c.products_id AND p2c.categories_id = " . (int)$current_category_id . " ORDER BY pd.products_name";
}
$GLOBALS['admin_hooks']->cat('catalog', $products_query_raw);
$products_query = $db->query($products_query_raw);
$products_count = mysqli_num_rows($products_query);
while ($products = $products_query->fetch_assoc()) {
would open up the possibility to add sortable filters

Re: quick question about override files
Posted: Tue Nov 14, 2023 10:40 am
by burt
Yes, you can add in hooks where-ever you need.