Exemplo n.º 1
0
function fn_set_1c_tags($product_id = 0, $tags)
{
    if (empty($product_id)) {
        return false;
    }
    fn_update_1c_tags($product_id, $tags);
    if (Registry::get('addons.1clue_related_products_extended.related_filling') == 'tags') {
        $_tags = fn_get_1c_tags($product_id);
        if (!empty($_tags)) {
            foreach ($_tags as $tag) {
                $tag_analogues = db_get_fields("SELECT product_id FROM ?:addon_related_products_tags WHERE tag=?s", $tag);
                fn_set_related($product_id, $tag_analogues, 'cross_linked');
            }
        }
    }
    return true;
}
Exemplo n.º 2
0
* "copyright.txt" FILE PROVIDED WITH THIS DISTRIBUTION PACKAGE.            *
****************************************************************************/
use Tygh\Registry;
if (!defined('BOOTSTRAP')) {
    die('Access denied');
}
if ($_SERVER['REQUEST_METHOD'] == 'POST') {
    //
    // Update required products
    //
    if ($mode == 'update') {
        if (!empty($_REQUEST['product_id'])) {
            if (Registry::get('addons.1clue_related_products_extended.related_filling') == 'tags') {
                fn_update_1c_tags($_REQUEST['product_id'], $_REQUEST['product_data']['1c_tags']);
                db_query('DELETE FROM ?:addon_related_products WHERE master_id = ?i OR slave_id= ?i', $_REQUEST['product_id'], $_REQUEST['product_id']);
                $tags = fn_get_1c_tags($_REQUEST['product_id']);
                if (!empty($tags)) {
                    foreach ($tags as $tag) {
                        $tag_related = db_get_fields("SELECT product_id FROM ?:addon_related_products_tags WHERE tag=?s", $tag);
                        fn_set_related($_REQUEST['product_id'], $tag_related, 'cross_linked');
                    }
                }
            } else {
                $remove_slave = Registry::get('addons.1clue_related_products_extended.link_type') == 'no_links' ? '0' : $_REQUEST['product_id'];
                db_query('DELETE FROM ?:addon_related_products WHERE master_id = ?i OR slave_id= ?i', $_REQUEST['product_id'], $remove_slave);
                if (!empty($_REQUEST['related'])) {
                    $related = explode(',', $_REQUEST['related']);
                    fn_set_related($_REQUEST['product_id'], $related, Registry::get('addons.1clue_related_products_extended.link_type'));
                }
            }
        }