Results 1 to 10 of 2445

Hybrid View

  1. #1
    Join Date
    Nov 2008
    Posts
    164
    Plugin Contributions
    0

    Default Re: Ceon URI Mapping v4.x

    I hacked this together a few years back to auto generate CEON product URIs - it's crude but it's worked well for me, and it's free. Simply copy one of the admin pages and drop the code in, run as needed to update product URIs.

    It lists all the categories on the site. Click the category name to auto populate the product URIs into the database.

    Notes:
    - It uses the old mysql function because I haven't kept up to date on coding practices
    - Filebase it works with for me is CEON 4.4.1
    - The site I have it on is running ZC 1.5.1
    - You do need the category slug to be generated before generating the product URIs - just navigate to the regular zencart "edit categories" page and edit then save each category

    Code:
    <?php // display categories to select from
            $categories = mysql_query("SELECT * FROM zen_categories LEFT JOIN zen_categories_description ON zen_categories.categories_id = zen_categories_description.categories_id WHERE zen_categories.categories_status='1'");
            echo "<p>Click on a category to update it's products: <br/>";
            while ($showthiscat = mysql_fetch_assoc($categories)){
                echo "<a href='update-ceon-uri.php?updatecategory={$showthiscat['categories_id']}'>{$showthiscat['categories_name']}</a>, \n";
            }
            echo "</p>\n<hr/>\n";
        ?>
    
        <?php 
            $replacechars = array("(",")","'","\"","$","%","&"); // specify all characters to be eliminated
            // update all products in category
            $updateuris = mysql_query("SELECT * FROM zen_products WHERE master_categories_id='{$_GET['updatecategory']}'"); 
            while ($thisuri = mysql_fetch_assoc($updateuris)) {
                unset($catname);
                $productsid = $thisuri['products_id'];
                $productsname = implode(mysql_fetch_assoc(mysql_query("SELECT products_name FROM zen_products_description WHERE products_id='{$productsid}'"))); 
                $catname = implode(mysql_fetch_assoc(mysql_query("SELECT uri FROM zen_ceon_uri_mappings WHERE main_page='index' AND associated_db_id='{$thisuri['master_categories_id']}'")));
                $newuri = $catname."/".strtolower(str_replace(" ","-",$productsname));
                //$newuri = "/".strtolower(str_replace(" ","-",$productsname));    // product-only on this site
                $newuri = str_replace($replacechars,"",$newuri); // remove characters in the array above
                $today = date('Y-m-d G:i:s'); // today
                
                if($productsname == ''){continue;} // skip empty names
                
            $exists = implode(mysql_fetch_assoc(mysql_query("SELECT * FROM zen_ceon_uri_mappings WHERE main_page='product_info' AND associated_db_id='$productsid'")));     // used to check if product already exists to do update vs insert
            
            if ($exists) { // if already in zen_ceon_uri_mappings, update
                mysql_query("UPDATE zen_ceon_uri_mappings SET uri='$newuri' WHERE main_page='product_info' AND associated_db_id='$productsid'");
                $result = "Updated... ".mysql_error();
            } else { // else, insert
                mysql_query("INSERT IGNORE INTO zen_ceon_uri_mappings 
                            (`uri`, `language_id`, `current_uri`, `main_page`, `query_string_parameters`, `associated_db_id`, `alternate_uri`, `redirection_type_code`, `date_added`) VALUES 
                            ('$newuri','1','1','product_info',NULL,'$productsid',NULL,NULL,'$today')");
                $result = "Inserted... ".mysql_error();
            }
                
                echo "<p>$newuri (cat: {$thisuri['master_categories_id']}) - $result</p>\n"; // display whether updated or inserted and any problems encountered
            }
            
    ?>
    Last edited by bobthemolder; 23 Mar 2016 at 12:40 AM.

  2. #2
    Join Date
    Apr 2010
    Posts
    900
    Plugin Contributions
    0

    Default Re: Ceon URI Mapping v4.x

    Quote Originally Posted by bobthemolder View Post
    I hacked this together a few years back to auto generate CEON product URIs - it's crude but it's worked well for me, and it's free. Simply copy one of the admin pages and drop the code in, run as needed to update product URIs.

    It lists all the categories on the site. Click the category name to auto populate the product URIs into the database.
    A standalone URI generator? Awesomeness! Right on!!!!

  3. #3
    Join Date
    Jan 2004
    Posts
    66,450
    Plugin Contributions
    81

    Default Re: Ceon URI Mapping v4.x

    @bobthemolder,

    I think the following does the same thing, but uses the Zen Cart $db stuff to do the queries, making your stuff compatible with newer ZC versions.
    I don't have a CEON URI site to test it on, but I think I've converted it correctly.

    Code:
    // display categories to select from
    $categories = $db->Execute("SELECT * FROM " . TABLE_CATEGORIES . " c LEFT JOIN " . TABLE_CATEGORIES_DESCRIPTION . " cd ON c.categories_id = cd.categories_id WHERE c.categories_status='1'");
    echo "<p>Click on a category to update its products: <br/>";
    while (!$categories->EOF) {
        echo "<a href='update-ceon-uri.php?updatecategory={$categories->fields['categories_id']}'>{$categories->fields['categories_name']}</a>, \n";
        $categories->MoveNext();
    }
    echo "</p>\n<hr/>\n";
    
    
    $replacechars = array("(",")","'","\"","$","%","&"); // specify all characters to be eliminated
    // update all products in category
    $_GET['updatecategory'] = (int)$_GET['updatecategory'];
    $updateuris = $db->Execute("SELECT * FROM " . TABLE_PRODUCTS . " WHERE master_categories_id='{$_GET['updatecategory']}'");
    while (!$updateuris->EOF)) {
        $thisuri = $updateuris->fields;
        unset($catname);
    
    
        $productsid = $thisuri['products_id'];
        $productsname = zen_get_products_name($productsid); 
        if($productsname == '') continue; // skip empty names
    
    
        $result = $db->Execute("SELECT uri FROM " . TABLE_CEON_URI_MAPPINGS . " WHERE main_page='index' AND associated_db_id='{$thisuri['master_categories_id']}'");
        $catname = $result->fields['uri'];
        $newuri = $catname."/".strtolower(str_replace(" ","-",$productsname));
        //$newuri = "/".strtolower(str_replace(" ","-",$productsname));    // product-only on this site
    
    
        // remove characters in the array above
        $newuri = str_replace($replacechars,"",$newuri); 
        $today = date('Y-m-d G:i:s'); // today
    
    
        // check if product already exists to do update vs insert
        $result = $db->Execute("SELECT * FROM " . TABLE_CEON_URI_MAPPINGS . " WHERE main_page='product_info' AND associated_db_id='$productsid'");
        $exists = $result->RecordCount();
    
    
        if ($exists) { // if already in TABLE_CEON_URI_MAPPINGS, update
            $db->Execute("UPDATE " . TABLE_CEON_URI_MAPPINGS . " SET uri='$newuri' WHERE main_page='product_info' AND associated_db_id='$productsid'");
            $status = "Updated. ";
        } else { // else, insert
            $db->Execute("INSERT IGNORE INTO " . TABLE_CEON_URI_MAPPINGS . " 
                        (`uri`, `language_id`, `current_uri`, `main_page`, `query_string_parameters`, `associated_db_id`, `alternate_uri`, `redirection_type_code`, `date_added`) VALUES 
                        ('$newuri','1','1','product_info',NULL,'$productsid',NULL,NULL,'$today')");
            $status = "Inserted. ";
        }
    
    
        // display whether updated or inserted and any problems encountered
        echo "<p>$newuri (cat: {$thisuri['master_categories_id']}) - $status</p>\n"; 
    
    
        $updateuris->MoveNext();
    }
    .

    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
    Jul 2009
    Posts
    402
    Plugin Contributions
    0

    Default Re: Ceon URI Mapping v4.x

    Quote Originally Posted by DrByte View Post
    @bobthemolder,

    I think the following does the same thing, but uses the Zen Cart $db stuff to do the queries, making your stuff compatible with newer ZC versions.
    I don't have a CEON URI site to test it on, but I think I've converted it correctly.

    Code:
    // display categories to select from
    $categories = $db->Execute("SELECT * FROM " . TABLE_CATEGORIES . " c LEFT JOIN " . TABLE_CATEGORIES_DESCRIPTION . " cd ON c.categories_id = cd.categories_id WHERE c.categories_status='1'");
    echo "<p>Click on a category to update its products: <br/>";
    while (!$categories->EOF) {
        echo "<a href='update-ceon-uri.php?updatecategory={$categories->fields['categories_id']}'>{$categories->fields['categories_name']}</a>, \n";
        $categories->MoveNext();
    }
    echo "</p>\n<hr/>\n";
    
    
    $replacechars = array("(",")","'","\"","$","%","&"); // specify all characters to be eliminated
    // update all products in category
    $_GET['updatecategory'] = (int)$_GET['updatecategory'];
    $updateuris = $db->Execute("SELECT * FROM " . TABLE_PRODUCTS . " WHERE master_categories_id='{$_GET['updatecategory']}'");
    while (!$updateuris->EOF)) {
        $thisuri = $updateuris->fields;
        unset($catname);
    
    
        $productsid = $thisuri['products_id'];
        $productsname = zen_get_products_name($productsid); 
        if($productsname == '') continue; // skip empty names
    
    
        $result = $db->Execute("SELECT uri FROM " . TABLE_CEON_URI_MAPPINGS . " WHERE main_page='index' AND associated_db_id='{$thisuri['master_categories_id']}'");
        $catname = $result->fields['uri'];
        $newuri = $catname."/".strtolower(str_replace(" ","-",$productsname));
        //$newuri = "/".strtolower(str_replace(" ","-",$productsname));    // product-only on this site
    
    
        // remove characters in the array above
        $newuri = str_replace($replacechars,"",$newuri); 
        $today = date('Y-m-d G:i:s'); // today
    
    
        // check if product already exists to do update vs insert
        $result = $db->Execute("SELECT * FROM " . TABLE_CEON_URI_MAPPINGS . " WHERE main_page='product_info' AND associated_db_id='$productsid'");
        $exists = $result->RecordCount();
    
    
        if ($exists) { // if already in TABLE_CEON_URI_MAPPINGS, update
            $db->Execute("UPDATE " . TABLE_CEON_URI_MAPPINGS . " SET uri='$newuri' WHERE main_page='product_info' AND associated_db_id='$productsid'");
            $status = "Updated. ";
        } else { // else, insert
            $db->Execute("INSERT IGNORE INTO " . TABLE_CEON_URI_MAPPINGS . " 
                        (`uri`, `language_id`, `current_uri`, `main_page`, `query_string_parameters`, `associated_db_id`, `alternate_uri`, `redirection_type_code`, `date_added`) VALUES 
                        ('$newuri','1','1','product_info',NULL,'$productsid',NULL,NULL,'$today')");
            $status = "Inserted. ";
        }
    
    
        // display whether updated or inserted and any problems encountered
        echo "<p>$newuri (cat: {$thisuri['master_categories_id']}) - $status</p>\n"; 
    
    
        $updateuris->MoveNext();
    }
    Hi,
    I am not sure I understood how to use the code above, I mean how to make in work.
    bobthemolder said to copy it in a amdin page but I did it in the categories.php page and all what I get is a blank page (zen cart v1.5.5)
    Can you please explain it in more details?
    Thanks
    enzo
    Last edited by enzo-ita; 2 Apr 2016 at 11:57 PM.

  5. #5
    Join Date
    Sep 2006
    Posts
    163
    Plugin Contributions
    1

    Default Re: Ceon URI Mapping v4.x

    You don't need to understand it: there is now a 155 version available for download. Simply install that!

  6. #6
    Join Date
    Jul 2009
    Posts
    402
    Plugin Contributions
    0

    Default Re: Ceon URI Mapping v4.x

    Quote Originally Posted by hairydog View Post
    You don't need to understand it: there is now a 155 version available for download. Simply install that!
    Thanks but there is not a version that does this
    auto generate CEON product URIs - it's crude but it's worked well for me, and it's free. Simply copy one of the admin pages and drop the code in, run as needed to update product URIs.
    as bobthemolder said.
    I like to understand and experimet, however.
    Ciao
    enzo

  7. #7
    Join Date
    Aug 2014
    Location
    Lisbon
    Posts
    594
    Plugin Contributions
    0

    Default Re: Ceon URI Mapping v4.x

    Hi
    Kind of Feature request:

    Is there a possibility in a near future that ceon could add the bookx product type to his package ?
    There's a product type ( in the install ) for product_book ... but I think that module has drop from updates.
    This one, BookX it's new and it's alive.

    I've pasted on git , what I've done to have the Ceon working with BookX product type, so basically copy and pasting the code from book module to bookx module.

    Well, I never use the other book module, but I guess it would update the products uri, and not the authors, genres...etc...but I don't know.
    Anyway , it would be nice :)

    Perhaps this link could save you some additional work... or not

    https://github.com/mesnitu/Ceon-BookX/

    Thanks
    “Though the problems of the world are increasingly complex, the solutions remain embarrassingly simple.” ― Bill Mollison

 

 

Similar Threads

  1. v139d Ceon uri mapping, how to generate uri mapping for bulk bulk-imported products?
    By mybiz9999 in forum All Other Contributions/Addons
    Replies: 3
    Last Post: 8 Jan 2013, 06:52 AM
  2. CEON URI Mapping
    By jmkent in forum All Other Contributions/Addons
    Replies: 3
    Last Post: 22 Nov 2012, 04:28 PM
  3. Ceon URI Mapping (SEO)
    By conor in forum All Other Contributions/Addons
    Replies: 2906
    Last Post: 9 Sep 2011, 08:31 AM
  4. Ceon URI Mapping v4
    By conor in forum All Other Contributions/Addons
    Replies: 110
    Last Post: 14 Aug 2011, 02:51 PM

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