Overriding catalog actions in v1.0.8.1 and later

Open to all! Ask other shopowners for help.
Post Reply
User avatar
edfaught
Member
Posts: 49
Joined: Mon Oct 26, 2020 3:22 pm
Phoenix Version:
Has thanked: 4 times
Been thanked: 2 times

Overriding catalog actions in v1.0.8.1 and later

Post by edfaught »

When updating from 8.0.1.0 I somehow lost my override functionality at /includes/system/override/actions/os_c__actions_add_product.php.
I would guess wildly that it has something to do with the name changes?


Join The Code Co-op to get access to your library in the Code Co-op Forum
ecartz
Core Team
Posts: 3084
Joined: Tue Nov 05, 2019 6:02 pm
Phoenix Version:
Has thanked: 4 times
Been thanked: 208 times

Re: Overriding catalog actions in v1.0.8.1 and later

Post by ecartz »

Try

Code: Select all

class hook_shop_system__22_actions {

  public function listen_startApplication() {
    $GLOBALS['class_index']->find_all_actions_under(DIR_FS_CATALOG . 'includes/system/override/actions');
  }

}
(doubled underscore is intentional) saved in includes/hooks/shop/system/_22_actions.php, rename the override files to something like add_product.php, and update the action file as done in https://github.com/CE-PhoenixCart/Phoen ... e018a5b558

At least one of Rainer's add-ons does this correctly. QTPro maybe?
User avatar
edfaught
Member
Posts: 49
Joined: Mon Oct 26, 2020 3:22 pm
Phoenix Version:
Has thanked: 4 times
Been thanked: 2 times

Re: Overriding catalog actions in v1.0.8.1 and later

Post by edfaught »

PHP Fatal error: Uncaught Error: Call to a member function find_all_actions_under() on null in \includes\hooks\shop\system\_22_actions.php:28
Stack trace:
#0 \includes\system\versioned\1.0.8.1\hooks.php(160): hook_shop_system__22_actions-
>listen_startApplication(Array)
#1 \includes\application_top.php(34): hooks->generate('startApplicatio...')
#2 \index.php(13): require('C:\\Users\\Ed_2\\M...')
#3 {main}
thrown in \includes\hooks\shop\system\_22_actions.php on line 28

I searched for this function and found it named tep_find_all_actions_under() in autoloader.php but renaming it here didn't fix the problem. I'm not even sure what the issue is...
ecartz
Core Team
Posts: 3084
Joined: Tue Nov 05, 2019 6:02 pm
Phoenix Version:
Has thanked: 4 times
Been thanked: 208 times

Re: Overriding catalog actions in v1.0.8.1 and later

Post by ecartz »

It says $class_index doesn't exist. You might have to update more. It looks like class_index was v1.0.8.3: https://github.com/CE-PhoenixCart/Phoen ... cf9d8b29dc
User avatar
edfaught
Member
Posts: 49
Joined: Mon Oct 26, 2020 3:22 pm
Phoenix Version:
Has thanked: 4 times
Been thanked: 2 times

Re: Overriding catalog actions in v1.0.8.1 and later

Post by edfaught »

My editor (Netbeans) shows this as syntax error also.

PHP Parse error: syntax error, unexpected '\' (T_NS_SEPARATOR), expecting function (T_FUNCTION) or const (T_CONST) in \includes\system\override\actions\add_product.php on line 59

Code: Select all

    \Href::redirect(\Guarantor::ensure_global('Linker')
                    ->build($GLOBALS['goto'])
                    ->retain_parameters($GLOBALS['parameters']));
Phoenix 1.0.8.4
ecartz
Core Team
Posts: 3084
Joined: Tue Nov 05, 2019 6:02 pm
Phoenix Version:
Has thanked: 4 times
Been thanked: 208 times

Re: Overriding catalog actions in v1.0.8.1 and later

Post by ecartz »

edfaught wrote: Tue Jul 19, 2022 8:55 pm PHP Parse error: syntax error, unexpected '\' (T_NS_SEPARATOR), expecting function (T_FUNCTION) or const (T_CONST) in \includes\system\override\actions\add_product.php on line 59
This is the kind of thing that happens when you have a mismatched }. It's saying that it has the code you posted but is expecting a function or const. It would be expecting a function or const if it is outside a function. If it were inside a function (where it should be), it wouldn't give that error.


Join The Code Co-op to get access to your library in the Code Co-op Forum
Post Reply