예제 #1
0
function fn_required_products_get_product_data_post(&$product, &$auth)
{
    if (!empty($product['product_id'])) {
        list($required) = fn_get_products(array('for_required_product' => $product['product_id']));
        if (count($required)) {
            $product['have_required'] = 'Y';
            $ids = fn_array_column($required, 'product_id');
            $have = fn_required_products_get_existent($auth, $ids);
            $product['required_products'] = array();
            fn_gather_additional_products_data($required, array('get_icon' => true, 'get_detailed' => true, 'get_options' => true, 'get_discounts' => true));
            foreach ($required as $entry) {
                $id = $entry['product_id'];
                $product['required_products'][$id] = $entry;
                $product['required_products'][$id]['bought'] = $have && in_array($id, $have) ? 'Y' : 'N';
            }
            if (!empty($have) && count($have) >= count($ids)) {
                $product['can_add_to_cart'] = 'Y';
            } else {
                $product['can_add_to_cart'] = 'N';
            }
        } else {
            $product['have_required'] = 'N';
        }
    }
}
예제 #2
0
function fn_required_products_get_product_data_more(&$product, &$auth)
{
    if (!empty($product['product_id'])) {
        list($requered) = fn_get_products(array('for_required_product' => $product['product_id'], 'type' => 'extended'));
        if (count($requered)) {
            $product['have_required'] = 'Y';
            $ids = array();
            foreach ($requered as $entry) {
                $ids[] = $entry['product_id'];
            }
            $have = fn_required_products_get_existent($auth, $ids, false);
            $product['required_products'] = array();
            foreach ($requered as $entry) {
                $id = $entry['product_id'];
                fn_gather_additional_product_data($entry, true, true, true, true, true);
                $product['required_products'][$id] = $entry;
                $product['required_products'][$id]['bought'] = $have && in_array($id, $have) ? 'Y' : 'N';
            }
            if (!empty($have) && count($have) >= count($ids)) {
                $product['can_add_to_cart'] = 'Y';
            } else {
                $product['can_add_to_cart'] = 'N';
            }
        } else {
            $product['have_required'] = 'N';
        }
    }
}
예제 #3
0
 public function index($id = 0, $params = array())
 {
     $lang_code = $this->safeGet($params, 'lang_code', DEFAULT_LANGUAGE);
     if ($this->getParentName() == 'categories') {
         $parent_category = $this->getParentData();
         $params['cid'] = $parent_category['category_id'];
     }
     if (!empty($id)) {
         $data = fn_get_product_data($id, $this->auth, $lang_code, '', true, true, true, false, false, false, false);
         if (empty($data)) {
             $status = Response::STATUS_NOT_FOUND;
         } else {
             $status = Response::STATUS_OK;
         }
     } else {
         $items_per_page = $this->safeGet($params, 'items_per_page', Registry::get('settings.Appearance.admin_products_per_page'));
         $params['extend'][] = 'categories';
         list($products, $search) = fn_get_products($params, $items_per_page, $lang_code);
         $params['get_options'] = $this->safeGet($params, 'get_options', false);
         $params['get_features'] = $this->safeGet($params, 'get_features', true);
         $params['get_detailed'] = $this->safeGet($params, 'get_detailed', true);
         $params['get_icon'] = $this->safeGet($params, 'get_icon', true);
         $params['get_additional'] = $this->safeGet($params, 'get_additional', true);
         $params['detailed_params'] = $this->safeGet($params, 'detailed_params', false);
         $params['features_display_on'] = 'A';
         fn_gather_additional_products_data($products, $params);
         $data = array('products' => array_values($products), 'params' => $search);
         $status = Response::STATUS_OK;
     }
     return array('status' => $status, 'data' => $data);
 }
예제 #4
0
 /**
  * Gets products for printing and print them
  * @param array $params product search params
  */
 protected function processProducts($params)
 {
     $total = static::ITEMS_PER_PAGE;
     while (static::ITEMS_PER_PAGE * ($params['page'] - 1) <= $total) {
         list($products, $search) = fn_get_products($params, static::ITEMS_PER_PAGE);
         $total = $search['total_items'];
         if ($params['page'] == 1) {
             fn_set_progress('parts', $total);
         }
         $get_images = !empty($this->selected_fields['image']);
         $_params = array('get_icon' => $get_images, 'get_detailed' => $get_images, 'get_options' => Registry::get('addons.price_list.include_options') == 'Y' ? true : false, 'get_discounts' => false);
         fn_gather_additional_products_data($products, $_params);
         $params['page']++;
         $this->printProductsBatch(true);
         foreach ($products as $product) {
             fn_set_progress('echo');
             if (Registry::get('addons.price_list.include_options') == 'Y' && $product['has_options']) {
                 $product = fn_price_list_get_combination($product);
                 foreach ($product['combinations'] as $c_id => $c_value) {
                     $product['price'] = $product['combination_prices'][$c_id];
                     $product['weight'] = $product['combination_weight'][$c_id];
                     $product['amount'] = $product['combination_amount'][$c_id];
                     $product['product_code'] = $product['combination_code'][$c_id];
                     $this->printProductRow($product, $c_value);
                 }
             } else {
                 $this->printProductRow($product);
             }
         }
         $this->printProductsBatch();
     }
 }
예제 #5
0
function fn_specific_development_products_from_current_category($category_ids)
{
    $category_id = fn_specific_development_get_main_category($category_ids);
    if (!$category_id) {
        return array();
    }
    $params = array('sl' => 'EN', 'type' => 'extended', 'cid' => $category_id);
    if (!empty($_REQUEST['sl'])) {
        $params['sl'] = $_REQUEST['sl'];
    }
    list($products) = fn_get_products($params);
    if (!empty($products)) {
        foreach ($products as $k => $v) {
            fn_gather_additional_product_data($products[$k], false, true, false, false, true);
        }
    }
    fn_specific_development_view_category($products);
    return $products;
}
예제 #6
0
function fn_required_products_get_product_data_post(&$product, &$auth)
{
    if (!empty($product['product_id'])) {
        list($required) = fn_get_products(array('for_required_product' => $product['product_id']));
        //var_dump($required);
        //var_dump(AREA);
        if (AREA != "A") {
            $checkedVariants = db_get_fields("SELECT required_id FROM ?:product_required_products WHERE product_id=?i AND linked=1", $_REQUEST['product_id']);
            foreach ($required as $keyProductRequired => $productRequired) {
                if (in_array($productRequired['product_id'], $checkedVariants)) {
                    unset($required[$keyProductRequired]);
                }
            }
        }
        if (count($required)) {
            $product['have_required'] = 'Y';
            $ids = array();
            foreach ($required as $entry) {
                $ids[] = $entry['product_id'];
            }
            $have = fn_required_products_get_existent($auth, $ids, false);
            $product['required_products'] = array();
            fn_gather_additional_products_data($required, array('get_icon' => true, 'get_detailed' => true, 'get_options' => true, 'get_discounts' => true));
            foreach ($required as $entry) {
                $id = $entry['product_id'];
                $product['required_products'][$id] = $entry;
                $product['required_products'][$id]['bought'] = $have && in_array($id, $have) ? 'Y' : 'N';
            }
            if (!empty($have) && count($have) >= count($ids)) {
                $product['can_add_to_cart'] = 'Y';
            } else {
                $product['can_add_to_cart'] = 'N';
            }
        } else {
            $product['have_required'] = 'N';
        }
    }
}
예제 #7
0
/**
 * Gets products default navigation
 *
 * @param array $params Request params
 * @return array navigation data
 */
function fn_lv_get_product_default_navigation($params)
{
    if (empty($params['product_id'])) {
        return false;
    }
    $update_data = array();
    $product_id = $params['product_id'];
    if (fn_allowed_for('ULTIMATE') && Registry::get('runtime.company_id')) {
        $company_condition = fn_get_company_condition('c.company_id');
        $category_id = db_get_field("SELECT c.category_id, IF(pc.link_type = ?s, 1, 0) as is_main FROM ?:categories AS c LEFT JOIN ?:products_categories AS pc ON c.category_id = pc.category_id WHERE pc.product_id = ?i {$company_condition} ORDER BY is_main DESC", 'M', $product_id);
    } else {
        $category_id = db_get_field("SELECT category_id FROM ?:products_categories WHERE product_id = ?i AND link_type = ?s", $product_id, 'M');
    }
    if (empty($category_id)) {
        return false;
    }
    $search_params = array('cid' => $category_id, 'get_conditions' => true);
    list($fields, $join, $condition) = fn_get_products($search_params);
    $sorting = "ORDER BY descr1.product asc";
    // get product position in full list
    db_query("SET @r = 0;");
    $product_position = db_get_field("SELECT a.row FROM (SELECT products.product_id, @r := @r + 1 as row FROM ?:products as products {$join} WHERE 1 {$condition} GROUP BY products.product_id {$sorting}) AS a WHERE a.product_id = ?i", $product_id);
    $items_per_page = Registry::get('settings.Appearance.products_per_page');
    if (empty($product_position) || empty($items_per_page)) {
        return false;
    }
    $page = ceil($product_position / $items_per_page);
    $limit = db_paginate($page, $items_per_page);
    $stored_items_ids[$page] = db_get_fields("SELECT SQL_CALC_FOUND_ROWS products.product_id FROM ?:products as products {$join} WHERE 1 {$condition} GROUP BY products.product_id {$sorting} {$limit}");
    $total_items = db_get_found_rows();
    $total_pages = ceil($total_items / $items_per_page);
    unset($search_params['get_conditions']);
    $update_data['params'] = serialize($search_params);
    $update_data['view_results'] = array('items_ids' => $stored_items_ids, 'total_pages' => $total_pages, 'items_per_page' => $items_per_page, 'total_items' => $total_items);
    $update_data['view_results'] = serialize($update_data['view_results']);
    return $update_data;
}
예제 #8
0
파일: rss.php 프로젝트: arpad9/bygmarket
function fn_rssf_get_items($params, $lang_code = CART_LANGUAGE)
{
    $items_data = $additional_data = $block_data = array();
    if (!empty($params['bid']) && !empty($params['sid']) && empty($params['category_id'])) {
        $block_data = Block::instance()->getById($params['bid'], $params['sid'], array(), $lang_code);
        if (!empty($block_data['content']['filling']) && $block_data['content']['filling'] == 'products') {
            $_params = array('sort_by' => $block_data['properties']['filling']['products']['rss_sort_by'] == 'U' ? 'updated_timestamp' : 'timestamp', 'sort_order' => 'desc');
            $max_items = !empty($block_data['properties']['max_item']) ? $block_data['properties']['max_item'] : 5;
            list($products) = fn_get_products($_params, $max_items, $lang_code);
            fn_gather_additional_products_data($products, array('get_icon' => true, 'get_detailed' => true, 'get_options' => false, 'get_discounts' => false));
            $additional_data['title'] = !empty($block_data['properties']['feed_title']) ? $block_data['properties']['feed_title'] : __('products') . '::' . __('page_title', '', $lang_code);
            $additional_data['description'] = !empty($block_data['properties']['feed_description']) ? $block_data['properties']['feed_description'] : $additional_data['title'];
            $additional_data['link'] = fn_url('', 'C', 'http', $lang_code);
            $additional_data['language'] = $lang_code;
            $additional_data['lastBuildDate'] = !empty($products[0]['updated_timestamp']) ? $products[0]['updated_timestamp'] : TIME;
            $items_data = fn_format_products_items($products, $block_data['properties']['filling']['products'], $lang_code);
        }
    } else {
        //show rss feed for categories page
        list($items_data, $additional_data) = fn_format_categories_items($params, $lang_code);
    }
    fn_set_hook('generate_rss_feed', $items_data, $additional_data, $block_data, $lang_code);
    return array($items_data, $additional_data);
}
예제 #9
0
function fn_google_sitemap_get_content($map_page = 0)
{
    $cache_path = fn_get_cache_path(false) . 'google_sitemap/';
    define('ITEMS_PER_PAGE', 500);
    define('MAX_URLS_IN_MAP', 50000);
    // 50 000 is the maximum for one sitemap file
    define('MAX_SIZE_IN_KBYTES', 10000);
    // 10240 KB || 10 Mb is the maximum for one sitemap file
    $sitemap_settings = Registry::get('addons.google_sitemap');
    $location = Registry::get('config.http_location');
    $lmod = date("Y-m-d", TIME);
    header("Content-Type: text/xml;charset=utf-8");
    // HEAD SECTION
    $simple_head = <<<HEAD
<?xml version="1.0" encoding="UTF-8"?>
<urlset xmlns="http://www.sitemaps.org/schemas/sitemap/0.9"
        xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
        xsi:schemaLocation="http://www.sitemaps.org/schemas/sitemap/0.9
            http://www.sitemaps.org/schemas/sitemap/0.9/sitemap.xsd">


HEAD;
    $simple_foot = <<<FOOT

</urlset>
FOOT;
    $index_map_url = <<<HEAD
    <url>
        <loc>{$location}/</loc>
        <lastmod>{$lmod}</lastmod>
        <changefreq>{$sitemap_settings['site_change']}</changefreq>
        <priority>{$sitemap_settings['site_priority']}</priority>
    </url>

HEAD;
    // END HEAD SECTION
    // SITEMAP CONTENT
    $link_counter = 1;
    $file_counter = 1;
    fn_mkdir($cache_path);
    $file = fopen($cache_path . 'sitemap' . $file_counter . '.xml', "wb");
    fwrite($file, $simple_head . $index_map_url);
    $languages = db_get_hash_single_array("SELECT lang_code, name FROM ?:languages WHERE status = 'A'", array('lang_code', 'name'));
    if ($sitemap_settings['include_categories'] == "Y") {
        $categories = db_get_fields("SELECT category_id FROM ?:categories WHERE FIND_IN_SET(?i, usergroup_ids) AND status = 'A' ?p", USERGROUP_ALL, fn_get_google_sitemap_company_condition('?:categories.company_id'));
        //Add the all active categories
        foreach ($categories as $category) {
            $links = fn_google_sitemap_generate_link('category', $category, $languages);
            $item = fn_google_sitemap_print_item_info($links, $lmod, $sitemap_settings['categories_change'], $sitemap_settings['categories_priority']);
            fn_google_sitemap_check_counter($file, $link_counter, $file_counter, $links, $simple_head, $simple_foot);
            fwrite($file, $item);
        }
    }
    if ($sitemap_settings['include_products'] == "Y") {
        $page = 1;
        $total = ITEMS_PER_PAGE;
        $params = $_REQUEST;
        $params['page'] = $page;
        $params['custom_extend'] = array('categories');
        $params['sort_by'] = 'null';
        $params['only_short_fields'] = true;
        while (ITEMS_PER_PAGE * ($params['page'] - 1) <= $total) {
            list($products, $search) = fn_get_products($params, ITEMS_PER_PAGE);
            $total = $search['total_items'];
            $params['page']++;
            foreach ($products as $product) {
                $links = fn_google_sitemap_generate_link('product', $product['product_id'], $languages);
                $item = fn_google_sitemap_print_item_info($links, $lmod, $sitemap_settings['products_change'], $sitemap_settings['products_priority']);
                fn_google_sitemap_check_counter($file, $link_counter, $file_counter, $links, $simple_head, $simple_foot);
                fwrite($file, $item);
            }
        }
        unset($products);
    }
    if ($sitemap_settings['include_pages'] == "Y") {
        $pages = db_get_fields("SELECT page_id FROM ?:pages WHERE status = 'A' AND page_type != 'L' ?p", fn_get_google_sitemap_company_condition('?:pages.company_id'));
        //Add the all active pages
        foreach ($pages as $page) {
            $links = fn_google_sitemap_generate_link('page', $page, $languages);
            $item = fn_google_sitemap_print_item_info($links, $lmod, $sitemap_settings['pages_change'], $sitemap_settings['pages_priority']);
            fn_google_sitemap_check_counter($file, $link_counter, $file_counter, $links, $simple_head, $simple_foot);
            fwrite($file, $item);
        }
    }
    if ($sitemap_settings['include_extended'] == "Y") {
        $vars = db_get_fields("SELECT ?:product_feature_variants.variant_id FROM ?:product_feature_variants " . "LEFT JOIN ?:product_features ON (?:product_feature_variants.feature_id = ?:product_features.feature_id) " . "WHERE ?:product_features.feature_type = 'E' AND ?:product_features.status = 'A'");
        //Add the all active extended features
        foreach ($vars as $var) {
            $links = fn_google_sitemap_generate_link('extended', $var, $languages);
            $item = fn_google_sitemap_print_item_info($links, $lmod, $sitemap_settings['extended_change'], $sitemap_settings['extended_priority']);
            fn_google_sitemap_check_counter($file, $link_counter, $file_counter, $links, $simple_head, $simple_foot);
            fwrite($file, $item);
        }
    }
    if (Registry::isExist("addons.news_and_emails") && $sitemap_settings['include_news'] == 'Y') {
        $news = db_get_fields("SELECT news_id FROM ?:news WHERE status = 'A' ?p", fn_get_google_sitemap_company_condition('?:news.company_id'));
        if (!empty($news)) {
            foreach ($news as $news_id) {
                $links = fn_google_sitemap_generate_link('news', $news_id, $languages);
                $item = fn_google_sitemap_print_item_info($links, $lmod, $sitemap_settings['news_change'], $sitemap_settings['news_priority']);
                fn_google_sitemap_check_counter($file, $link_counter, $file_counter, $links, $simple_head, $simple_foot);
                fwrite($file, $item);
            }
        }
    }
    if (fn_allowed_for('MULTIVENDOR') && $sitemap_settings['include_companies'] == 'Y') {
        $companies = db_get_fields("SELECT company_id FROM ?:companies WHERE status = 'A' ?p", fn_get_google_sitemap_company_condition('?:companies.company_id'));
        if (!empty($companies)) {
            foreach ($companies as $company_id) {
                $links = fn_google_sitemap_generate_link('companies', $company_id, $languages);
                $item = fn_google_sitemap_print_item_info($links, $lmod, $sitemap_settings['companies_change'], $sitemap_settings['companies_priority']);
                fn_google_sitemap_check_counter($file, $link_counter, $file_counter, $links, $simple_head, $simple_foot);
                fwrite($file, $item);
            }
        }
    }
    fn_set_hook('sitemap_item', $sitemap_settings, $file, $lmod, $link_counter, $file_counter);
    fwrite($file, $simple_foot);
    fclose($file);
    if ($file_counter == 1) {
        fn_rename($cache_path . 'sitemap' . $file_counter . '.xml', $cache_path . 'sitemap.xml');
    } else {
        // Make a map index file
        $maps = '';
        $seo_enabled = Registry::get('addons.seo.status') == 'A' ? true : false;
        for ($i = 1; $i <= $file_counter; $i++) {
            if ($seo_enabled) {
                $name = $location . '/sitemap' . $i . '.xml';
            } else {
                $name = fn_url('xmlsitemap.view?page=' . $i, 'C', 'http');
            }
            $name = htmlentities($name);
            $maps .= <<<MAP
    <sitemap>
        <loc>{$name}</loc>
        <lastmod>{$lmod}</lastmod>
    </sitemap>

MAP;
        }
        $index_map = <<<HEAD
<?xml version="1.0" encoding="UTF-8"?>
<sitemapindex xmlns="http://www.sitemaps.org/schemas/sitemap/0.9"
        xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
        xsi:schemaLocation="http://www.sitemaps.org/schemas/sitemap/0.9
            http://www.sitemaps.org/schemas/sitemap/0.9/sitemap.xsd">

{$maps}
</sitemapindex>
HEAD;
        $file = fopen($cache_path . 'sitemap.xml', "wb");
        fwrite($file, $index_map);
        fclose($file);
    }
    $filename = $cache_path . 'sitemap.xml';
    if (!empty($map_page)) {
        $name = $cache_path . 'sitemap' . $map_page . '.xml';
        if (file_exists($name)) {
            $filename = $name;
        }
    }
    readfile($filename);
    exit;
}
예제 #10
0
파일: func.php 프로젝트: arpad9/bygmarket
/**
 * Get products as API list
 * @param array $params
 * @param integer $items_per_page
 * @param string $lang_code
 * @return array array('products' => array(), 'params' => array())
 */
function fn_twg_api_get_products($params, $items_per_page = 10, $lang_code = CART_LANGUAGE)
{
    $to_unserialize = array('extend', 'variants');
    foreach ($to_unserialize as $field) {
        if (!empty($params[$field]) && is_string($params[$field])) {
            $params[$field] = unserialize($params[$field]);
        }
    }
    if (empty($params['extend'])) {
        $params['extend'] = array('description');
    }
    if (!empty($params['pid']) && !is_array($params['pid'])) {
        $params['pid'] = explode(',', $params['pid']);
    }
    if (!empty($params['q'])) {
        // search by product code
        $params['ppcode'] = 'Y';
        $params['subcats'] = 'Y';
        $params['status'] = 'A';
        $params['pshort'] = 'Y';
        $params['pfull'] = 'Y';
        $params['pname'] = 'Y';
        $params['pkeywords'] = 'Y';
        $params['search_performed'] = 'Y';
    }
    if (isset($params['company_id']) and $params['company_id'] == 0) {
        unset($params['company_id']);
    }
    if (empty($params['page'])) {
        $params['page'] = 1;
    }
    list($products, $params) = fn_get_products($params, $items_per_page, $lang_code);
    fn_gather_additional_products_data($products, array('get_icon' => true, 'get_detailed' => true, 'get_options' => true, 'get_discounts' => true, 'get_features' => false));
    if (empty($products)) {
        return array(array(), array());
    }
    $product_ids = array();
    $image_params = TwigmoSettings::get('images.catalog');
    foreach ($products as $k => $v) {
        if (!empty($products[$k]['short_description']) || !empty($products[$k]['full_description'])) {
            $products[$k]['short_description'] = !empty($products[$k]['short_description']) ? strip_tags($products[$k]['short_description']) : fn_substr(strip_tags($products[$k]['full_description']), 0, TWG_MAX_DESCRIPTION_LEN);
            unset($products[$k]['full_description']);
        } else {
            $products[$k]['short_description'] = '';
        }
        $product_ids[] = $v['product_id'];
        // Get product image data
        if (!empty($v['main_pair'])) {
            $products[$k]['icon'] = TwigmoImage::getApiImageData($v['main_pair'], 'product', 'icon', $image_params);
        }
    }
    $category_descr = !empty($product_ids) ? db_get_hash_array("SELECT p.product_id, p.category_id, c.category\n             FROM ?:products_categories AS p, ?:category_descriptions AS c\n             WHERE c.category_id = p.category_id\n             AND c.lang_code = ?s\n             AND p.product_id IN (?a)\n             AND p.link_type = 'M'", 'product_id', $lang_code, $product_ids) : array();
    foreach ($products as $key => $product) {
        if (!empty($product['product_id']) && !empty($category_descr[$product['product_id']])) {
            $products[$key]['category'] = $category_descr[$product['product_id']]['category'];
            $products[$key]['category_id'] = $category_descr[$product['product_id']]['category_id'];
        }
        if (!empty($product['inventory_amount']) && $product['inventory_amount'] > $product['amount']) {
            $products[$key]['amount'] = $product['inventory_amount'];
        }
    }
    $result = Api::getAsList('products', $products);
    return array($result, $params);
}
예제 #11
0
function fn_data_feeds_export($datafeed_id, $options = array(), $pattern = '')
{
    static $pattern;
    if (empty($pattern)) {
        $pattern = fn_get_pattern_definition('products');
    }
    $params['datafeed_id'] = $datafeed_id;
    $params['single'] = true;
    $params['available_fields'] = 'Y';
    $params = array_merge($params, $options);
    $datafeed_data = fn_data_feeds_get_data($params, DESCR_SL);
    if (empty($pattern) || empty($params['datafeed_id'])) {
        fn_set_notification('E', __('error'), __('error_exim_no_data_exported'));
        return false;
    }
    if ($datafeed_data['exclude_disabled_products'] == 'Y') {
        $params['status'] = 'A';
    }
    if (empty($datafeed_data['products']) && empty($datafeed_data['categories'])) {
        $params['cid'] = 0;
        $params['subcats'] = 'Y';
        $params['skip_view'] = 'Y';
        $params['extend'] = array('categories');
        list($products, $search) = fn_get_products($params);
        $pids = array_map(create_function('$product', '$pid = $product["product_id"]; return $pid;'), $products);
    } else {
        $pids = array();
        if (!empty($datafeed_data['products'])) {
            $pids = explode(',', $datafeed_data['products']);
        }
        if (!empty($datafeed_data['categories'])) {
            $params['cid'] = explode(',', $datafeed_data['categories']);
            $params['subcats'] = 'Y';
            $params['skip_view'] = 'Y';
            $params['extend'] = array('categories');
            list($products, $search) = fn_get_products($params);
            $_pids = array_map(create_function('$product', '$pid = $product["product_id"]; return $pid;'), $products);
            $pids = array_merge($pids, $_pids);
            unset($_pids);
        }
        $pids = array_unique($pids);
    }
    if (empty($pids)) {
        fn_set_notification('E', __('error'), __('error_exim_no_data_exported'));
        return false;
    }
    $pattern['condition']['conditions']['product_id'] = $pids;
    $fields = array();
    if (!empty($datafeed_data['fields'])) {
        foreach ($datafeed_data['fields'] as $field) {
            $fields[$field['field']] = $field['export_field_name'];
        }
    }
    $features = db_get_array('SELECT feature_id, description FROM ?:product_features_descriptions WHERE lang_code = ?s', DESCR_SL);
    $features_fields = array();
    if (!empty($features)) {
        foreach ($features as $feature) {
            $features_fields[$feature['description']] = array('process_get' => array('fn_data_feeds_get_product_features', '#key', '#field', '#lang_code'), 'linked' => false);
        }
    }
    $pattern['export_fields'] = array_merge($pattern['export_fields'], $features_fields);
    $options = $datafeed_data['export_options'];
    $options['delimiter'] = $datafeed_data['csv_delimiter'];
    $options['filename'] = $datafeed_data['file_name'];
    $options['fields_names'] = true;
    $options['force_header'] = true;
    $pattern['enclosure'] = !empty($datafeed_data['enclosure']) ? $datafeed_data['enclosure'] : '';
    if (!empty($fields)) {
        if (fn_export($pattern, $fields, $options) == true) {
            $errors = false;
            $export_location = empty($params['location']) ? $datafeed_data['export_location'] : $params['location'];
            if ($export_location == 'S') {
                if (file_exists(fn_get_files_dir_path() . $datafeed_data['file_name']) && is_dir($datafeed_data['save_dir'])) {
                    fn_rename(fn_get_files_dir_path() . $datafeed_data['file_name'], $datafeed_data['save_dir'] . '/' . $datafeed_data['file_name']);
                } else {
                    $errors = true;
                    fn_set_notification('E', __('error'), __('check_server_export_settings'));
                }
            } elseif ($export_location == 'F') {
                if (empty($datafeed_data['ftp_url'])) {
                    $errors = true;
                    fn_set_notification('E', __('error'), __('ftp_connection_problem'));
                } else {
                    preg_match("/[^\\/^\\^:]+/", $datafeed_data['ftp_url'], $matches);
                    $host = $matches[0];
                    preg_match("/.*:([0-9]+)/", $datafeed_data['ftp_url'], $matches);
                    $port = empty($matches[1]) ? 21 : $matches[1];
                    preg_match("/[^\\/]+(.*)/", $datafeed_data['ftp_url'], $matches);
                    $url = empty($matches[1]) ? '' : $matches[1];
                    $conn_id = @ftp_connect($host, $port);
                    $result = @ftp_login($conn_id, $datafeed_data['ftp_user'], $datafeed_data['ftp_pass']);
                    if (!empty($url)) {
                        @ftp_chdir($conn_id, $url);
                    }
                    $filename = fn_get_files_dir_path() . $datafeed_data['file_name'];
                    if ($result) {
                        if (@ftp_put($conn_id, $datafeed_data['file_name'], $filename, FTP_ASCII)) {
                            unlink($filename);
                        } else {
                            $errors = true;
                            fn_set_notification('E', __('error'), __('ftp_connection_problem'));
                        }
                    } else {
                        $errors = true;
                        fn_set_notification('E', __('error'), __('ftp_connection_problem'));
                    }
                    @ftp_close($conn_id);
                }
            }
            if (!$errors) {
                fn_set_notification('N', __('notice'), __('text_exim_data_exported'));
                return true;
            } else {
                unlink(fn_get_files_dir_path() . $datafeed_data['file_name']);
                return false;
            }
        } else {
            fn_set_notification('E', __('error'), __('error_exim_no_data_exported'));
            return false;
        }
    } else {
        fn_set_notification('E', __('error'), __('error_exim_fields_not_selected'));
        return false;
    }
}
예제 #12
0
    if (!empty($optsVariantsLinksToProductsArray)) {
        $comparationResults = fn_get_product_data_for_compare($optsVariantsLinksToProductsArray, $action);
        Registry::get('view')->assign('comparison_data', $comparationResults);
        Registry::get('view')->assign('total_products', count($optsVariantsLinksToProductsArray));
        Registry::get('view')->assign('list', $list);
        Registry::get('view')->assign('action', $action);
    }
    if ($_REQUEST['compare_type']) {
        Registry::get('view')->assign('elem_width', $_REQUEST['elem_width']);
        Registry::set('runtime.root_template', 'views/products/show_option_variant_link_products_list.tpl');
    }
} elseif ($mode == 'show_boxes_products') {
    if ($_REQUEST['product_ids']) {
        $params['item_ids'] = $_REQUEST['product_ids'];
        $params['p_status'] = array("A", "H");
        list($products, $search) = fn_get_products($params, 100, CART_LANGUAGE);
    }
    Registry::get('view')->assign('products', $products);
} elseif ($mode == 'ls_wishlist_update') {
    //update number of favorite products through ajax
    $result = $_SESSION['wishlist'];
    $wishlistest3 = count($result['products']);
    echo $wishlistest3;
    exit;
} elseif ($mode == 'delete_footer' && !empty($_REQUEST['cart_id'])) {
    fn_delete_wishlist_product($wishlist, $_REQUEST['cart_id']);
    fn_save_cart_content($wishlist, $auth['user_id'], 'W');
    exit;
} elseif ($mode == 'view_details_compact') {
    if ($_REQUEST['variant_id']) {
        $fieldsOptionsVariantsLinksToProducts = "d.product_id AS linked_product_id";
예제 #13
0
/**
 * Getting users list
 *
 * @param  array  $params          Params list
 * @param  array  $auth            Auth
 * @param  int    $items_per_page  Items per page
 * @param  str    $custom_view     Custom view
 * @return array
 */
function fn_get_users($params, &$auth, $items_per_page = 0, $custom_view = '')
{
    /**
     * Actions before getting users list
     *
     * @param array $params         Params list
     * @param array $auth           Auth data
     * @param int   $items_per_page Items per page
     * @param str   $custom_view    Custom view
     */
    fn_set_hook('get_users_pre', $params, $auth, $items_per_page, $custom_view);
    // Init filter
    $_view = !empty($custom_view) ? $custom_view : 'users';
    $params = LastView::instance()->update($_view, $params);
    // Set default values to input params
    $default_params = array('page' => 1, 'items_per_page' => $items_per_page);
    $params = array_merge($default_params, $params);
    // Define fields that should be retrieved
    $fields = array("?:users.user_id", "?:users.user_login", "?:users.is_root", "?:users.timestamp", "?:users.user_type", "?:users.status", "?:users.firstname", "?:users.lastname", "?:users.email", "?:users.company", "?:users.company_id", "?:companies.company as company_name");
    // Define sort fields
    $sortings = array('id' => "?:users.user_id", 'username' => "?:users.user_login", 'email' => "?:users.email", 'name' => array("?:users.lastname", "?:users.firstname"), 'date' => "?:users.timestamp", 'type' => "?:users.user_type", 'status' => "?:users.status", 'company' => "company_name");
    if (isset($params['compact']) && $params['compact'] == 'Y') {
        $union_condition = ' OR ';
    } else {
        $union_condition = ' AND ';
    }
    $condition = array();
    $join = $group = '';
    $group .= " GROUP BY ?:users.user_id";
    if (isset($params['company']) && fn_string_not_empty($params['company'])) {
        $condition['company'] = db_quote(" AND ?:users.company LIKE ?l", "%" . trim($params['company']) . "%");
    }
    if (isset($params['name']) && fn_string_not_empty($params['name'])) {
        $arr = fn_explode(' ', $params['name']);
        foreach ($arr as $k => $v) {
            if (!fn_string_not_empty($v)) {
                unset($arr[$k]);
            }
        }
        if (sizeof($arr) == 2) {
            $condition['name'] = db_quote(" AND (?:users.firstname LIKE ?l AND ?:users.lastname LIKE ?l)", "%" . array_shift($arr) . "%", "%" . array_shift($arr) . "%");
        } else {
            $condition['name'] = db_quote(" AND (?:users.firstname LIKE ?l OR ?:users.lastname LIKE ?l)", "%" . trim($params['name']) . "%", "%" . trim($params['name']) . "%");
        }
    }
    if (isset($params['user_login']) && fn_string_not_empty($params['user_login'])) {
        $condition['user_login'] = db_quote(" {$union_condition} ?:users.user_login LIKE ?l", "%" . trim($params['user_login']) . "%");
    }
    if (!empty($params['tax_exempt'])) {
        $condition['tax_exempt'] = db_quote(" AND ?:users.tax_exempt = ?s", $params['tax_exempt']);
    }
    if (!fn_allowed_for('ULTIMATE:FREE')) {
        if (isset($params['usergroup_id']) && $params['usergroup_id'] != ALL_USERGROUPS) {
            if (!empty($params['usergroup_id'])) {
                $join .= db_quote(" LEFT JOIN ?:usergroup_links ON ?:usergroup_links.user_id = ?:users.user_id AND ?:usergroup_links.usergroup_id = ?i", $params['usergroup_id']);
                $condition['usergroup_links'] = " AND ?:usergroup_links.status = 'A'";
            } else {
                $join .= " LEFT JOIN ?:usergroup_links ON ?:usergroup_links.user_id = ?:users.user_id AND ?:usergroup_links.status = 'A'";
                $condition['usergroup_links'] = " AND ?:usergroup_links.user_id IS NULL";
            }
        }
    }
    if (!empty($params['status'])) {
        $condition['status'] = db_quote(" AND ?:users.status = ?s", $params['status']);
    }
    if (isset($params['email']) && fn_string_not_empty($params['email'])) {
        $condition['email'] = db_quote(" {$union_condition} ?:users.email LIKE ?l", "%" . trim($params['email']) . "%");
    }
    if (isset($params['address']) && fn_string_not_empty($params['address'])) {
        $condition['address'] = db_quote(" AND (?:user_profiles.b_address LIKE ?l OR ?:user_profiles.s_address LIKE ?l)", "%" . trim($params['address']) . "%", "%" . trim($params['address']) . "%");
    }
    if (isset($params['zipcode']) && fn_string_not_empty($params['zipcode'])) {
        $condition['zipcode'] = db_quote(" AND (?:user_profiles.b_zipcode LIKE ?l OR ?:user_profiles.s_zipcode LIKE ?l)", "%" . trim($params['zipcode']) . "%", "%" . trim($params['zipcode']) . "%");
    }
    if (!empty($params['country'])) {
        $condition['country'] = db_quote(" AND (?:user_profiles.b_country LIKE ?l OR ?:user_profiles.s_country LIKE ?l)", "%{$params['country']}%", "%{$params['country']}%");
    }
    if (isset($params['state']) && fn_string_not_empty($params['state'])) {
        $condition['state'] = db_quote(" AND (?:user_profiles.b_state LIKE ?l OR ?:user_profiles.s_state LIKE ?l)", "%" . trim($params['state']) . "%", "%" . trim($params['state']) . "%");
    }
    if (isset($params['city']) && fn_string_not_empty($params['city'])) {
        $condition['city'] = db_quote(" AND (?:user_profiles.b_city LIKE ?l OR ?:user_profiles.s_city LIKE ?l)", "%" . trim($params['city']) . "%", "%" . trim($params['city']) . "%");
    }
    if (!empty($params['user_id'])) {
        $condition['user_id'] = db_quote(' AND ?:users.user_id IN (?n)', $params['user_id']);
    }
    if (!empty($params['p_ids']) || !empty($params['product_view_id'])) {
        $arr = strpos($params['p_ids'], ',') !== false || !is_array($params['p_ids']) ? explode(',', $params['p_ids']) : $params['p_ids'];
        if (empty($params['product_view_id'])) {
            $condition['order_product_id'] = db_quote(" AND ?:order_details.product_id IN (?n)", $arr);
        } else {
            $condition['order_product_id'] = db_quote(" AND ?:order_details.product_id IN (?n)", db_get_fields(fn_get_products(array('view_id' => $params['product_view_id'], 'get_query' => true))));
        }
        $join .= db_quote(" LEFT JOIN ?:orders ON ?:orders.user_id = ?:users.user_id AND ?:orders.is_parent_order != 'Y' LEFT JOIN ?:order_details ON ?:order_details.order_id = ?:orders.order_id");
    }
    if (defined('RESTRICTED_ADMIN')) {
        // FIXME: NOT GOOD
        $condition['restricted_admin'] = db_quote(" AND ((?:users.user_type != 'A' AND ?:users.user_type != 'V') OR (?:users.user_type = 'A' AND ?:users.user_id = ?i))", $auth['user_id']);
    }
    // sometimes other vendor's admins could buy products from other vendors.
    if (!empty($params['user_type']) && (!($params['user_type'] == 'C' && Registry::get('runtime.company_id')) || fn_allowed_for('ULTIMATE'))) {
        $condition['user_type'] = db_quote(' AND ?:users.user_type = ?s', $params['user_type']);
    } else {
        // Get active user types
        $user_types = array_keys(fn_get_user_types());
        // Select only necessary groups frm all available
        if (!empty($params['user_types'])) {
            $user_types = array_intersect($user_types, $params['user_types']);
        }
        if (!empty($params['exclude_user_types'])) {
            $user_types = array_diff($user_types, $params['exclude_user_types']);
        }
        $condition['user_type'] = db_quote(" AND ?:users.user_type IN(?a)", $user_types);
    }
    $join .= db_quote(" LEFT JOIN ?:user_profiles ON ?:user_profiles.user_id = ?:users.user_id");
    $join .= db_quote(" LEFT JOIN ?:companies ON ?:companies.company_id = ?:users.company_id");
    /**
     * Prepare params for getting users query
     *
     * @param array $params    Params list
     * @param array $fields    Fields list
     * @param array $sortings  Sorting variants
     * @param array $condition Conditions set
     * @param str   $join      Joins list
     * @param array $auth      Auth data
     */
    fn_set_hook('get_users', $params, $fields, $sortings, $condition, $join, $auth);
    $sorting = db_sort($params, $sortings, 'name', 'asc');
    // Used for Extended search
    if (!empty($params['get_conditions'])) {
        return array($fields, $join, $condition);
    }
    // Paginate search results
    $limit = '';
    if (!empty($params['items_per_page'])) {
        $params['total_items'] = db_get_field("SELECT COUNT(DISTINCT(?:users.user_id)) FROM ?:users {$join} WHERE 1 " . implode(' ', $condition));
        $limit = db_paginate($params['page'], $params['items_per_page'], $params['total_items']);
    }
    $users = db_get_array("SELECT " . implode(', ', $fields) . " FROM ?:users {$join} WHERE 1" . implode('', $condition) . " {$group} {$sorting} {$limit}");
    LastView::instance()->processResults('users', $users, $params);
    /**
     * Actions after getting users list
     *
     * @param array $users  Users list
     * @param array $params Params list
     * @param array $auth   Auth data
     */
    fn_set_hook('get_users_post', $users, $params, $auth);
    return array($users, $params);
}
예제 #14
0
<?php

use Tygh\Registry;
if (!defined('BOOTSTRAP')) {
    die('Access denied');
}
if ($mode == 'view' && !empty($_REQUEST['product_id'])) {
    $product_id = $_REQUEST['product_id'];
    if (!empty($product_id)) {
        $catId = db_get_field('SELECT category_id FROM ?:products_categories WHERE product_id = ?i LIMIT 1', $product_id);
        if ($catId) {
            Registry::get('view')->assign('catid', $catId);
        } else {
            $catId = 0;
            Registry::get('view')->assign('catid', $catId);
        }
        list($products) = fn_get_products(array('pid' => $product_id));
        !empty($products[0]['price']) ? Registry::get('view')->assign('ra_oldPrice', $products[0]['price']) : "";
    }
}
예제 #15
0
파일: twigmo.php 프로젝트: askzap/ultimate
function fn_twg_get_product_stats_by_params($params = array())
{
    $default_params = array('only_short_fields' => true, 'extend' => array('companies', 'sharing'), 'get_conditions' => true);
    $params = array_merge($default_params, $params);
    list($fields, $join, $condition) = fn_get_products($params);
    if (isset($params['product_type'])) {
        $condition .= db_quote(' AND products.product_type=?s', $params['product_type']);
    }
    db_query('SELECT SQL_CALC_FOUND_ROWS 1 FROM ?:products AS products' . $join . ' WHERE 1 ' . $condition . 'GROUP BY products.product_id');
    return db_get_found_rows();
}
예제 #16
0
         $width[$col] = strlen($price_schema['fields'][$field]['title']) * FIELD_MWIDTH;
     }
     $col++;
 }
 $col = 'A';
 $row++;
 $page = 1;
 $total = ITEMS_PER_PAGE;
 $fill = true;
 $params = $_REQUEST;
 $params['type'] = 'extended';
 $params['subcats'] = 'N';
 $params['sort_by'] = $price_schema['fields'][Registry::get('addons.price_list.price_list_sorting')]['sort_by'];
 $params['page'] = $page;
 while (ITEMS_PER_PAGE * ($params['page'] - 1) <= $total) {
     list($products, , $total) = fn_get_products($params, ITEMS_PER_PAGE);
     $params['page']++;
     // Write products information
     foreach ($products as $product) {
         if (Registry::get('addons.price_list.include_options') == 'Y') {
             fn_gather_additional_product_data($product, true, false, true, true, true);
         } else {
             fn_gather_additional_product_data($product, true, false, false, true, true);
         }
         if (Registry::get('addons.price_list.include_options') == 'Y' && $product['has_options']) {
             $product = fn_price_list_get_combination($product);
             foreach ($product['combinations'] as $c_id => $c_value) {
                 $product['price'] = $product['combination_prices'][$c_id];
                 $product['weight'] = $product['combination_weight'][$c_id];
                 $product['amount'] = $product['combination_amount'][$c_id];
                 $product['product_code'] = $product['combination_code'][$c_id];
예제 #17
0
 public final function getOrderConditions($params)
 {
     $condition = $join = $group = '';
     if (!empty($params['cname'])) {
         $arr = explode(' ', $params['cname']);
         if (sizeof($arr) == 2) {
             $condition .= db_quote(" AND ?:orders.firstname LIKE ?l AND ?:orders.lastname LIKE ?l", "%{$arr['0']}%", "%{$arr['1']}%");
         } else {
             $condition .= db_quote(" AND (?:orders.firstname LIKE ?l OR ?:orders.lastname LIKE ?l)", "%{$params['cname']}%", "%{$params['cname']}%");
         }
     }
     if (!empty($params['tax_exempt'])) {
         $condition .= db_quote(" AND ?:orders.tax_exempt = ?s", $params['tax_exempt']);
     }
     if (!empty($params['email'])) {
         $condition .= db_quote(" AND ?:orders.email LIKE ?l", "%{$params['email']}%");
     }
     if (!empty($params['user_id'])) {
         $condition .= db_quote(' AND ?:orders.user_id IN (?n)', $params['user_id']);
     }
     if (!empty($params['total_from'])) {
         $condition .= db_quote(" AND ?:orders.total >= ?d", fn_convert_price($params['total_from']));
     }
     if (!empty($params['total_to'])) {
         $condition .= db_quote(" AND ?:orders.total <= ?d", fn_convert_price($params['total_to']));
     }
     if (!empty($params['status'])) {
         $condition .= db_quote(' AND ?:orders.status IN (?a)', $params['status']);
     }
     if (!empty($params['order_id'])) {
         $multiple_ids = strpos($params['order_id'], ',') !== false;
         $condition .= db_quote(' AND ?:orders.order_id IN (?n)', !is_array($params['order_id']) && $multiple_ids ? explode(',', $params['order_id']) : $params['order_id']);
     }
     if (!empty($params['p_ids']) || !empty($params['product_view_id'])) {
         $multiple_ids = strpos($params['p_ids'], ',') !== false;
         $arr = $multiple_ids || !is_array($params['p_ids']) ? explode(',', $params['p_ids']) : $params['p_ids'];
         if (empty($params['product_view_id'])) {
             $condition .= db_quote(" AND ?:order_details.product_id IN (?n)", $arr);
         } else {
             $condition .= db_quote(" AND ?:order_details.product_id IN (?n)", db_get_fields(fn_get_products(array('view_id' => $params['product_view_id'], 'get_query' => true))));
         }
         $join .= " LEFT JOIN ?:order_details ON ?:order_details.order_id = ?:orders.order_id";
     }
     if (!empty($params['admin_user_id'])) {
         $condition .= db_quote(" AND ?:new_orders.user_id = ?i", $params['admin_user_id']);
         $join .= " LEFT JOIN ?:new_orders ON ?:new_orders.order_id = ?:orders.order_id";
     }
     if (!empty($params['shippings'])) {
         $set_conditions = array();
         foreach ($params['shippings'] as $v) {
             $set_conditions[] = db_quote("FIND_IN_SET(?s, ?:orders.shipping_ids)", $v);
         }
         $condition .= " AND (" . implode(' OR ', $set_conditions) . ")";
     }
     if (!empty($params['period']) && $params['period'] != 'A') {
         list($params['time_from'], $params['time_to']) = fn_create_periods($params);
         $condition .= db_quote(" AND (?:orders.timestamp >= ?i AND ?:orders.timestamp <= ?i)", $params['time_from'], $params['time_to']);
     }
     if (!empty($params['custom_files']) && $params['custom_files'] == 'Y') {
         $condition .= db_quote(" AND ?:order_details.extra LIKE ?l", "%custom_files%");
         if (empty($params['p_ids']) && empty($params['product_view_id'])) {
             $join .= " LEFT JOIN ?:order_details ON ?:order_details.order_id = ?:orders.order_id";
         }
     }
     return array($condition, $join);
 }
예제 #18
0
/**
 * Fills sequential options with default values. Necessary for cart total calculation
 *
 * @param array $item Cart item
 * @param int $changed_option Changed option identifier
 * @return array New options list
 */
function fn_fill_sequential_options($item, $changed_option)
{
    $params['pid'] = $item['product_id'];
    list($product) = fn_get_products($params);
    $product = reset($product);
    $product['changed_option'] = $changed_option;
    $product['selected_options'] = $item['product_options'];
    fn_gather_additional_product_data($product, false, false, true, false, false);
    if (count($item['product_options']) != count($product['selected_options'])) {
        foreach ($item['product_options'] as $option_id => $variant_id) {
            if (isset($product['selected_options'][$option_id]) || in_array($product['product_options'][$option_id]['option_type'], array('I', 'T', 'F'))) {
                continue;
            }
            if (!empty($product['product_options'][$option_id]['variants'])) {
                reset($product['product_options'][$option_id]['variants']);
                $variant_id = key($product['product_options'][$option_id]['variants']);
            } else {
                $variant_id = '';
            }
            $product['selected_options'][$option_id] = $variant_id;
            $product['changed_option'] = $option_id;
            fn_gather_additional_product_data($product, false, false, true, false, false);
        }
    }
    return $product['selected_options'];
}
예제 #19
0
    die('Access denied');
}
if ($mode == 'get_info') {
    if (empty($_REQUEST['count'])) {
        $count = 4;
    } else {
        $count = $_REQUEST['count'];
    }
    if (empty($_REQUEST['orientation'])) {
        $orientation = 'horizontal';
    } else {
        $orientation = $_REQUEST['orientation'];
    }
    $ids = array_slice(array_map('intval', $_REQUEST['product_ids']), 0, $count);
    if (count($ids) == $count) {
        list($products, $search) = fn_get_products(array('pid' => $ids, 'rees46_type' => $_REQUEST['recommended_by']));
        fn_gather_additional_products_data($products, array('get_icon' => false, 'get_detailed' => true, 'get_additional' => false, 'get_options' => false));
    } else {
        $products = array();
    }
    Registry::get('view')->assign('rees46_products', $products);
    Registry::get('view')->assign('rees46_type', $_REQUEST['recommended_by']);
    Registry::get('view')->assign('rees46_title', $_REQUEST['title']);
    Registry::get('view')->assign('rees46_count', $count);
    Registry::get('view')->assign('rees46_block_orientation', $orientation);
    Registry::get('view')->display('addons/rees46/blocks/recommenders.tpl');
    exit;
}
if ($mode == 'yml') {
    $filename = Registry::get('config.dir.cache_misc') . 'rees46.yml';
    require_once 'rees46_yml.php';
예제 #20
0
//
// 'Management' page
//
if ($mode == 'manage' || $mode == 'p_subscr') {
    unset($_SESSION['product_ids']);
    unset($_SESSION['selected_fields']);
    $params = $_REQUEST;
    $params['only_short_fields'] = true;
    $params['extend'][] = 'companies';
    if (fn_allowed_for('ULTIMATE')) {
        $params['extend'][] = 'sharing';
    }
    if ($mode == 'p_subscr') {
        $params['get_subscribers'] = true;
    }
    list($products, $search) = fn_get_products($params, Registry::get('settings.Appearance.admin_products_per_page'), DESCR_SL);
    fn_gather_additional_products_data($products, array('get_icon' => true, 'get_detailed' => true, 'get_options' => false, 'get_discounts' => false));
    $page = $search['page'];
    $valid_page = db_get_valid_page($page, $search['items_per_page'], $search['total_items']);
    if ($page > $valid_page) {
        $_REQUEST['page'] = $valid_page;
        return array(CONTROLLER_STATUS_REDIRECT, Registry::get('config.current_url'));
    }
    Tygh::$app['view']->assign('products', $products);
    Tygh::$app['view']->assign('search', $search);
    if (!empty($_REQUEST['redirect_if_one']) && $search['total_items'] == 1) {
        return array(CONTROLLER_STATUS_REDIRECT, 'products.update?product_id=' . $products[0]['product_id']);
    }
    $selected_fields = fn_get_product_fields();
    Tygh::$app['view']->assign('selected_fields', $selected_fields);
    if (!fn_allowed_for('ULTIMATE:FREE')) {
예제 #21
0
/**
 * Gets categefories and products totals data
 *
 * @return array Array with categories and products totals
 */
function fn_get_categories_stats()
{
    $stats = array();
    $params = array('only_short_fields' => true, 'extend' => array('companies', 'sharing'), 'get_conditions' => true);
    list($fields, $join, $condition) = fn_get_products($params);
    db_query('SELECT SQL_CALC_FOUND_ROWS 1 FROM ?:products AS products' . $join . ' WHERE 1 ' . $condition . 'GROUP BY products.product_id');
    $stats['products_total'] = db_get_found_rows();
    $params = array('get_conditions' => true);
    list($fields, $join, $condition, $group_by, $sorting, $limit) = fn_get_categories($params);
    $stats['categories_total'] = db_get_field('SELECT COUNT(*) FROM ?:categories WHERE 1 ?p', $condition);
    $params = array('get_conditions' => true, 'status' => 'A');
    list($fields, $join, $condition, $group_by, $sorting, $limit) = fn_get_categories($params);
    $stats['categories_active'] = db_get_field('SELECT COUNT(*) FROM ?:categories WHERE 1 ?p', $condition);
    $params = array('get_conditions' => true, 'status' => 'H');
    list($fields, $join, $condition, $group_by, $sorting, $limit) = fn_get_categories($params);
    $stats['categories_hidden'] = db_get_field('SELECT COUNT(*) FROM ?:categories WHERE 1 ?p', $condition);
    $params = array('get_conditions' => true, 'status' => 'D');
    list($fields, $join, $condition, $group_by, $sorting, $limit) = fn_get_categories($params);
    $stats['categories_disabled'] = db_get_field('SELECT COUNT(*) FROM ?:categories WHERE 1 ?p', $condition);
    return $stats;
}
예제 #22
0
function fn_get_shipments_info($params, $items_per_page = 0)
{
    // Init view params
    $params = LastView::instance()->update('shipments', $params);
    // Set default values to input params
    $default_params = array('page' => 1, 'items_per_page' => $items_per_page);
    $params = array_merge($default_params, $params);
    $fields_list = array('?:shipments.shipment_id', '?:shipments.timestamp AS shipment_timestamp', '?:shipments.comments', '?:shipment_items.order_id', '?:orders.timestamp AS order_timestamp', '?:orders.s_firstname', '?:orders.s_lastname', '?:orders.user_id');
    $joins = array('LEFT JOIN ?:shipment_items ON (?:shipments.shipment_id = ?:shipment_items.shipment_id)', 'LEFT JOIN ?:orders ON (?:shipment_items.order_id = ?:orders.order_id)');
    $condition = '';
    if (Registry::get('runtime.company_id')) {
        $joins[] = 'LEFT JOIN ?:companies ON (?:companies.company_id = ?:orders.company_id)';
        $condition = db_quote(' AND ?:companies.company_id = ?i', Registry::get('runtime.company_id'));
    }
    $group = array('?:shipments.shipment_id');
    // Define sort fields
    $sortings = array('id' => "?:shipments.shipment_id", 'order_id' => "?:orders.order_id", 'shipment_date' => "?:shipments.timestamp", 'order_date' => "?:orders.timestamp", 'customer' => array("?:orders.s_lastname", "?:orders.s_firstname"));
    $sorting = db_sort($params, $sortings, 'id', 'desc');
    if (isset($params['advanced_info']) && $params['advanced_info']) {
        $fields_list[] = '?:shipments.shipping_id';
        $fields_list[] = '?:shipping_descriptions.shipping AS shipping';
        $fields_list[] = '?:shipments.tracking_number';
        $fields_list[] = '?:shipments.carrier';
        $joins[] = ' LEFT JOIN ?:shippings ON (?:shipments.shipping_id = ?:shippings.shipping_id)';
        $joins[] = db_quote(' LEFT JOIN ?:shipping_descriptions ON (?:shippings.shipping_id = ?:shipping_descriptions.shipping_id AND ?:shipping_descriptions.lang_code = ?s)', DESCR_SL);
    }
    if (!empty($params['order_id'])) {
        $condition .= db_quote(' AND ?:shipment_items.order_id = ?i', $params['order_id']);
    }
    if (!empty($params['shipment_id'])) {
        $condition .= db_quote(' AND ?:shipments.shipment_id = ?i', $params['shipment_id']);
    }
    if (isset($params['cname']) && fn_string_not_empty($params['cname'])) {
        $arr = fn_explode(' ', $params['cname']);
        foreach ($arr as $k => $v) {
            if (!fn_string_not_empty($v)) {
                unset($arr[$k]);
            }
        }
        if (sizeof($arr) == 2) {
            $condition .= db_quote(" AND ?:orders.firstname LIKE ?l AND ?:orders.lastname LIKE ?l", "%" . array_shift($arr) . "%", "%" . array_shift($arr) . "%");
        } else {
            $condition .= db_quote(" AND (?:orders.firstname LIKE ?l OR ?:orders.lastname LIKE ?l)", "%" . trim($params['cname']) . "%", "%" . trim($params['cname']) . "%");
        }
    }
    if (!empty($params['p_ids']) || !empty($params['product_view_id'])) {
        $arr = strpos($params['p_ids'], ',') !== false || !is_array($params['p_ids']) ? explode(',', $params['p_ids']) : $params['p_ids'];
        if (empty($params['product_view_id'])) {
            $condition .= db_quote(" AND ?:shipment_items.product_id IN (?n)", $arr);
        } else {
            $condition .= db_quote(" AND ?:shipment_items.product_id IN (?n)", db_get_fields(fn_get_products(array('view_id' => $params['product_view_id'], 'get_query' => true)), ','));
        }
        $joins[] = "LEFT JOIN ?:order_details ON ?:order_details.order_id = ?:orders.order_id";
    }
    if (!empty($params['shipment_period']) && $params['shipment_period'] != 'A') {
        $params['time_from'] = $params['shipment_time_from'];
        $params['time_to'] = $params['shipment_time_to'];
        $params['period'] = $params['shipment_period'];
        list($params['shipment_time_from'], $params['shipment_time_to']) = fn_create_periods($params);
        $condition .= db_quote(" AND (?:shipments.timestamp >= ?i AND ?:shipments.timestamp <= ?i)", $params['shipment_time_from'], $params['shipment_time_to']);
    }
    if (!empty($params['order_period']) && $params['order_period'] != 'A') {
        $params['time_from'] = $params['order_time_from'];
        $params['time_to'] = $params['order_time_to'];
        $params['period'] = $params['order_period'];
        list($params['order_time_from'], $params['order_time_to']) = fn_create_periods($params);
        $condition .= db_quote(" AND (?:orders.timestamp >= ?i AND ?:orders.timestamp <= ?i)", $params['order_time_from'], $params['order_time_to']);
    }
    fn_set_hook('get_shipments', $params, $fields_list, $joins, $condition, $group);
    $fields_list = implode(', ', $fields_list);
    $joins = implode(' ', $joins);
    $group = implode(', ', $group);
    if (!empty($group)) {
        $group = ' GROUP BY ' . $group;
    }
    $limit = '';
    if (!empty($params['items_per_page'])) {
        $params['total_items'] = db_get_field("SELECT COUNT(DISTINCT(?:shipments.shipment_id)) FROM ?:shipments {$joins} WHERE 1 {$condition}");
        $limit = db_paginate($params['page'], $params['items_per_page'], $params['total_items']);
    }
    $shipments = db_get_array("SELECT {$fields_list} FROM ?:shipments {$joins} WHERE 1 {$condition} {$group} {$sorting} {$limit}");
    if (isset($params['advanced_info']) && $params['advanced_info'] && !empty($shipments)) {
        $shipment = reset($shipments);
        $order_info = fn_get_order_info($shipment['order_id']);
        foreach ($shipments as $id => $shipment) {
            $items = db_get_array('SELECT item_id, amount FROM ?:shipment_items WHERE shipment_id = ?i', $shipment['shipment_id']);
            if (!empty($items)) {
                foreach ($items as $item) {
                    $shipments[$id]['products'][$item['item_id']] = $item['amount'];
                    if (!empty($order_info['products'][$item['item_id']]['extra']['group_key'])) {
                        $shipments[$id]['group_key'] = $order_info['products'][$item['item_id']]['extra']['group_key'];
                    } else {
                        $shipments[$id]['group_key'] = 0;
                    }
                }
            }
        }
        if (Settings::instance()->getValue('use_shipments', '', $order_info['company_id']) != 'Y') {
            foreach ($shipments as $id => $shipment) {
                $shipments[$id]['one_full'] = true;
                foreach ($order_info['products'] as $product_key => $product) {
                    $group_key = !empty($product['extra']['group_key']) ? $product['extra']['group_key'] : 0;
                    if ($shipment['group_key'] == $group_key) {
                        if (empty($shipment['products'][$product_key]) || $shipment['products'][$product_key] < $product['amount']) {
                            $shipments[$id]['one_full'] = false;
                            break;
                        }
                    }
                }
            }
        }
    }
    /**
     * Changes selected shipments
     *
     * @param array $shipments Array of shipments
     * @param array $params    Shipments search params
     */
    fn_set_hook('get_shipments_info_post', $shipments, $params);
    LastView::instance()->processResults('shipments_info', $shipments, $params);
    return array($shipments, $params);
}
예제 #23
0
function fn_get_rma_returns($params, $items_per_page = 0)
{
    // Init filter
    $params = LastView::instance()->update('rma', $params);
    // Set default values to input params
    $default_params = array('page' => 1, 'items_per_page' => $items_per_page);
    $params = array_merge($default_params, $params);
    // Define fields that should be retrieved
    $fields = array('DISTINCT ?:rma_returns.return_id', '?:rma_returns.order_id', '?:rma_returns.timestamp', '?:rma_returns.status', '?:rma_returns.total_amount', '?:rma_property_descriptions.property AS action', '?:users.firstname', '?:users.lastname');
    // Define sort fields
    $sortings = array('return_id' => "?:rma_returns.return_id", 'timestamp' => "?:rma_returns.timestamp", 'order_id' => "?:rma_returns.order_id", 'status' => "?:rma_returns.status", 'amount' => "?:rma_returns.total_amount", 'action' => "?:rma_returns.action", 'customer' => "?:users.lastname");
    $sorting = db_sort($params, $sortings, 'timestamp', 'desc');
    $join = $condition = $group = '';
    if (isset($params['cname']) && fn_string_not_empty($params['cname'])) {
        $arr = fn_explode(' ', $params['cname']);
        foreach ($arr as $k => $v) {
            if (!fn_string_not_empty($v)) {
                unset($arr[$k]);
            }
        }
        if (sizeof($arr) == 2) {
            $condition .= db_quote(" AND ?:users.firstname LIKE ?l AND ?:users.lastname LIKE ?l", "%" . array_shift($arr) . "%", "%" . array_shift($arr) . "%");
        } else {
            $condition .= db_quote(" AND (?:users.firstname LIKE ?l OR ?:users.lastname LIKE ?l)", "%" . trim($params['cname']) . "%", "%" . trim($params['cname']) . "%");
        }
    }
    if (isset($params['email']) && fn_string_not_empty($params['email'])) {
        $condition .= db_quote(" AND ?:users.email LIKE ?l", "%" . trim($params['email']) . "%");
    }
    if (isset($params['rma_amount_from']) && fn_is_numeric($params['rma_amount_from'])) {
        $condition .= db_quote("AND ?:rma_returns.total_amount >= ?d", $params['rma_amount_from']);
    }
    if (isset($params['rma_amount_to']) && fn_is_numeric($params['rma_amount_to'])) {
        $condition .= db_quote("AND ?:rma_returns.total_amount <= ?d", $params['rma_amount_to']);
    }
    if (!empty($params['action'])) {
        $condition .= db_quote(" AND ?:rma_returns.action = ?s", $params['action']);
    }
    if (!empty($params['return_id'])) {
        $condition .= db_quote(" AND ?:rma_returns.return_id = ?i", $params['return_id']);
    }
    if (!empty($params['request_status'])) {
        $condition .= db_quote(" AND ?:rma_returns.status IN (?a)", $params['request_status']);
    }
    if (!empty($params['period']) && $params['period'] != 'A') {
        list($params['time_from'], $params['time_to']) = fn_create_periods($params);
        $condition .= db_quote(" AND (?:rma_returns.timestamp >= ?i AND ?:rma_returns.timestamp <= ?i)", $params['time_from'], $params['time_to']);
    }
    if (!empty($params['order_id'])) {
        $condition .= db_quote(" AND ?:rma_returns.order_id = ?i", $params['order_id']);
    }
    if (isset($params['user_id'])) {
        $condition .= db_quote(" AND ?:rma_returns.user_id = ?i", $params['user_id']);
    }
    if (!empty($params['order_status'])) {
        $condition .= db_quote(" AND ?:orders.status IN (?a)", $params['order_status']);
    }
    if (!empty($params['p_ids']) || !empty($params['product_view_id'])) {
        $arr = strpos($params['p_ids'], ',') !== false || !is_array($params['p_ids']) ? explode(',', $params['p_ids']) : $params['p_ids'];
        if (empty($params['product_view_id'])) {
            $condition .= db_quote(" AND ?:order_details.product_id IN (?n)", $arr);
        } else {
            $condition .= db_quote(" AND ?:order_details.product_id IN (?n)", db_get_fields(fn_get_products(array('view_id' => $params['product_view_id'], 'get_query' => true))));
        }
        $join .= " LEFT JOIN ?:order_details ON ?:order_details.order_id = ?:orders.order_id";
        $group .= db_quote(" GROUP BY ?:rma_returns.return_id HAVING COUNT(?:orders.order_id) >= ?i", count($arr));
    }
    $limit = '';
    if (!empty($params['items_per_page'])) {
        $params['total_items'] = db_get_field("SELECT COUNT(DISTINCT ?:rma_returns.return_id) FROM ?:rma_returns LEFT JOIN ?:rma_return_products ON ?:rma_return_products.return_id = ?:rma_returns.return_id LEFT JOIN ?:rma_property_descriptions ON ?:rma_property_descriptions.property_id = ?:rma_returns.action LEFT JOIN ?:users ON ?:rma_returns.user_id = ?:users.user_id LEFT JOIN ?:orders ON ?:rma_returns.order_id = ?:orders.order_id {$join} WHERE 1 {$condition} {$group}");
        $limit = db_paginate($params['page'], $params['items_per_page'], $params['total_items']);
    }
    $return_requests = db_get_array("SELECT " . implode(', ', $fields) . " FROM ?:rma_returns LEFT JOIN ?:rma_return_products ON ?:rma_return_products.return_id = ?:rma_returns.return_id LEFT JOIN ?:rma_property_descriptions ON (?:rma_property_descriptions.property_id = ?:rma_returns.action AND ?:rma_property_descriptions.lang_code = ?s) LEFT JOIN ?:users ON ?:rma_returns.user_id = ?:users.user_id LEFT JOIN ?:orders ON ?:rma_returns.order_id = ?:orders.order_id {$join} WHERE 1 {$condition} {$group} {$sorting} {$limit}", AREA == 'C' ? CART_LANGUAGE : DESCR_SL);
    LastView::instance()->processResults('rma_returns', $return_requests, $params);
    return array($return_requests, $params);
}
예제 #24
0
/**
 * Creates condition for product search
 *
 * @param array $params List of search parameters
 * @param string $lang_code 2-letter language code
 * @return array Prepared data
 */
function fn_create_products_condition($params, $lang_code = CART_LANGUAGE)
{
    /**
     * Modify search parameters defined in fn_search_register_object
     *
     * @param array  $params    List of search parameters
     * @param string $lang_code 2-letter language code
     */
    fn_set_hook('create_products_condition_pre', $params, $lang_code);
    $params['get_conditions'] = true;
    if (AREA == 'A') {
        $params['pcode_from_q'] = 'Y';
        $params['pid'] = $params['q'];
    }
    list($fields, $join, $condition) = fn_get_products($params, 0, $lang_code);
    $data = array('fields' => $fields, 'join' => $join, 'condition' => '1 ' . $condition, 'table' => 'products', 'key' => 'product_id', 'sort' => 'descr1.product', 'sort_table' => 'product_descriptions');
    /**
     * Modify prepared data
     *
     * @param array  $params    List of search parameters
     * @param string $lang_code 2-letter language code
     * @param array  $data      Result search scheme
     */
    fn_set_hook('create_products_condition_post', $params, $lang_code, $data);
    return $data;
}
예제 #25
0
     $stats .= base64_decode('PGltZyBzcmM9Imh0dHA6Ly93d3cuY3MtY2FydC5jb20vaW1hZ2VzL2JhY2tncm91bmQuZ2lmIiBoZWlnaHQ9IjEiIHdpZHRoPSIxIiBhbHQ9IiIgLz4=');
 }
 $general_stats = array();
 /* Products */
 if (fn_check_view_permissions('products.manage', 'GET')) {
     $general_stats['products'] = array();
     $params = array('only_short_fields' => true, 'extend' => array('companies', 'sharing'), 'status' => 'A', 'get_conditions' => true);
     list($fields, $join, $condition) = fn_get_products($params);
     db_query('SELECT SQL_CALC_FOUND_ROWS 1 FROM ?:products AS products' . $join . ' WHERE 1 ' . $condition . 'GROUP BY products.product_id');
     $general_stats['products']['total_products'] = db_get_found_rows();
     $params = array('amount_to' => 0, 'tracking' => array('B', 'O'), 'get_conditions' => true);
     $params['extend'][] = 'companies';
     if (fn_allowed_for('ULTIMATE')) {
         $params['extend'][] = 'sharing';
     }
     list($fields, $join, $condition) = fn_get_products($params);
     db_query('SELECT SQL_CALC_FOUND_ROWS ' . implode(', ', $fields) . ' FROM ?:products AS products' . $join . ' WHERE 1 ' . $condition . ' GROUP BY products.product_id');
     $general_stats['products']['out_of_stock_products'] = db_get_found_rows();
 }
 /* Customers */
 if (fn_check_view_permissions('profiles.manage', 'GET')) {
     $general_stats['customers'] = array();
     $users_company_condition = fn_get_company_condition('?:users.company_id');
     $general_stats['customers']['registered_customers'] = db_get_field('SELECT COUNT(*) FROM ?:users WHERE user_type = ?s ?p', 'C', $users_company_condition);
 }
 /* Categories */
 if (fn_check_view_permissions('categories.manage', 'GET')) {
     $general_stats['categories'] = array();
     list($fields, $join, $condition, $group_by, $sorting, $limit) = fn_get_categories(array('get_conditions' => true));
     $general_stats['categories']['total_categories'] = db_get_field('SELECT COUNT(*) FROM ?:categories WHERE 1 ?p', $condition);
 }
예제 #26
0
*                                                                          *
****************************************************************************
* PLEASE READ THE FULL TEXT  OF THE SOFTWARE  LICENSE   AGREEMENT  IN  THE *
* "copyright.txt" FILE PROVIDED WITH THIS DISTRIBUTION PACKAGE.            *
****************************************************************************/
//
// $Id: xml_feeds.php 10229 2010-07-27 14:21:39Z 2tl $
//
if (!defined('AREA')) {
    die('Access denied');
}
$xml = '<?xml version="1.0" encoding="' . CHARSET . '"?>';
// Products management
if ($mode == 'get_products') {
    $_REQUEST['type'] = empty($_REQUEST['type']) ? 'extended' : $_REQUEST['type'];
    list($products) = fn_get_products($_REQUEST, Registry::get('settings.Appearance.products_per_page'));
    if (!empty($products)) {
        foreach ($products as $k => $v) {
            fn_gather_additional_product_data($products[$k], true);
        }
    }
    $xml .= fn_array_to_xml($products, 'products');
}
//
// View product details
//
if ($mode == 'get_product') {
    $_REQUEST['product_id'] = empty($_REQUEST['product_id']) ? 0 : $_REQUEST['product_id'];
    $product = fn_get_product_data($_REQUEST['product_id'], $auth, CART_LANGUAGE);
    if (!empty($product)) {
        if (!empty($_REQUEST['combination'])) {
예제 #27
0
function fn_se_get_products_data($product_ids, $company_id = 0, $lang_code = NULL, $fl_echo = true)
{
    $xml = '';
    $products = array();
    if (!empty($product_ids)) {
        list($products) = fn_get_products(array('disable_searchanise' => true, 'area' => 'A', 'sort_by' => 'null', 'pid' => $product_ids, 'extend' => array('description', 'search_words', 'popularity', 'sales')), 0, $lang_code);
    }
    if ($fl_echo) {
        fn_echo('.');
    }
    if (!empty($products)) {
        foreach ($products as &$_product) {
            $_product['exclude_from_calculate'] = true;
            //pass additional params to fn_gather_additional_products_data for some speed up
        }
        fn_gather_additional_products_data($products, array('get_features' => false, 'get_icon' => true, 'get_detailed' => true, 'get_options' => false, 'get_discounts' => false, 'get_taxed_prices' => false));
        if ($fl_echo) {
            fn_echo('.');
        }
        if (!fn_allowed_for('ULTIMATE:FREE')) {
            $usergroups = empty($usergroups) ? array_merge(fn_get_default_usergroups(), db_get_hash_array("SELECT a.usergroup_id, a.status, a.type FROM ?:usergroups as a WHERE a.type = 'C' ORDER BY a.usergroup_id", 'usergroup_id')) : $usergroups;
        } else {
            $usergroups = array();
        }
        fn_se_get_products_additionals($products, $company_id, $lang_code);
        fn_se_get_products_features($products, $company_id, $lang_code);
        $schema = $items = array();
        foreach ($products as $product) {
            $item = array();
            $data = fn_se_prepare_product_data($product, $usergroups, $company_id, $lang_code);
            foreach ($data as $name => $d) {
                $name = isset($d['name']) ? $d['name'] : $name;
                $item[$name] = $d['value'];
                unset($d['value']);
                if (!empty($d)) {
                    $schema[$name] = $d;
                }
            }
            $items[] = $item;
        }
    }
    return array('schema' => $schema, 'items' => $items);
}
예제 #28
0
파일: pdf.php 프로젝트: askzap/ultimate
     $tbl .= '<td style="font-size: ' . FIELDS_HEADER_FONT_SIZE . ';" width="' . $price_schema['fields'][$field_name]['min_width'] . '%"><strong>' . $price_schema['fields'][$field_name]['title'] . '</strong></td>';
 }
 $tbl .= '</tr>';
 $tbl .= '</table>';
 Pdf::batchAdd($tbl);
 $page = 1;
 $total = ITEMS_PER_PAGE;
 $fill = true;
 $params = $_REQUEST;
 $params['sort_by'] = $price_schema['fields'][Registry::get('addons.price_list.price_list_sorting')]['sort_by'];
 $params['page'] = $page;
 $params['skip_view'] = 'Y';
 $params['cid'] = $category['category_id'];
 $params['subcats'] = 'N';
 while (ITEMS_PER_PAGE * ($params['page'] - 1) <= $total) {
     list($products, $search) = fn_get_products($params, ITEMS_PER_PAGE);
     $total = $search['total_items'];
     $_params = array('get_icon' => true, 'get_detailed' => true, 'get_options' => Registry::get('addons.price_list.include_options') == 'Y' ? true : false, 'get_discounts' => false);
     fn_gather_additional_products_data($products, $_params);
     $params['page']++;
     $tbl = '<table border="0" cellpadding="' . TABLE_CELLPADDING . '" cellspacing="' . TABLE_CELLSPACING . '" width="100%">';
     // Write products information
     foreach ($products as $product) {
         if ($fill) {
             $style = 'style="background-color: ' . FIELDS_ODD_BG_COLOR . '"';
         } else {
             $style = '';
         }
         if (Registry::get('addons.price_list.include_options') == 'Y' && $product['has_options']) {
             $product = fn_price_list_get_combination($product);
             foreach ($product['combinations'] as $c_id => $c_value) {
예제 #29
0
    } elseif ($mode == 'on_sale') {
        $title = __("on_sale");
        $params['on_sale'] = true;
    } elseif ($mode == 'bestsellers') {
        $title = __("bestsellers");
        $params['bestsellers'] = true;
        $params['sales_amount_from'] = Registry::get('addons.bestsellers.sales_amount_from');
    } elseif ($mode == 'newest') {
        $title = __("newest");
        $params['sort_by'] = empty($params['sort_by']) ? 'timestamp' : $params['sort_by'];
        $params['plain'] = true;
        $params['visible'] = true;
        $period = Registry::get('addons.bestsellers.period');
        $params['period'] = 'A';
        if ($period == 'today') {
            $params['period'] = 'D';
        } elseif ($period == 'last_days') {
            $params['period'] = 'HC';
            $params['last_days'] = Registry::get('addons.bestsellers.last_days');
        }
    } else {
        $title = __('products');
    }
    fn_add_breadcrumb($title);
    list($products, $search) = fn_get_products($params, Registry::get('settings.Appearance.products_per_page'));
    fn_gather_additional_products_data($products, array('get_icon' => true, 'get_detailed' => true, 'get_additional' => true, 'get_options' => true));
    $selected_layout = fn_get_products_layout($params);
    Registry::get('view')->assign('products', $products);
    Registry::get('view')->assign('search', $search);
    Registry::get('view')->assign('selected_layout', $selected_layout);
}
예제 #30
0
                $display_tpl = 'views/checkout/components/cart_items.tpl';
            } else {
                $display_tpl = 'views/order_management/products.tpl';
            }
        }
        $data = isset($product_data) ? $product_data : $cart_products;
        fn_set_hook('after_options_calculation', $mode, $data);
        $view->display($display_tpl);
        exit;
    }
}
if ($mode == 'picker') {
    $params = $_REQUEST;
    $params['type'] = 'extended';
    $params['skip_view'] = 'Y';
    list($products, $search) = fn_get_products($params, AREA == 'C' ? Registry::get('settings.Appearance.products_per_page') : Registry::get('settings.Appearance.admin_products_per_page'));
    if (!empty($_REQUEST['display']) || AREA == 'C' && !defined('EVENT_OWNER')) {
        foreach ($products as $k => $v) {
            fn_gather_additional_product_data($products[$k], true, true, true, true);
        }
    }
    if (!empty($products)) {
        foreach ($products as $k => $v) {
            $products[$k]['options'] = fn_get_product_options($v['product_id'], DESCR_SL, true, false, true);
            $products[$k]['exceptions'] = fn_get_product_exceptions($v['product_id']);
            if (!empty($products[$k]['exceptions'])) {
                foreach ($products[$k]['exceptions'] as $v) {
                    $products[$k]['exception_combinations'][fn_get_options_combination($v['combination'])] = '';
                }
            }
        }