Page 3 of 3 FirstFirst 123
Results 21 to 29 of 29
  1. #21
    Join Date
    Apr 2009
    Posts
    415
    Plugin Contributions
    2

    Default Re: Plugin Manager (Zen Cart 1.5.7+)

    Quote Originally Posted by swguy View Post
    This would be amazingly confusing. If your plugin has front end and back end elements, just do it the old way for 1.5.7 and below.
    Yes also probably more difficult. I'll stick to old way roll on 1.5.8.
    Mark Brittain
    http:\\innerlightcrystals.co.uk\sales\

  2. #22
    Join Date
    Sep 2012
    Location
    West Jefferson, NC
    Posts
    380
    Plugin Contributions
    0

    Default Re: Plugin Manager (Zen Cart 1.5.7+)

    I am trying to put my admin program into the zc_plugin folder and have hit a 3 day snag trying to figure out how to proceed.

    Fresh install of 1.5.7c
    Ubuntu 20.04 LAMP stack
    DisplayLogs module installed
    My module partially installed
    PHP 7.4

    Using the DisplayLogs file structure as an example, I successfully registered my plugin in admin and proceeded with setting up the installer. I have been able to interact with modifying the db but have came to a screeching halt.

    I need to retrieve the configuration_group_id to do my inserts into the configuration table. Here is what worked in 1.5.6c:

    Code:
    $setup_gID = $db->execute("select `configuration_group_id`
    from " . TABLE_CONFIGURATION_GROUP . " 
    where `configuration_group_title` = 'EZ-Feeds Settings' ");
    if(isset($setup_gID->fields['configuration_group_id'])) {
      $gID_setup = $setup_gID->fields['configuration_group_id'];
    }
    Unfortunately, I have no experience with working with php classes. I have read tons of how to pages but nothing is sinking in or working for me.

    I have tried various forms of this (from configuration.php):

    Code:
    $gID = (isset($_GET['gID'])) ? $_GET['gID'] : 1;
    $_GET['gID'] = $gID;
    $cfg_group = $db->Execute("SELECT configuration_group_title
                               FROM " . TABLE_CONFIGURATION_GROUP . "
                               WHERE configuration_group_id = " . (int)$gID);
    It returned 1, instead of 31, in one of my attempts...so I tried various forms of this:

    Code:
    $gID_setup = 
    "select `configuration_group_id` from " . TABLE_CONFIGURATION_GROUP . " 
    where `configuration_group_title` = 'EZ-Feeds Settings' ";
    $this->executeInstallerSql($gID_setup);
    
    var_dump($this->gID_setup);
    exit;
    NULL was returned in one instance and bool(true) in another.

    I am blurry eyed and exhausted from trying to figure it out.

    I would appreciate some insight on how to proceed.

    BTW...great addition zc_plugin! It is going to be a huge time saver for developers after we figure out the ins and outs of it.
    Last edited by mikeel100; 3 Sep 2021 at 03:10 AM.

  3. #23
    Join Date
    Nov 2005
    Location
    los angeles
    Posts
    2,660
    Plugin Contributions
    11

    Default Re: Plugin Manager (Zen Cart 1.5.7+)

    Quote Originally Posted by mikeel100 View Post
    I need to retrieve the configuration_group_id to do my inserts into the configuration table. Here is what worked in 1.5.6c:

    Code:
    $setup_gID = $db->execute("select `configuration_group_id`
    from " . TABLE_CONFIGURATION_GROUP . " 
    where `configuration_group_title` = 'EZ-Feeds Settings' ");
    if(isset($setup_gID->fields['configuration_group_id'])) {
      $gID_setup = $setup_gID->fields['configuration_group_id'];
    }
    if this worked in v156c, i see no reason why it would not work in v157. perhaps i would do:

    PHP Code:
    //from
    if(isset($setup_gID->fields['configuration_group_id'])) {
    //to
    if(!($setup_gID->EOF) { 

    Unfortunately, I have no experience with working with php classes. I have read tons of how to pages but nothing is sinking in or working for me.

    I have tried various forms of this (from configuration.php):

    Code:
    $gID = (isset($_GET['gID'])) ? $_GET['gID'] : 1;
    $_GET['gID'] = $gID;
    $cfg_group = $db->Execute("SELECT configuration_group_title
                               FROM " . TABLE_CONFIGURATION_GROUP . "
                               WHERE configuration_group_id = " . (int)$gID);
    It returned 1, instead of 31, in one of my attempts...
    i am not sure what 'it' refers to.

    this code has little to do with classes. i would suggest studying a little more on php. your first line creates a var named $gID. if there is $_GET['gID'], $gID gets assigned that value, else it gets assigned 1. the second line assigns the $_GET['gID'] var to what $gID is. it makes no sense to me.

    do you understand _GET vars? i would suggest reading about them. it is the way to pass data from a URL. reassigning it makes no sense (to me) in this context.


    so I tried various forms of this:

    Code:
    $gID_setup = 
    "select `configuration_group_id` from " . TABLE_CONFIGURATION_GROUP . " 
    where `configuration_group_title` = 'EZ-Feeds Settings' ";
    $this->executeInstallerSql($gID_setup);
    
    var_dump($this->gID_setup);
    exit;
    NULL was returned in one instance and bool(true) in another.
    i normally use something called print_r as opposed to var_dump. but now we are into a class.... and executeInstallerSql will only return true or false. i have no idea what this might be: `$this->gID_setup`.

    i agree that the zc_plugins is a GREAT addition to ZC. but the problems that you are having are more related to your understanding of php than anything special about ZC. IMO.

    not sure that helps.... but keep trying!
    author of square Webpay. called the savior by the chief bottle washer...
    mxWorks has premium plugins. donations: venmo or paypal accepted.
    available for hire.

  4. #24
    Join Date
    Sep 2012
    Location
    West Jefferson, NC
    Posts
    380
    Plugin Contributions
    0

    Default Re: Plugin Manager (Zen Cart 1.5.7+)

    Carl, the code used in 1.5.6c was not buried in an extended class like it is in 1.5.7c zc_plugins.

    Have you successfully added an admin plugin to the new structure? I seriously doubt it by the way you failed to answer my question...thanks for responding though.

    You would know what "it" is if you read the query...

    Yes, I know what GET and POST are...they did not work in my 1.5.6 version...thus the long code.

    I will restate it again as plain as I can...

    Within an extended class (ScriptedInstaller.php), how do I retrieve the configuration_group_id from the configuration group table while working in the zc_plugin file structure?

    Below, is from ScriptedInstaller.php located in zc_plugins>MyPlugin>version>installer...this file is provided with the ZC distribution in the DisplayLogs folder under zc_plugins. I simply copied it and used as the basis for adding my plugin.

    Code:
    use Zencart\PluginSupport\ScriptedInstaller as ScriptedInstallBase;
    
    class ScriptedInstaller extends ScriptedInstallBase {
      protected function executeInstall() {
    
    
    HOW DO I RETURN THE configuration_group_id FROM THE configuration_group TABLE WITHIN THIS STRUCTURE?
    $gID_setup = "select `configuration_group_id` from " . TABLE_CONFIGURATION_GROUP . " where `configuration_group_title` = 'EZ-Feeds Settings' ";
    $this->executeInstallerSql($gID_setup); DO I HAVE TO MODIFY THIS executeInstallerSql FUNCTION? 
    
    .................
    I will continue reading until I understand how to work with extended classes. I have been reading for 4 days now without figuring out how to get what I need.

    I was simply looking for a little help...anyone else?

  5. #25
    Join Date
    Sep 2012
    Location
    West Jefferson, NC
    Posts
    380
    Plugin Contributions
    0

    Default Re: Plugin Manager (Zen Cart 1.5.7+)

    I figured out something that will work...had to dig backwards through the functions.

    Outside of zc_plugins, $db->execute precedes sql calls...inside of zc_plugins, $this->dbConn->execute($sql) precedes sql calls.

    Code:
    $sql = "select `configuration_group_id` from " . TABLE_CONFIGURATION_GROUP . " where `configuration_group_title` = 'EZ-Feeds Settings' ";
    $setup_gID = $this->dbConn->execute($sql); 
    
    if(isset($setup_gID->fields['configuration_group_id'])) {
      $gID = $setup_gID->fields['configuration_group_id'];
    }

  6. #26
    Join Date
    Jul 2012
    Posts
    16,710
    Plugin Contributions
    17

    Default Re: Plugin Manager (Zen Cart 1.5.7+)

    Quote Originally Posted by mikeel100 View Post
    I figured out something that will work...had to dig backwards through the functions.

    Outside of zc_plugins, $db->execute precedes sql calls...inside of zc_plugins, $this->dbConn->execute($sql) precedes sql calls.

    Code:
    $sql = "select `configuration_group_id` from " . TABLE_CONFIGURATION_GROUP . " where `configuration_group_title` = 'EZ-Feeds Settings' ";
    $setup_gID = $this->dbConn->execute($sql); 
    
    if(isset($setup_gID->fields['configuration_group_id'])) {
      $gID = $setup_gID->fields['configuration_group_id'];
    }
    For "reverse" compatibility, could also use either:
    Code:
    global $db;
    $db->Execute($sql);
    or
    Code:
    $GLOBALS['db']->Execute($sql);
    Otherwise, and to piggy back on the some of the previous discussion, the thing with $this->executeInstallerSql is that it returns only true or false upon completion... It does not return anything from the query (other than success/failure)... That said and I still haven't tried it yet, but it may be possible to use MySQL temporary type variables within multiple queries to collect/use data without bringing the data back to the php space.

    Also, to potentially feed back about why the assignment of $_GET might be done would be to actually ensure that the value is assigned for follow on use, even though it would be better to just use the newly created $gID and if for some reason a link needed to be generated with that information, then just add it in as part of the link generation.

    To also reiterate a previous suggestion, this:
    Code:
    if(isset($setup_gID->fields['configuration_group_id'])) {
      $gID = $setup_gID->fields['configuration_group_id'];
    }
    should instead be written:
    Code:
    if(!$setup_gID->EOF) {
      $gID = $setup_gID->fields['configuration_group_id'];
    }
    There are of course a few things that will need to be considered after this:
    May need to test if $gID is set or not before attempting to use the value or perhaps assign a default value (which is what the previous code attempted by setting it to 1 if it didn't exist...

    But as far as use of $_GET['gID'] within the installer of the plugins, well, at this point in accessing the admin, gID is not set because one is not navigating through the configuration menu.
    ZC Installation/Maintenance Support <- Site
    Contribution for contributions welcome...

  7. #27
    Join Date
    Nov 2005
    Location
    los angeles
    Posts
    2,660
    Plugin Contributions
    11

    Default Re: Plugin Manager (Zen Cart 1.5.7+)

    Quote Originally Posted by mikeel100 View Post
    Have you successfully added an admin plugin to the new structure? I seriously doubt it by the way you failed to answer my question...thanks for responding though.
    seriously doubt no more. my plugin making use of the new zc_plugin structure:

    https://www.zen-cart.com/downloads.php?do=file&id=2279

    zc_plugins getting uninstalled first reported by me:

    https://github.com/zencart/zencart/issues/4014

    a screenshot of one of my clients zc_plugins modules (most of which are not available for public download):

    Name:  Screenshot from 2021-09-03 21-09-10.jpg
Views: 564
Size:  18.7 KB

    good luck resolving your issues and understanding extending classes. i would suggest not disparaging anyone on this board who makes a valiant attempt to help you with your problems.
    author of square Webpay. called the savior by the chief bottle washer...
    mxWorks has premium plugins. donations: venmo or paypal accepted.
    available for hire.

  8. #28
    Join Date
    Nov 2005
    Location
    los angeles
    Posts
    2,660
    Plugin Contributions
    11

    Default Re: Plugin Manager (Zen Cart 1.5.7+)

    PHP Code:
    use Zencart\PluginSupport\ScriptedInstaller as ScriptedInstallBase;

    class 
    ScriptedInstaller extends ScriptedInstallBase
    {
        protected function 
    executeInstall()
        {
    // you need the next line:
            
    global $db;

            
    $sql "select `configuration_group_id` from " TABLE_CONFIGURATION_GROUP 
    where `configuration_group_title` = 'EZ-Feeds Settings' "
    ;
            
    $gidQuery $db->Execute($sql);
            if (!
    $gidQuery->EOF) {
                
    $yourNUMBER $gidQuery->fields['configuration_group_id'];
            } 
    author of square Webpay. called the savior by the chief bottle washer...
    mxWorks has premium plugins. donations: venmo or paypal accepted.
    available for hire.

  9. #29
    Join Date
    Sep 2012
    Location
    West Jefferson, NC
    Posts
    380
    Plugin Contributions
    0

    Default Re: Plugin Manager (Zen Cart 1.5.7+)

    Thanks for all the replies and suggestions.

    I ended up moving a protected function into the scripted installer from the plugin installer script...

    Code:
      protected function executeEZFeedsSql($sql) {
        $this->dbConn->dieOnErrors = false;
        $data = $this->dbConn->Execute($sql);
        if ($this->dbConn->error_number !== 0) {
            $this->errorContainer->addError(0, $this->dbConn->error_text, true, PLUGIN_INSTALL_SQL_FAILURE);
            return false;
        }
        $this->dbConn->dieOnErrors = true;
        return $data;
      }
    Then retrieving what I needed with:

    Code:
    $setup_gID = $this->executeEZFeedsSql($sql);
    		if(isset($setup_gID->fields['configuration_group_id'])) {
    			$gID = $setup_gID->fields['configuration_group_id'];
    		}
    My plugin is working fine now. It took several hours to figure out that I had to change my language file root folder path to point to the zc_plugins folder and I also had to move a few language file table, folder and file paths into the setup script.

    I will use compare both of your comments against what I have implemented and change as suggested where needed.

    Carl, sorry for being so short. I was tired and frustrated from the lack of an answer from your (long and mostly unnecessary (first response)...will take it with a grain of salt the next time.

 

 
Page 3 of 3 FirstFirst 123

Similar Threads

  1. Zen-Cart Order Manager
    By Zapisto in forum All Other Contributions/Addons
    Replies: 32
    Last Post: 28 Jul 2010, 12:31 AM

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
disjunctive-egg
Zen-Cart, Internet Selling Services, Klamath Falls, OR