Page 1 of 2 12 LastLast
Results 1 to 10 of 19
  1. #1
    Join Date
    May 2006
    Location
    Gardiner, Maine
    Posts
    2,371
    Plugin Contributions
    23

    Default need a little help thinking through an issue between two carts

    There are two carts that used to be on two different servers. There were scripts in place to update one of the carts via a daily cron job. The owner only edits/adds products in one cart and then the other cart is updated and the new images moved through ftp to the second cart.

    Now both carts on on the same hosting account with the second cart as a add on domain on a cpanel server.

    I don't like the way this way done before and want to rethink the whole process to make sure this is done efficiently.

    The first part is the database:

    The updating of the products in the database may need to be done just as before with minimal changes of code. But I do want opinions about how it is done. It looks unnecessarily complicated to me.

    My understanding is that the owner never ever edits products on the second site. My inclination is to simply empty the tables on the second site and replace with required tables on first site. The dual wholesale mod is installed which creates one extra field on the products fields.

    Here's the code
    PHP Code:
    $error "";
    $success "";
    //connect to the database
    $con mysql_connect("ip address","secondsite","password");
    if (!
    $con)
      {
      
    $error "Could not connect: " mysql_error();
      }

    mysql_select_db("secondsite"$con);

    mysql_query("DROP TABLE IF EXISTS `zen_products_description_temp`;");

    $query_temp "CREATE TABLE `zen_products_description_temp` (
      `products_id` int(11) NOT NULL AUTO_INCREMENT,
      `products_description` text,
      `products_viewed` int(5) DEFAULT '0',
      `product_is_always_free_shipping` tinyint(1) NOT NULL DEFAULT '0',
      `products_status` tinyint(1) NOT NULL DEFAULT '0',
      PRIMARY KEY (`products_id`)
    );"
    ;
    mysql_query($query_temp);

    $query_add "INSERT INTO zen_products_description_temp SELECT a.products_id, products_description, products_viewed, product_is_always_free_shipping, products_status FROM zen_products_description a, zen_products b where a.products_id = b.products_id";

    mysql_query($query_add);


    //dump 7 specific tables into a .sql file on firstsite database
    $command "mysqldump --user=firstsite --password=deleted --host=ip address firstsite zen_products zen_products_description zen_categories zen_categories_description zen_products_to_categories zen_manufacturers zen_manufacturers_info zen_products_attributes zen_products_options zen_products_options_values zen_products_options_values_to_products_options > secondsite.sql";
    exec($command);

    //restore those tables into the missarchery database
    $restore "mysql --user=secondsite--password=deleted --host=ip number secondsite< secondsite.sql";
    exec($restore);
    //close the database connection
    mysql_close($con);

    //connect to the database
    $con2 mysql_connect("ip address","secondsite","password");
    if (!
    $con2)
      {
      
    $error "Could not connect: " mysql_error();
      }

    mysql_select_db("secondsite"$con2);

    //update the prices to the retail price
    $query "UPDATE zen_products set products_price = products_price_w, products_price_sorter = products_price_w";
    if(
    $test mysql_query($query)){
        
    $success .= "The prices were successfully updated to the retail price!" "\n";
    }else{
        
    $error .= "Error updating the prices to retail price." mysql_error() . "\n";    
    }

    //change jmp091023 - add update query to set tax-class values for all products to '1' (taxable).
    $query "UPDATE zen_products set products_tax_class_id = '1'";
    if(
    $test mysql_query($query)){
        
    $success .= "All products are now marked as taxable!" "\n";
    }else{
        
    $error .= "Error updating the products_tax_class_id." mysql_error() . "\n";    
    }
    //jmp091023 ends.

    //update product description and products viewed
    $query "UPDATE zen_products_description a, zen_products_description_temp b, zen_products c SET a.products_description = b.products_description, a.products_viewed = b.products_viewed, c.product_is_always_free_shipping = b.product_is_always_free_shipping, c.products_status = b.products_status WHERE a.products_id = b.products_id and c.products_id = b.products_id;";
    if(
    $test2 mysql_query($query)){
        
    $success .= "Product descriptions, free shipping indicators, and status were preserved!" "\n";
    }else{
        
    $error .= "Error updating the products description." mysql_error() . "\n";
    }

    mysql_query("DROP TABLE IF EXISTS `zen_products_description_temp`;");
    //close the database connection
    mysql_close($con2);

    unlink('secondsite.sql'); 
    The second part are the images. There are nearly 7000 images for the products. I thought to simply point the second site to the image directory of the first which is in the root. Changing the image path when it's an addon domain did not work as I had hoped because the root for the add on domain is not the hosting account root but only inside that add on domain. To be clear:
    full path for first site is /home/account name/public_html. For the second site it is /home/account name/public_html/secondsite.com/

    So I first changed this define('DIR_WS_IMAGES', 'images/'); to this define('DIR_WS_IMAGES', '/images/'); does not point to first domain in actual root.

    Bypassing the file structure and doing this bypassing zen cart image functions completely displaying the full size original image
    define('DIR_WS_IMAGES', 'http://firstsite.com/images/');

    I can't think of any other way to do it with the configure file though there may be. I'm also wanting to install image handler to make this even more complicated. Guess the images just should be copied to the second site.

    So I thought, what if when she uploads an image into the first site, why not have zen copy that image to the other? Or a script that rests in the images folder that detects a new image and then copies it to the second site. That requires no sql queries and no cron job.

    So then I thought, wait if I can do that, perhaps I should just set up the first site to send a query to the second site when updating or adding new products. Total synchonization.

    But. That does sound pretty intensive and probably more time to do that updating the existing scripts with new database settings and replacing mysql with mysqli.

    What's your opinion? If you started from scratch, how would you do it?
    The full-time Zen Cart Guru. WizTech4ZC.com
    New template for 2.0 viewable here: 2.0 Demo

  2. #2
    Join Date
    Sep 2009
    Location
    Stuart, FL
    Posts
    13,979
    Plugin Contributions
    96

    Default Re: need a little help thinking through an issue between two carts

    Have you considered the "Multi-Site Module"?

  3. #3
    Join Date
    May 2006
    Location
    Gardiner, Maine
    Posts
    2,371
    Plugin Contributions
    23

    Default Re: need a little help thinking through an issue between two carts

    Yeah, I had a passing thought to that. But checkout has always been the issue. Don't all templates have to use the same url for checkout? Or is that just when you have ssl turned on? One site uses ssl and the other does not. Owner has definitely stated that neither site can reference the other - keeping retail and wholesale completely separate in the end. The reason why the dual wholesale mod is installed is to have both prices with only wholesale displaying on one and only retail on the other and insure updating correctly.
    The full-time Zen Cart Guru. WizTech4ZC.com
    New template for 2.0 viewable here: 2.0 Demo

  4. #4
    Join Date
    Dec 2009
    Location
    Amersfoort, The Netherlands
    Posts
    2,845
    Plugin Contributions
    25

    Default Re: need a little help thinking through an issue between two carts

    Quote Originally Posted by delia View Post
    Yeah, I had a passing thought to that. But checkout has always been the issue. Don't all templates have to use the same url for checkout? Or is that just when you have ssl turned on? One site uses ssl and the other does not. Owner has definitely stated that neither site can reference the other - keeping retail and wholesale completely separate in the end. The reason why the dual wholesale mod is installed is to have both prices with only wholesale displaying on one and only retail on the other and insure updating correctly.
    With the multi site module each site can be configured separately. Including the ssl. One site can use ssl while the other does not, but also both can have their own ssl.

  5. #5
    Join Date
    May 2006
    Location
    Gardiner, Maine
    Posts
    2,371
    Plugin Contributions
    23

    Default Re: need a little help thinking through an issue between two carts

    Yeah, that I figured out but there's different payment and shipping methods between the two sites so varied that I don't see how it's possible to have both coexist on the same site. Great idea though.
    The full-time Zen Cart Guru. WizTech4ZC.com
    New template for 2.0 viewable here: 2.0 Demo

  6. #6
    Join Date
    Dec 2009
    Location
    Amersfoort, The Netherlands
    Posts
    2,845
    Plugin Contributions
    25

    Default Re: need a little help thinking through an issue between two carts

    It is also possible to specify the different payment mods. Every value that is present in the the configuration table, can be overridden in the sites config file.

  7. #7
    Join Date
    May 2006
    Location
    Gardiner, Maine
    Posts
    2,371
    Plugin Contributions
    23

    Default Re: need a little help thinking through an issue between two carts

    I wonder... That would well worth the effort if it can be done. Thanks.
    The full-time Zen Cart Guru. WizTech4ZC.com
    New template for 2.0 viewable here: 2.0 Demo

  8. #8
    Join Date
    Dec 2009
    Location
    Amersfoort, The Netherlands
    Posts
    2,845
    Plugin Contributions
    25

    Default Re: need a little help thinking through an issue between two carts

    If you need any help let me know

  9. #9
    Join Date
    May 2006
    Location
    Gardiner, Maine
    Posts
    2,371
    Plugin Contributions
    23

    Default Re: need a little help thinking through an issue between two carts

    I'll be talking with the owner to see if this will work. I have installed several multi sites before so hopefully all will go well Those configure settings I haven't done with that before but have with my mobile template so I think I'm going to be okay.

    Great getting the responses - working by your self sometimes feedback is just invaluable when one's brain gets overwhelmed.

    Thanks to everyone!
    The full-time Zen Cart Guru. WizTech4ZC.com
    New template for 2.0 viewable here: 2.0 Demo

  10. #10
    Join Date
    May 2006
    Location
    Gardiner, Maine
    Posts
    2,371
    Plugin Contributions
    23

    Default Re: need a little help thinking through an issue between two carts

    @Design75 I have run into a problem. I upgraded multi-site to 1.5.4. The biggest difference between the two sites is that one is normal - and one customer pending approval so it's goes to the login screen. On the site that requires login/signup, it throws this error

    [08-Mar-2015 09:35:36 America/New_York] PHP Warning: session_start(): Cannot send session cache limiter - headers already sent (output started at /home/domain/public_html/multi/includes/config_sites/deliasample.com_config.php:4) in /home/domain/public_html/multi/includes/functions/sessions.php on line 115

    So the session gets started twice this way. I don't know if this has been an issue before or if it is just post 1.5.1 versions.

    I tried both ways - having the database set as customer pending or just in the site_config file. Makes no difference.

    I assume I did the file integrations right - there really wasn't much to it really.

    So I figure the problem in the init_sessions.php.

    // bof Multi site - Prioritise the GET variable over the cookie.
    elseif(isset($_GET[session_name()])) {
    zen_setcookie(session_name(), $_GET[session_name()], time()+$SESS_LIFE, '/', (zen_not_null($current_domain) ? $current_domain : ''));
    if(isset($_COOKIE[session_name()])&&($_COOKIE[session_name()]!=$_GET[session_name()])) {
    $_COOKIE[session_name()] = $_GET[session_name()];
    }
    }
    //eof Multi site

    What do you think?
    The full-time Zen Cart Guru. WizTech4ZC.com
    New template for 2.0 viewable here: 2.0 Demo

 

 
Page 1 of 2 12 LastLast

Similar Threads

  1. I've got two things not working for me, need little here
    By Mazion in forum Templates, Stylesheets, Page Layout
    Replies: 3
    Last Post: 3 Sep 2010, 08:56 AM
  2. Need help with URL shopping carts!
    By helpme123 in forum All Other Contributions/Addons
    Replies: 17
    Last Post: 1 Apr 2009, 12:25 AM
  3. Zen newbie thinking through discount strategy - help
    By brightgirl in forum Discounts/Coupons, Gift Certificates, Newsletters, Ads
    Replies: 2
    Last Post: 29 Feb 2008, 01:25 AM

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