Пример #1
0
 public function __construct($company_id, $price_id = 0, $lang_code = DESCR_SL, $offset = 0, $debug = false, $options = array())
 {
     $this->company_id = $company_id;
     $this->lang_code = $lang_code;
     $this->offset = (int) $offset;
     $this->debug = $debug;
     if (!empty($price_id)) {
         $this->price_id = $price_id;
         $this->price_list = fn_yml_get_price_list($price_id);
         if (!empty($options)) {
             $this->options = $options;
         } else {
             $this->options = fn_yml_get_options($price_id);
         }
         $this->log = new Logs('csv', $price_id);
         $this->filepath = $this->getFilePath();
         $this->filepath_temp = $this->getTempFilePath();
     }
     $this->yml2_product_export = fn_get_storage_data('yml2_product_export_' . $this->price_id);
     $this->yml2_product_skip = fn_get_storage_data('yml2_product_skip_' . $this->price_id);
     if (!empty($this->options)) {
         $this->filename = $this->filename . '_' . $this->options['price_id'];
         $this->options['company_id'] = $this->company_id;
         if (!empty($this->options['export_categories'])) {
             $this->export_category_ids = explode(',', $this->options['export_categories']);
         }
         if (!empty($this->options['exclude_categories_ext'])) {
             $this->exclude_category_ids = explode(',', $this->options['exclude_categories_ext']);
         }
         if (!empty($this->options['hidden_categories'])) {
             $this->hidden_category_ids = explode(',', $this->options['hidden_categories']);
         }
         if (!empty($this->options['export_hidden_categories']) && $this->options['export_hidden_categories'] == 'Y' && !empty($this->options['hidden_categories_ext'])) {
             $hidden_category_ids_ext = explode(',', $this->options['hidden_categories_ext']);
             $this->export_category_ids = array_merge($this->export_category_ids, $hidden_category_ids_ext);
         }
         $this->options['offer_type_categories'] = $this->getYMLCategories('yml2_offer_type');
         $this->options['yml2_model_categories'] = $this->getYMLCategories('yml2_model');
         $this->options['yml2_type_prefix_categories'] = $this->getYMLCategories('yml2_type_prefix');
         $this->options['market_category'] = $this->getYMLCategories('yml2_market_category');
         $this->options['yml2_model_select'] = $this->getYMLCategories('yml2_model_select');
         foreach ($this->options['yml2_model_select'] as $category_id => $select) {
             $select = explode('.', $select);
             $this->options['yml2_model_select'][$category_id] = array();
             if (!fn_is_empty($select)) {
                 $this->options['yml2_model_select'][$category_id]['type'] = $select[0];
                 $this->options['yml2_model_select'][$category_id]['value'] = $select[1];
             }
         }
         $this->options['yml2_type_prefix_select'] = $this->getYMLCategories('yml2_type_prefix_select');
         foreach ($this->options['yml2_type_prefix_select'] as $category_id => $select) {
             $select = explode('.', $select);
             $this->options['yml2_type_prefix_select'][$category_id] = array();
             if (!fn_is_empty($select)) {
                 $this->options['yml2_type_prefix_select'][$category_id]['type'] = $select[0];
                 $this->options['yml2_type_prefix_select'][$category_id]['value'] = $select[1];
             }
         }
     }
 }
Пример #2
0
****************************************************************************/
use Tygh\Registry;
use Tygh\Ym\Yml2;
if (!defined('BOOTSTRAP')) {
    die('Access denied');
}
if ($_SERVER['REQUEST_METHOD'] == 'POST') {
    return;
}
if ($mode == 'generate' || $mode == 'get') {
    $access_key = !empty($_REQUEST['access_key']) ? $_REQUEST['access_key'] : '';
    $price_id = !empty($_REQUEST['price_id']) ? $_REQUEST['price_id'] : 0;
    if (empty($price_id) && !empty($access_key)) {
        $price_id = fn_yml_get_price_id($access_key);
    }
    $options = fn_yml_get_options($price_id);
    if (!empty($options) && $options['enable_authorization'] == 'Y' && empty($access_key)) {
        $options = array();
    }
    if (!empty($options)) {
        $company_id = Registry::get('runtime.company_id');
        if (fn_allowed_for('MULTIVENDOR')) {
            $company_id = 0;
        }
        $offset = !empty($_REQUEST['offset']) ? $_REQUEST['offset'] : 0;
        $lang_code = DESCR_SL;
        if (Registry::isExist('languages.ru')) {
            $lang_code = 'ru';
        }
        $yml = new Yml2($company_id, $price_id, $lang_code, $offset, isset($_REQUEST['debug']));
        if ($mode == 'get') {