Page 1 of 1

Override admin file?

Posted: Tue Jul 14, 2026 2:14 am
by Blaine
Is it possible to override the admin/includes/actions/catalog/update_product.php file? If so, where do I put that override file?

I have a lot of custom fields in my products tables. These are all placed on the edit product page with hooks but the only way I have been able to get changes saved to the db is by editing this core file.

Re: Override admin file?

Posted: Tue Jul 14, 2026 6:46 am
by raiwa
You can do it changing the action name to the name of your overridden action like explained in my post for a overridden view action:
https://phoenixcart.org/forum/viewtopic ... 654#p23654

But you do not need to override the complete core action and its better not to do it. Like this, if the core action is updated, you do not have to care to apply the update to your overridden action.

There are hook listeners for the update and insert actions and you can place the functions in the same admin catalog hook you already have.
Here an example:

Code: Select all

    function listen_productActionSave() {
        global $db;

        if (isset($_POST['product_id']) && isset($_POST['myinput'])) {

            $products_id = Text::input($_POST['product_id']);

            $sql_data_array = [
                'myinput' => (int)Text::input($_POST['myinput']),
            ];

            $db->perform('products', $sql_data_array, 'update', "products_id = '" . (int)$products_id . "'");
        }
    }

    public function listen_updateProductAction() {
        $this->listen_productActionSave();
    }

    public function listen_insertProductAction() {
        $this->listen_productActionSave();
    }