function fn_yml_import_exclude_prices($key, $data) { static $price_lists; if (!isset($price_lists)) { $price_lists = fn_yml_get_price_lists(); $price_lists = array_keys($price_lists); } $exclude_data = explode(',', $data); $old_exclude = fm_yml_get_exclude_products($key); $old_exclude_data = array(); if (!empty($old_exclude)) { foreach ($old_exclude as $old_data) { $old_exclude_data[] = $old_data['price_id']; } } $exclude_data = array_intersect($exclude_data, $price_lists); $delete_old_exclude = array_diff($old_exclude_data, $exclude_data); $add_new_exclude = array_diff($exclude_data, $old_exclude_data); if (!empty($delete_old_exclude)) { db_query("DELETE FROM ?:yml_exclude_objects WHERE object_type = 'product' AND object_id = ?i AND price_id IN (?a)", $key, $delete_old_exclude); } if (!empty($add_new_exclude)) { foreach ($add_new_exclude as $price_id) { db_query("INSERT INTO ?:yml_exclude_objects (price_id, object_id, object_type) VALUES(?i, ?i, 'product') ", $price_id, $key); } } return true; }
<?php /*************************************************************************** * * * (c) 2004 Vladimir V. Kalynyak, Alexey V. Vinokurov, Ilya M. Shalnev * * * * This is commercial software, only users who have purchased a valid * * license and accept to the terms of the License Agreement can install * * and use this program. * * * **************************************************************************** * PLEASE READ THE FULL TEXT OF THE SOFTWARE LICENSE AGREEMENT IN THE * * "copyright.txt" FILE PROVIDED WITH THIS DISTRIBUTION PACKAGE. * ****************************************************************************/ use Tygh\Registry; if (!defined('BOOTSTRAP')) { die('Access denied'); } if ($mode == 'update') { $price_lists = fn_yml_get_price_lists(); Tygh::$app['view']->assign('yml2_price_lists', $price_lists); }
Tygh::$app['view']->assign('products_data', $products_data); } elseif ($mode == 'update' || $mode == 'add') { $offer_types = fn_get_schema('yml', 'offer_types'); unset($offer_types['common']); if (!empty($_REQUEST['product_id'])) { $product = Tygh::$app['view']->getTemplateVars('product_data'); $parent_offer_type = fn_yml_get_parent_categories_field('yml2_offer_type', $product['main_category'], true); $yml2_model_category = fn_yml_get_parent_categories_field('yml2_model', $product['main_category'], true); $yml2_type_prefix_category = fn_yml_get_parent_categories_field('yml2_type_prefix', $product['main_category'], true); $yml2_market_category = fn_yml_get_parent_categories_field('yml2_market_category', $product['main_category'], true); $yml2_parent_offer_type_name = ''; if (!empty($parent_offer_type)) { $yml2_parent_offer_type_name = $offer_types[$parent_offer_type]; } Tygh::$app['view']->assign('yml2_parent_offer_type_name', $yml2_parent_offer_type_name); Tygh::$app['view']->assign('offer_type_parent_category', $parent_offer_type); Tygh::$app['view']->assign('yml2_model_category', $yml2_model_category); Tygh::$app['view']->assign('yml2_type_prefix_category', $yml2_type_prefix_category); Tygh::$app['view']->assign('yml2_market_category', $yml2_market_category); $yml2_exclude = fm_yml_get_exclude_products($_REQUEST['product_id']); $yml2_exclude_prices = array(); foreach ($yml2_exclude as $exclude) { $yml2_exclude_prices[] = $exclude['price_id']; } Tygh::$app['view']->assign('yml2_exclude_prices', $yml2_exclude_prices); $yml2_prices = fn_yml_get_price_lists(); Tygh::$app['view']->assign('yml2_prices', $yml2_prices); } Tygh::$app['view']->assign('yml2_offer_types', $offer_types); Registry::set('navigation.tabs.yml', array('title' => __('yml_export'), 'js' => true)); }