Mimic ZenCart的页面查找

时间:2014-07-18 16:47:08

标签: php zen-cart

任何人都知道如何开始尝试为产品编写替代查找代码?

我希望做的是将ZenCart改为不仅从这里查找产品页面: http://www.example.com/index.php?main_page=product_cards_ufs_info&cPath=1_6&products_id=124

作为替代方案: http://www.example.com/index.php?ufs_card=SOME_ID

这样它就会拉出SOME_ID的产品页面(存储在附加到产品ID号的单独数据库中)。

我试图找到$ _GET [' main_page']的查找,但我的想法已经不多了。

1 个答案:

答案 0 :(得分:0)

所以这就是我最终如何做到这一点。作为/zencart/includes/functions/extra_functions文件夹下的单独文件,我最终使用了以下代码。本质上,脚本将在某个数据库表中查找短句柄并返回master_category_idproducts_id。由于我使用外部表格进行查找,因此会执行联接,我们会将结果限制为仅限第一个。

if(isset($_GET['ufs_card'])) {

    $ufs = $_GET['ufs_card'];

    // First let's "fix" the search symbol.
    // Let's remove any Underscores

    $ufs = strtoupper(str_replace("_", " ", $ufs));

    $ufs_query = "SELECT ufs.products_id, master_categories_id FROM " . TABLE_CARDS_UFS . " ufs LEFT JOIN " . TABLE_PRODUCTS . " p ON ufs.products_id = p.products_id WHERE collector_no = '" . $ufs . "' LIMIT 1";
    // echo $ufs_query;
    $ufs_get_result = $db->Execute($ufs_query);

    $ufs_id = $ufs_get_result->fields['products_id'];
    $category_id = $ufs_get_result->fields['master_categories_id'];
    if($ufs_id && $category_id) {
        // Okay we have a valid result... Let's do a redirect.
        zen_redirect(zen_href_link("product_cards_ufs_info", 'cPath=' . zen_get_generated_category_path_rev($category_id) . '&products_id=' . $ufs_id, 'NONSSL'), 307);
    } else { // We didn't find a valid result... so redirect them to page not found OR homepage.
        if (MISSING_PAGE_CHECK == 'Page Not Found') {
            zen_redirect(zen_href_link(FILENAME_PAGE_NOT_FOUND));
        } else if (MISSING_PAGE_CHECK == 'On' || MISSING_PAGE_CHECK == 'true') {
            zen_redirect(zen_href_link(FILENAME_DEFAULT));
        } 
    }
}