Page 1 of 3 123 LastLast
Results 1 to 10 of 29
  1. #1
    Join Date
    Apr 2011
    Location
    UK
    Posts
    54
    Plugin Contributions
    0

    Default Can I use an auto Import/cron job for this?

    hi, i have a supplier that can supply a text file with products

    is there a way i can make a cron job or something to fetch the data file from a passworded url convert it to a csv and import the file then excite the csv file?

    im new at cron jobs

  2. #2
    Join Date
    Apr 2011
    Location
    UK
    Posts
    54
    Plugin Contributions
    0

    Default Re: Can I use an auto Import/cron job for this?

    Quote Originally Posted by KNM Computers View Post
    hi, i have a supplier that can supply a text file with products

    is there a way i can make a cron job or something to fetch the data file from a passworded url convert it to a csv and import the file then excite the csv file?

    im new at cron jobs

    ok looking through the forum i found this:

    Quote Originally Posted by Ryk View Post
    I have no idea whether this sort of thing is even possible....

    Receive excel file
    convert excel file to fit EasyPopulate excel layout
    ftp EP file to website
    insert into ZC database

    ...all without human intervention.

    Is this doable?
    I have a partial solution which I've not tested.

    You can save an excel spreadsheet in CSV format and use, the Easy Populate CSV add on, available here:
    http://www.zen-cart.com/index.php?ma...oducts_id=1240

    Ftp the file to /tempEP (the default import directory).
    Let's say the file is called import_me.csv

    You might be able to automate the above with a batch script.

    Then create a script to be called by cron every five minutes say.
    The script must first authenticate itself.
    see:
    http://www.zen-cart.com/forum/showthread.php?t=114279

    The script then sets the filename variable to import and runs the easypopulate code.

    To authenticate we need to override init_admin_auth.php.
    So copy
    admin/includes/init_includes/init_admin_auth.php
    to
    admin/includes/init_includes/overrides/init_admin_auth.php
    and add
    """
    // to allow cron jobs set CRON_ADMIN_USER_ID
    if ($_SERVER['REMOTE_ADDR'] == $_SERVER['SERVER_ADDR']) {
    if (!isset($_SESSION['admin_id']) && defined('CRON_ADMIN_USER_ID') && CRON_ADMIN_USER_ID != '') {
    $_SESSION['admin_id'] = CRON_ADMIN_USER_ID;
    }
    }
    """
    to just after
    """

    if (!defined('IS_ADMIN_FLAG')) {
    die('Illegal Access');
    }
    """

    Then we write the script for cron.
    Create a file /admin/cron1.php:
    <?php
    define('CRON_ADMIN_USER_ID', '999');
    require ('includes/application_top.php');
    $_POST['localfile'] = "import_me.csv";
    require ('easypopulate.php');
    ?>

    Then set up the cron job to call the script eg:
    /usr/bin/lynx -accept_all_cookies -dump http://localhost/PathTo/admin/cron1.php

    Please note I haven't thoroughly tested this.
    if i set this up would i have to put a url where ill be getting my feed file from (its a passworded url) if i do then where in the script would i have to put it? or would that be a new/different cron job?

  3. #3
    Join Date
    Jan 2004
    Posts
    66,391
    Blog Entries
    7
    Plugin Contributions
    81

    Default Re: Can I use an auto Import/cron job for this?

    TIP:

    1. Forget the "cron" part initially. First get yourself a PHP script that works properly to accomplish your desired goals. Something that you can trigger from your browser by just visiting the .php file as the URL.

    2. After you've got that working reliably then test it from the command line.

    3. Then after that's working fine, set up a cron job in your hosting account to trigger that script to run at the scheduled intervals.


    #1 is where you need to focus your time. Everything else is distraction.


    As for the post you quoted above, note that it specifically says that it expects you to FTP the CSV to the server beforehand. So judging from the other stuff you've written, you're going to need to first automate the process of grabbing the password-protected file before you kick off anything that processes that file.
    .

    Zen Cart - putting the dream of business ownership within reach of anyone!
    Donate to: DrByte directly or to the Zen Cart team as a whole

    Remember: Any code suggestions you see here are merely suggestions. You assume full responsibility for your use of any such suggestions, including any impact ANY alterations you make to your site may have on your PCI compliance.
    Furthermore, any advice you see here about PCI matters is merely an opinion, and should not be relied upon as "official". Official PCI information should be obtained from the PCI Security Council directly or from one of their authorized Assessors.

  4. #4
    Join Date
    Apr 2011
    Location
    UK
    Posts
    54
    Plugin Contributions
    0

    Default Re: Can I use an auto Import/cron job for this?

    got ya thanks

  5. #5
    Join Date
    Apr 2011
    Location
    UK
    Posts
    54
    Plugin Contributions
    0

    Default Re: Can I use an auto Import/cron job for this?

    well wot i did was added this into url bar http://www.knmcomputers.co.uk/myadmin/cron1.php it asked me to log in so i did then when it loged it it did import my products

    so what did you say was next?

  6. #6
    Join Date
    Jan 2004
    Posts
    66,391
    Blog Entries
    7
    Plugin Contributions
    81

    Default Re: Can I use an auto Import/cron job for this?

    I'm not sure I understand your question.

    Are you wanting to know how to bypass the login? That's answered in the post you quoted.
    .

    Zen Cart - putting the dream of business ownership within reach of anyone!
    Donate to: DrByte directly or to the Zen Cart team as a whole

    Remember: Any code suggestions you see here are merely suggestions. You assume full responsibility for your use of any such suggestions, including any impact ANY alterations you make to your site may have on your PCI compliance.
    Furthermore, any advice you see here about PCI matters is merely an opinion, and should not be relied upon as "official". Official PCI information should be obtained from the PCI Security Council directly or from one of their authorized Assessors.

  7. #7
    Join Date
    Apr 2011
    Location
    UK
    Posts
    54
    Plugin Contributions
    0

    Default Re: Can I use an auto Import/cron job for this?

    sorry lol in a way yes, as i think this will be an issue if im to get the whole process automatic, but the main question was as i have it excuited the script when i added the url so i need this to do it automatic?

  8. #8
    Join Date
    Apr 2011
    Location
    UK
    Posts
    54
    Plugin Contributions
    0

    Default Re: Can I use an auto Import/cron job for this?

    ok in the file i made in admin called cron1 i put

    Code:
    <?php
    define('CRON_ADMIN_USER_ID', '1'); 
    require ('includes/application_top.php');
    $_POST['localfile'] = "Full-EP2013Jul20-2311.csv";
    require ('easypopulate.php');
    ?>
    and in admin/includes/init_includes/overides/init_admin_auth.php is

    Code:
    <?php
    /**
     * @package admin
     * @copyright Copyright 2003-2012 Zen Cart Development Team
     * @license http://www.zen-cart.com/license/2_0.txt GNU Public License V2.0
     * @version GIT: $Id: Author: Ian Wilson  Sun Jul 1 12:08:22 2012 +0100 Modified in v1.5.1 $
     */
    
    if (!defined('IS_ADMIN_FLAG')) die('Illegal Access');
    
    define(SUPERUSER_PROFILE, 1);
    
    // admin folder rename required
    if (!defined('ADMIN_BLOCK_WARNING_OVERRIDE') || ADMIN_BLOCK_WARNING_OVERRIDE == '')
    {
      if (basename($_SERVER['SCRIPT_FILENAME']) != FILENAME_ALERT_PAGE . '.php')
      {
        if (substr(DIR_WS_ADMIN, -7) == '/admin/' || substr(DIR_WS_HTTPS_ADMIN, -7) == '/admin/')
        {
          zen_redirect(zen_href_link(FILENAME_ALERT_PAGE));
        }
        $check_path = dirname($_SERVER['SCRIPT_FILENAME']) . '/../zc_install';
        if (is_dir($check_path))
        {
          zen_redirect(zen_href_link(FILENAME_ALERT_PAGE));
        }
      }
    }
    if (basename($_SERVER['SCRIPT_FILENAME']) != FILENAME_ALERT_PAGE . '.php')
    {
    
      if (strpos(strtolower($PHP_SELF),FILENAME_PASSWORD_FORGOTTEN.'.php') !== FALSE &&
      substr_count(strtolower($PHP_SELF), '.php') > 1)
      {
        zen_redirect(zen_href_link(FILENAME_LOGIN, '', 'SSL'));
      }
    
      if (!(basename($PHP_SELF) == FILENAME_LOGIN . ".php"))
      {
        $page = basename($PHP_SELF, ".php");
        if (!isset($_SESSION['admin_id']))
        {
          if (!(basename($PHP_SELF) == FILENAME_PASSWORD_FORGOTTEN . '.php'))
          {
            zen_redirect(zen_href_link(FILENAME_LOGIN, 'camefrom=' . basename($PHP_SELF) . '&' .  zen_get_all_get_params(), 'SSL'));
          }
        }
    
        if (!in_array($page, array(FILENAME_DEFAULT,FILENAME_ADMIN_ACCOUNT,FILENAME_LOGOFF,FILENAME_ALERT_PAGE,FILENAME_PASSWORD_FORGOTTEN,FILENAME_DENIED,FILENAME_ALT_NAV)) &&
            !zen_is_superuser())
        {
          if (check_page($page, $_GET) == FALSE)
          {
            zen_redirect(zen_href_link(FILENAME_DENIED, '', 'SSL'));
          }
        }
    
      }
    
      if ((basename($PHP_SELF) == FILENAME_LOGIN . '.php') &&
      (substr_count(dirname($PHP_SELF),'//') > 0 || substr_count(dirname($PHP_SELF),'.php') > 0))
      {
        zen_redirect(zen_href_link(FILENAME_LOGIN, '', 'SSL'));
      }
    }
    but is does not do the auto admin login have i done something wrong?

  9. #9
    Join Date
    Jan 2004
    Posts
    66,391
    Blog Entries
    7
    Plugin Contributions
    81

    Default Re: Can I use an auto Import/cron job for this?

    This thread is worth a read: http://www.zen-cart.com/showthread.p...for-a-cron-job through all pages.
    .

    Zen Cart - putting the dream of business ownership within reach of anyone!
    Donate to: DrByte directly or to the Zen Cart team as a whole

    Remember: Any code suggestions you see here are merely suggestions. You assume full responsibility for your use of any such suggestions, including any impact ANY alterations you make to your site may have on your PCI compliance.
    Furthermore, any advice you see here about PCI matters is merely an opinion, and should not be relied upon as "official". Official PCI information should be obtained from the PCI Security Council directly or from one of their authorized Assessors.

  10. #10
    Join Date
    Apr 2011
    Location
    UK
    Posts
    54
    Plugin Contributions
    0

    Default Re: Can I use an auto Import/cron job for this?

    hi the cron file i made where it says:
    " <?php
    define('CRON_ADMIN_USER_ID', '1'); "

    is the the zencart admin id?

    i have zencart 1.51 and think ive read somewhere about making up a user ???

    thanks

 

 
Page 1 of 3 123 LastLast

Similar Threads

  1. Admin auto login for a cron job
    By Gigo in forum Customization from the Admin
    Replies: 20
    Last Post: 9 Aug 2012, 07:39 AM
  2. Can I run Backup MYSQL Plugin v1.4 via cron job?
    By Renz in forum General Questions
    Replies: 2
    Last Post: 23 Mar 2012, 06:25 AM
  3. Setting up a cron job for the Snapshot add-on?
    By RescoCCC in forum All Other Contributions/Addons
    Replies: 11
    Last Post: 3 Jan 2012, 06:19 PM
  4. Cron Job for Optimize Database
    By Convergence in forum General Questions
    Replies: 4
    Last Post: 24 Jan 2011, 09:36 PM
  5. Cron Job for Updating QTY
    By ryanb4614 in forum General Questions
    Replies: 2
    Last Post: 9 Aug 2010, 07:13 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