예제 #1
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();
     }
 }
예제 #2
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';
        }
    }
}
예제 #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
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';
        }
    }
}
예제 #5
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);
}
예제 #6
0
function fn_mailru_prepare_offer($products, $options, $enclosure)
{
    //array error
    $error_products = array('products_zero_price' => '', 'disabled_products' => '', 'out_of_stock' => '', 'empty_brand' => '', 'empty_model' => '', 'disable_cat_list' => '', 'disable_cat_list_d' => '');
    //data addons mail
    $addon_settings = Registry::get('addons.rus_tovary_mailru');
    $delivery_type = $addon_settings['delivery_type'];
    list($products, $product_ids) = fn_mailru_filter_products($products, $addon_settings, $error_products);
    if (empty($products)) {
        return true;
    }
    //category
    $visible_categories = fn_mailru_get_visible_categories($addon_settings);
    $fields = array('p.product_id', 'p.mailru_brand', 'p.mailru_model', 'p.mailru_delivery', 'p.mailru_pickup', 'p.mailru_cost', 'p.mailru_type_prefix', 'p.mailru_mcp');
    $fields[] = "(\n        SELECT GROUP_CONCAT(IF(pc2.link_type = 'M', CONCAT(pc2.category_id, 'M'), pc2.category_id))\n        FROM ?:products_categories as pc2\n        WHERE product_id = p.product_id\n    ) as category_ids";
    $mailru_products = db_get_hash_array('SELECT ' . implode(', ', $fields) . ' FROM ?:products as p WHERE product_id IN (?n)', 'product_id', $product_ids);
    $products_zero_price = '';
    foreach ($products as $key => $product) {
        $products[$key]['category_ids'] = $mailru_products[$product['product_id']]['category_ids'];
    }
    $params = array('get_options' => false, 'get_taxed_prices' => false, 'detailed_params' => false);
    fn_gather_additional_products_data($products, $params);
    foreach ($products as $data) {
        $yml = array();
        if ($data['status'] != 'A') {
            continue;
        }
        if ($addon_settings['disable_cat_d'] == "Y") {
            if (!in_array($data['category'], $visible_categories)) {
                $error_products['disable_cat_list_d'] .= $data['product_name'] . ', ';
                continue;
            }
        }
        $avail = fn_is_accessible_product(array('product_id' => $data['product_id'])) ? 'true' : 'false';
        $currency = Registry::get('currencies.' . CART_PRIMARY_CURRENCY);
        $data['price'] = !empty($data['price']) ? $data['price'] : $data['price'];
        $data['price'] = fn_format_price($data['price'], $currency['currency_code'], $currency['decimals'], false);
        if (CART_PRIMARY_CURRENCY != "RUB") {
            $currencies = Registry::get('currencies');
            if (isset($currencies['RUB'])) {
                $currency = $currencies['RUB'];
                $price = fn_format_rate_value($data['price'], 'F', $currency['decimals'], $currency['decimals_separator'], $currency['thousands_separator'], $currency['coefficient']);
            } else {
                $price = $data['price'];
            }
            $price = !floatval($price) ? fn_parse_price($price) : $price;
            $delivery_cost = fn_mailru_format_price($mailru_products[$data['product_id']]['mailru_cost'], "RUB");
            $delivery_cost = !floatval($delivery_cost) ? fn_parse_price($delivery_cost) : $delivery_cost;
        } else {
            $price = !floatval($data['price']) ? fn_parse_price($data['price']) : $data['price'];
            $delivery_cost = !floatval($mailru_products[$data['product_id']]['mailru_cost']) ? fn_parse_price($mailru_products[$data['product_id']]['mailru_cost']) : $mailru_products[$data['product_id']]['mailru_cost'];
        }
        if (empty($price)) {
            $products_zero_price .= $data['product'] . ', ';
            continue;
        }
        $brand = fn_mailru_get_brand($data, $mailru_products[$data['product_id']], $addon_settings);
        $url = fn_url($data['product_url']);
        $url = htmlentities($url);
        $offer_attrs = '';
        if (!empty($mailru_products[$data['product_id']]['mailru_mcp'])) {
            $offer_attrs .= '@cbid=' . $mailru_products[$data['product_id']]['mailru_mcp'];
        }
        if (CART_PRIMARY_CURRENCY == "RUB") {
            $currency_id = "RUR";
        } elseif (CART_PRIMARY_CURRENCY == "EUR") {
            $currency_id = "EURO";
        } else {
            $currency_id = CART_PRIMARY_CURRENCY;
        }
        $image_url = fn_tovary_mailru_c_encode($data['image_url']);
        $s = urlencode("–");
        $image_url = str_replace("–", $s, $image_url);
        $yml['url'] = $url;
        $yml['price'] = $price;
        $yml['currencyId'] = $currency_id;
        $yml['categoryId'] = $data['category'];
        if (!empty($image_url)) {
            $yml['picture'] = $image_url;
        }
        if ($addon_settings['mail_settings'] == "type_name") {
            $yml['name'] = htmlspecialchars($data['product_name']);
        } elseif ($addon_settings['mail_settings'] == "type_detailed" && !empty($mailru_products[$data['product_id']]['mailru_model'])) {
            if ($addon_settings['type_prefix'] == "Y") {
                if (!empty($mailru_products[$data['product_id']]['mailru_type_prefix'])) {
                    $yml['typePrefix'] = $mailru_products[$data['product_id']]['mailru_type_prefix'];
                } else {
                    $yml['typePrefix'] = $data['category_descriptions'];
                }
            }
            if (empty($brand)) {
                $error_products['empty_brand'] .= $data['product_name'] . ', ';
            } else {
                $yml['vendor'] = $brand;
            }
            $yml['model'] = $mailru_products[$data['product_id']]['mailru_model'];
        } else {
            continue;
        }
        if (!empty($data['full_description'])) {
            $yml['description'] = $data['full_description'];
        }
        if (!empty($data['product_features'])) {
            foreach ($data['product_features'] as $feature) {
                $yml['param@name=' . fn_exim_mailru_get_product_info($feature['description'])] = $feature['value'];
            }
        }
        $yml['delivery'] = $mailru_products[$data['product_id']]['mailru_delivery'] == 'Y' ? 'true' : 'false';
        $yml['pickup'] = $mailru_products[$data['product_id']]['mailru_pickup'] == 'Y' ? 'true' : 'false';
        if ($addon_settings['local_delivery_cost'] == 'Y') {
            if ($delivery_cost == 0) {
                if ($delivery_type == 'value') {
                    $delivery_cost = "0";
                    $yml['local_delivery_cost'] = $delivery_cost;
                } elseif ($delivery_type == 'free') {
                    $delivery_cost = "Бесплатная доставка";
                    $yml['local_delivery_cost'] = $delivery_cost;
                }
            } else {
                $yml['local_delivery_cost'] = $delivery_cost;
            }
        }
        $yml_offers['offer@id=' . $data['product_id'] . '@available=' . $avail . $offer_attrs] = $yml;
        $_SESSION['mailru_export_count']++;
    }
    if ($products_zero_price) {
        fn_set_notification('W', __('error'), __('mailru_export_unsuccessfull') . $products_zero_price);
    }
    if (!empty($error_products) && $addon_settings['notify_disable_products'] == "Y") {
        foreach ($error_products as $key => $value) {
            if (!empty($value)) {
                fn_set_notification('W', __('error'), __('mailru_export_unsuccessfull_' . $key) . $value);
            }
        }
    }
    if (!empty($yml_offers)) {
        $yml_offers = fn_mailru_array_to_yml($yml_offers);
        fn_mailru_write_yml($options['filename'], 'a+', $yml_offers);
    }
    return true;
}
예제 #7
0
        $products_footer[$k]['extra'] = empty($products_footer[$k]['extra']) ? array() : $products_footer[$k]['extra'];
        $products_footer[$k]['extra'] = array_merge($products_footer[$k]['extra'], $extra);
        if (isset($products_footer[$k]['extra']['product_options']) || $_options) {
            $products_footer[$k]['selected_options'] = empty($products_footer[$k]['extra']['product_options']) ? $_options : $products_footer[$k]['extra']['product_options'];
        }
        if (!empty($products_footer[$k]['selected_options'])) {
            $options = fn_get_selected_product_options($v['product_id'], $v['product_options'], CART_LANGUAGE);
            foreach ($products_footer[$k]['selected_options'] as $option_id => $variant_id) {
                foreach ($options as $option) {
                    if ($option['option_id'] == $option_id && !in_array($option['option_type'], array('I', 'T', 'F')) && empty($variant_id)) {
                        $products_footer[$k]['changed_option'] = $option_id;
                        break 2;
                    }
                }
            }
        }
        $products_footer[$k]['display_subtotal'] = $products_footer[$k]['price'] * $v['amount'];
        $products_footer[$k]['display_amount'] = $v['amount'];
        $products_footer[$k]['cart_id'] = $k;
        /* $products_footer[$k]['product_options'] = fn_get_selected_product_options($v['product_id'], $v['product_options'], CART_LANGUAGE);
           $products_footer[$k]['price'] = fn_apply_options_modifiers($v['product_options'], $products_footer[$k]['price'], 'P'); */
        if (!empty($products_footer[$k]['extra']['parent'])) {
            $extra_products[$k] = $products_footer[$k];
            unset($products_footer[$k]);
            continue;
        }
    }
}
fn_gather_additional_products_data($products_footer, array('get_icon' => true, 'get_detailed' => true, 'get_options' => true, 'get_discounts' => true));
//$view->assign('show_qty', true);
$view->assign('products_footer', $products_footer);
예제 #8
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);
}
예제 #9
0
* 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');
}
$xml = '<?xml version="1.0" encoding="' . CHARSET . '"?>';
// Products management
if ($mode == 'get_products') {
    $_REQUEST['extend'] = empty($_REQUEST['type']) ? array('description') : array($_REQUEST['type']);
    list($products) = fn_get_products($_REQUEST, Registry::get('settings.Appearance.products_per_page'));
    fn_gather_additional_products_data($products, array('get_icon' => 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'])) {
            $product['combination'] = $combination;
        }
        fn_gather_additional_product_data($product, true, true);
        $xml .= fn_array_to_xml($product, 'product_data');
    }
예제 #10
0
파일: pdf.php 프로젝트: askzap/ultimate
 $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) {
                 $product['price'] = $product['combination_prices'][$c_id];
                 $product['weight'] = $product['combination_weight'][$c_id];
                 $product['amount'] = $product['combination_amount'][$c_id];
예제 #11
0
/**
 * Get products chains
 *
 * @param array $params Parameters for the function
 * @param array $auth Array of user authentication data
 * @param string $lang_code 2-letter language code (e.g. 'en', 'ru', etc.)
 *
 * @return array Chains of products
 */
function fn_buy_together_get_chains($params = array(), $auth = array(), $lang_code = CART_LANGUAGE)
{
    /**
     * Modify product chains get parameters
     *
     * @param array $params Parameters for the function
     * @param array $auth Array of user authentication data
     * @param string $lang_code 2-letter language code (e.g. 'en', 'ru', etc.)
     */
    fn_set_hook('buy_together_get_chains_pre', $parms, $auth, $lang_code);
    $fields = array('items.chain_id', 'items.product_id', 'items.products', 'items.modifier', 'items.modifier_type', 'items.date_from', 'items.date_to', 'items.display_in_promotions', 'items.status', 'descr.name', 'descr.description');
    if (fn_allowed_for('ULTIMATE')) {
        $fields[] = 'p.company_id';
    }
    $conditions = array();
    $joins = array();
    $joins[] = db_quote("LEFT JOIN ?:products AS p ON p.product_id = items.product_id");
    $joins[] = db_quote("LEFT JOIN ?:buy_together_descriptions AS descr ON items.chain_id = descr.chain_id AND descr.lang_code = ?s", $lang_code);
    if (!empty($params['product_id'])) {
        $conditions['product_id'] = db_quote('items.product_id = ?i', $params['product_id']);
    }
    if (!empty($params['chain_id'])) {
        $conditions['chain_id'] = db_quote('items.chain_id = ?i', $params['chain_id']);
    }
    if (!empty($params['status'])) {
        $conditions['status'] = db_quote('items.status = ?s', $params['status']);
    }
    if (!empty($params['date']) && $params['date']) {
        $date = mktime(0, 0, 0);
        $conditions['date'] = db_quote('(items.date_from <= ?i AND items.date_to >= ?i)', $date, $date);
    }
    if (!empty($params['promotions']) && $params['promotions']) {
        $conditions['promotions'] = db_quote('items.display_in_promotions = ?s', 'Y');
    }
    /**
     * Change select condition (fields, conditions, joins) before selecting payment method data
     *
     * @param array $params Parameters for the function
     * @param array $auth Array of user authentication data
     * @param string $lang_code 2-letter language code (e.g. 'en', 'ru', etc.)
     * @param array $fields Array of fields to be selected
     * @param array $conditions Array of complete condition expressions to be applied to the end of an SQL-query
     * @param array $joins List of strings with the complete JOIN information (JOIN type, tables and fields) for an SQL-query
     *
     */
    fn_set_hook('buy_together_get_chains', $params, $auth, $lang_code, $fields, $conditions, $joins);
    if (!empty($conditions)) {
        $condition = 'WHERE ' . implode(' AND ', $conditions);
    } else {
        $condition = '';
    }
    $fields = implode(', ', $fields);
    $joins = implode(' ', $joins);
    $chains = db_get_array("SELECT {$fields} FROM ?:buy_together AS items {$joins} {$condition}");
    if (!empty($chains)) {
        $selected_options = isset($params['selected_options']) ? $params['selected_options'] : array();
        $product_ids = array();
        $products = array();
        if (!empty($params['full_info'])) {
            foreach ($chains as $chain) {
                $product_ids[$chain['product_id']] = $chain['product_id'];
                $chain_products = unserialize($chain['products']);
                foreach ($chain_products as $product) {
                    $product_ids[$product['product_id']] = $product['product_id'];
                }
            }
            list($products) = fn_get_products(array('pid' => $product_ids));
        }
        foreach ($chains as $key => &$chain) {
            $chain['products'] = unserialize($chain['products']);
            if (!empty($params['full_info'])) {
                $is_valid = true;
                if (isset($auth['area']) && $auth['area'] == 'C' && empty($chain['products'])) {
                    unset($chains[$key]);
                    continue;
                }
                if (!isset($products[$chain['product_id']])) {
                    unset($chains[$key]);
                    continue;
                }
                $chain['products_info'] = $chain['products'];
                $main_product = $products[$chain['product_id']];
                $option_key = $main_product['product_id'] . '_' . $chain['chain_id'];
                $main_product['selected_options'] = isset($selected_options[$option_key]['selected_options']) ? $selected_options[$option_key]['selected_options'] : '';
                $main_product['changed_option'] = isset($selected_options[$option_key]['changed_option']) ? $params['selected_options'][$option_key]['changed_option'] : '';
                fn_gather_additional_products_data($main_product, array('get_icon' => true, 'get_detailed' => true, 'get_additional' => false, 'get_options' => true, 'get_discounts' => true));
                $chain['product_name'] = $main_product['product'];
                $chain['chain_amount'] = $main_product['min_qty'] > 0 ? $main_product['min_qty'] : 1;
                $chain['min_qty'] = $main_product['min_qty'] = 1;
                $chain['price'] = $main_product['price'];
                $chain['list_price'] = $main_product['list_price'];
                $chain['default_options'] = fn_get_default_product_options($main_product['product_id']);
                $chain['product_options'] = $main_product['product_options'];
                $chain['options_type'] = $main_product['options_type'];
                $chain['exceptions_type'] = $main_product['exceptions_type'];
                $chain['options_update'] = isset($main_product['options_update']) ? $main_product['options_update'] : false;
                list($chain['discount'], $chain['discounted_price']) = fn_buy_together_calculate_discount($main_product['price'], $chain['modifier'], $chain['modifier_type']);
                if (isset($main_product['main_pair'])) {
                    $chain['main_pair'] = $main_product['main_pair'];
                }
                $total_price = $main_product['price'];
                $chain_price = $chain['discounted_price'];
                foreach ($chain['products'] as $hash => &$chain_product) {
                    if (empty($product['product_id'])) {
                        unset($chains[$key]['products'][$hash]);
                        unset($chains[$key]['products_info'][$hash]);
                        continue;
                    }
                    if (!isset($products[$chain_product['product_id']])) {
                        if (isset($auth['area']) && $auth['area'] == 'C') {
                            $is_valid = false;
                            break;
                        }
                        unset($chains[$key]['products'][$hash]);
                        unset($chains[$key]['products_info'][$hash]);
                        continue;
                    }
                    $product = $products[$chain_product['product_id']];
                    if (AREA == 'C' && ($product['status'] == 'H' || isset($product['tracking']) && $product['tracking'] != ProductTracking::DO_NOT_TRACK && Registry::get('settings.General.show_out_of_stock_products') == 'N' && empty($product['amount']))) {
                        $is_valid = false;
                        break;
                    }
                    if (!empty($chain_product['product_options'])) {
                        $product['selected_options'] = $chain_product['product_options'];
                    } else {
                        $product['selected_options'] = isset($selected_options[$product['product_id']]['selected_options']) ? $selected_options[$product['product_id']]['selected_options'] : '';
                        $product['changed_option'] = isset($selected_options[$product['product_id']]['changed_option']) ? $selected_options[$product['product_id']]['changed_option'] : '';
                    }
                    fn_gather_additional_products_data($product, array('get_icon' => true, 'get_detailed' => true, 'get_additional' => false, 'get_options' => true, 'get_discounts' => true));
                    $product['min_qty'] = $product['min_qty'] > 0 ? $product['min_qty'] : 1;
                    $chain_product['product_name'] = $product['product'];
                    $chain_product['min_qty'] = $product['min_qty'];
                    $chain_product['price'] = empty($chain_product['price']) ? $product['price'] : $chain_product['price'];
                    $chain_product['list_price'] = $product['list_price'];
                    if (isset($product['main_pair'])) {
                        $chain_product['main_pair'] = $product['main_pair'];
                    }
                    list($chain_product['discount'], $chain_product['discounted_price']) = fn_buy_together_calculate_discount($product['price'], empty($chain_product['modifier']) ? 0 : $chain_product['modifier'], empty($chain_product['modifier_type']) ? 'to_fixed' : $chain_product['modifier_type']);
                    $chain_product['options_type'] = $product['options_type'];
                    $chain_product['exceptions_type'] = $product['exceptions_type'];
                    $chain_product['options_update'] = isset($product['options_update']) ? $product['options_update'] : false;
                    $total_price += $product['price'] * $chain_product['amount'];
                    $chain_price += $chain_product['discounted_price'] * $chain_product['amount'];
                    if (!empty($chain_product['product_options'])) {
                        $chain_product['product_options_short'] = $chain_product['product_options'];
                        $options = fn_get_selected_product_options_info($chain_product['product_options'], DESCR_SL);
                        $chain_product['product_options'] = $options;
                    } elseif (!empty($product['product_options'])) {
                        $chain_product['aoc'] = true;
                        // Allow any option combinations
                        $chain_product['options'] = $product['product_options'];
                    }
                    $chains[$key]['products_info'][$hash]['price'] = $chain_product['price'];
                    $chains[$key]['products_info'][$hash]['discount'] = $chain_product['discount'];
                    $chains[$key]['products_info'][$hash]['discounted_price'] = $chain_product['discounted_price'];
                }
                if (!$is_valid) {
                    unset($chains[$key]);
                    continue;
                }
                $chain['total_price'] = $total_price;
                $chain['chain_price'] = $chain_price;
                unset($chain_product);
            }
            if (!empty($params['simple'])) {
                $simple_chain = $chain;
                break;
            }
        }
        unset($chain);
    }
    if (isset($simple_chain)) {
        $chains = $simple_chain;
    }
    /**
     * Gets function result along with parameters and query information.
     *
     * @param array $params Parameters for the function
     * @param array $auth Array of user authentication data
     * @param string $lang_code 2-letter language code (e.g. 'en', 'ru', etc.)
     * @param mixed $chains One chain or array of chains, depending on 'simple' parameter.
     * @param array $fields Array of fields to be selected
     * @param array $conditions Array of complete condition expressions to be applied to the end of an SQL-query
     * @param array $joins List of strings with the complete JOIN information (JOIN type, tables and fields) for an SQL-query
     */
    fn_set_hook('buy_together_get_chains_post', $params, $auth, $lang_code, $chains, $fields, $conditions, $joins);
    return $chains;
}
예제 #12
0
 if (Registry::get('settings.General.show_products_from_subcategories') == 'Y') {
     $params['subcats'] = 'Y';
 }
 if (isset($_REQUEST['ls_view_all'])) {
     list($products, $search) = fn_get_products($params, 10000, CART_LANGUAGE);
     $ls_view_all = true;
     list($products2, $search2) = fn_get_products($params, Registry::get('settings.Appearance.products_per_page'), CART_LANGUAGE);
 } else {
     list($products, $search) = fn_get_products($params, Registry::get('settings.Appearance.products_per_page'), CART_LANGUAGE);
     $ls_view_all = false;
 }
 if (isset($search['page']) && $search['page'] > 1 && empty($products)) {
     return array(CONTROLLER_STATUS_NO_PAGE);
 }
 $colorOptionFlag = false;
 $colorOptionVariants = array();
 foreach ($products as $product123) {
     $colorOptionCheck = db_get_row("SELECT ?:product_options.option_id FROM ?:product_options LEFT JOIN ?:product_global_option_links ON ?:product_options.option_id=?:product_global_option_links.option_id WHERE (?:product_options.product_id=?i OR ?:product_global_option_links.product_id=?i) AND ?:product_options.option_id = 2291", $product123['product_id'], $product123['product_id']);
     if (!empty($colorOptionCheck)) {
         $colorOptionFlag = true;
     }
 }
 if ($colorOptionFlag) {
     $colorOptionVariants = db_get_array("SELECT ?:product_option_variants.*, ?:product_option_variants_descriptions.variant_name FROM ?:product_option_variants JOIN ?:product_option_variants_descriptions ON ?:product_option_variants.variant_id=?:product_option_variants_descriptions.variant_id WHERE ?:product_option_variants.option_id=2291 AND ?:product_option_variants_descriptions.lang_code = ?s", CART_LANGUAGE);
 }
 Registry::get('view')->assign('colorOptionVariants', $colorOptionVariants);
 fn_gather_additional_products_data($products, array('get_icon' => true, 'get_detailed' => true, 'get_additional' => true, 'get_options' => true, 'get_discounts' => true, 'get_features' => false, 'get_extra' => false, 'get_taxed_prices' => true, 'get_for_one_product' => !is_array(reset($products)) ? true : false, 'detailed_params' => true, 'features_display_on' => 'C', 'ls_category_page' => true));
 $show_no_products_block = !empty($params['features_hash']) && !$products;
 Registry::get('view')->assign('show_no_products_block', $show_no_products_block);
 foreach ($products as $keyProduct => $categoryProducts) {
     $promoName = "";
예제 #13
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);
}
예제 #14
0
파일: Yml.php 프로젝트: askzap/ask-zap
 protected function body($file)
 {
     $offered = array();
     if ($this->options['disable_cat_d'] == "Y") {
         $visible_categories = $this->getVisibleCategories();
     }
     $fields = array('p.product_id', 'p.product_code', 'd.lang_code', 'pc.category_id', 'cd.category', 'pp.price', 'p.list_price', 'p.status', 'p.amount', 'p.weight', 'p.shipping_freight', 'p.free_shipping', 'd.product', 'd.full_description', 'p.company_id', 'p.tracking', 'p.list_price', 'p.yml_brand', 'p.yml_origin_country', 'p.yml_store', 'p.yml_pickup', 'p.yml_delivery', 'p.yml_adult', 'p.yml_cost', 'p.yml_export_yes', 'p.yml_bid', 'p.yml_cbid', 'p.yml_model', 'p.yml_sales_notes', 'p.yml_type_prefix', 'p.yml_market_category', 'p.yml_manufacturer_warranty', 'p.yml_seller_warranty');
     $fields[] = "(\n                SELECT GROUP_CONCAT(IF(pc2.link_type = 'M', CONCAT(pc2.category_id, 'M'), pc2.category_id))\n                FROM ?:products_categories as pc2\n                WHERE product_id = p.product_id\n            ) as category_ids";
     $joins = array(db_quote("LEFT JOIN ?:product_descriptions as d ON d.product_id = p.product_id AND d.lang_code = ?s", $this->lang_code), db_quote("LEFT JOIN ?:product_prices as pp" . " ON pp.product_id = p.product_id AND pp.lower_limit = 1 AND pp.usergroup_id = 0"), db_quote("LEFT JOIN ?:products_categories as pc ON pc.product_id = p.product_id AND pc.link_type = ?s", 'M'), db_quote("LEFT JOIN ?:category_descriptions as cd ON cd.category_id = pc.category_id AND cd.lang_code = ?s", $this->lang_code));
     $condition = '';
     if ($this->company_id > 0) {
         $condition .= db_quote(' AND company_id = ?i', $this->company_id);
     }
     $product_ids = db_get_fields("SELECT product_id FROM ?:products WHERE yml_export_yes = ?s AND status = ?s " . $condition, 'Y', 'A');
     $offset = 0;
     while ($ids = array_slice($product_ids, $offset, self::ITERATION_ITEMS)) {
         $offset += self::ITERATION_ITEMS;
         $products = db_get_array('SELECT ' . implode(', ', $fields) . ' FROM ?:products as p' . ' ' . implode(' ', $joins) . ' WHERE p.product_id IN(?n)', $ids);
         $products_images_main = fn_get_image_pairs($ids, 'product', 'M', false, true, $this->lang_code);
         $products_images_additional = fn_get_image_pairs($ids, 'product', 'A', false, true, $this->lang_code);
         $params = array('get_options' => false, 'get_taxed_prices' => false, 'detailed_params' => false);
         fn_gather_additional_products_data($products, $params);
         foreach ($products as $k => &$product) {
             $is_broken = false;
             $price = !floatval($product['price']) ? fn_parse_price($product['price']) : intval($product['price']);
             if ($this->options['export_null_price'] == 'N' && empty($price)) {
                 $is_broken = true;
             }
             if (in_array($product['category_id'], $this->disabled_category_ids)) {
                 $is_broken = true;
             }
             if ($this->options['disable_cat_d'] == 'Y' && !in_array($product['category_id'], $visible_categories)) {
                 $is_broken = true;
             }
             $product['product'] = $this->escape($product['product']);
             $product['full_description'] = $this->escape($product['full_description']);
             $product['product_features'] = $this->getProductFeatures($product);
             $product['brand'] = $this->getBrand($product);
             if ($this->options['export_type'] == 'vendor_model') {
                 if (empty($product['brand']) || empty($product['yml_model'])) {
                     $is_broken = true;
                 }
             }
             if ($product['tracking'] == 'O') {
                 $product['amount'] = db_get_field("SELECT SUM(amount) FROM ?:product_options_inventory WHERE product_id = ?i", $product['product_id']);
             }
             if ($this->options['export_stock'] == 'Y' && $product['amount'] <= 0) {
                 $is_broken = true;
             }
             if ($is_broken) {
                 unset($products[$k]);
                 continue;
             }
             $product['product_url'] = fn_url('products.view?product_id=' . $product['product_id']);
             // Images
             $images = array_merge($products_images_main[$product['product_id']], $products_images_additional[$product['product_id']]);
             $product['images'] = array_slice($images, 0, self::IMAGES_LIMIT);
             list($key, $value) = $this->offer($product);
             $offered[$key] = $value;
         }
         if (!empty($offered)) {
             fwrite($file, fn_yandex_market_array_to_yml($offered));
             unset($offered);
         }
     }
 }
예제 #15
0
 protected function generateOffers($file)
 {
     $fields = array('p.product_id', 'p.product_code', 'd.lang_code', 'pc.category_id', 'cd.category', 'pp.price', 'p.list_price', 'p.status', 'p.amount', 'p.weight', 'p.shipping_freight', 'p.shipping_params', 'p.free_shipping', 'd.product', 'd.short_description', 'd.full_description', 'p.company_id', 'p.bean_bag_quantity_150', 'p.bean_bag_quantity_300', 'p.tracking', 'p.list_price', 'p.yml2_brand', 'p.yml2_origin_country', 'p.yml2_store', 'p.yml2_pickup', 'p.yml2_delivery', 'p.yml2_delivery_options', 'p.yml2_bid', 'p.yml2_cbid', 'p.yml2_model', 'p.yml2_sales_notes', 'p.yml2_type_prefix', 'p.yml2_offer_type', 'p.yml2_market_category', 'p.yml2_manufacturer_warranty', 'p.yml2_seller_warranty', 'p.yml2_purchase_price');
     $fields[] = "(\n                SELECT GROUP_CONCAT(IF(pc2.link_type = 'M', CONCAT(pc2.category_id, 'M'), pc2.category_id))\n                FROM ?:products_categories as pc2\n                WHERE product_id = p.product_id\n            ) as category_ids";
     $joins = array(db_quote("LEFT JOIN ?:product_descriptions as d ON d.product_id = p.product_id AND d.lang_code = ?s", $this->lang_code), db_quote("LEFT JOIN ?:product_prices as pp" . " ON pp.product_id = p.product_id AND pp.lower_limit = 1 AND pp.usergroup_id = 0"), db_quote("LEFT JOIN ?:products_categories as pc ON pc.product_id = p.product_id AND pc.link_type = ?s", 'M'), db_quote("LEFT JOIN ?:category_descriptions as cd ON cd.category_id = pc.category_id AND cd.lang_code = ?s", $this->lang_code));
     $condition = '';
     if ($this->company_id > 0) {
         $condition .= db_quote(' AND company_id = ?i', $this->company_id);
     }
     $exclude_products_ids = array();
     if (!empty($this->options['exclude_categories_not_logging']) && $this->options['exclude_categories_not_logging'] == 'Y' && !empty($this->exclude_category_ids)) {
         $exclude_products_ids = db_get_fields("SELECT DISTINCT product_id FROM ?:products_categories WHERE category_id IN (?a)", $this->exclude_category_ids);
     }
     $products_ids = db_get_fields("SELECT DISTINCT object_id FROM ?:yml_exclude_objects WHERE price_id = ?i AND object_type = 'product'", $this->price_id);
     $exclude_products_ids = array_merge($exclude_products_ids, $products_ids);
     if (!empty($exclude_products_ids)) {
         $condition .= db_quote(' AND product_id NOT IN (?a)', $exclude_products_ids);
     }
     $product_ids = db_get_fields("SELECT product_id FROM ?:products WHERE status = ?s {$condition}", 'A');
     fn_set_storage_data('yml2_export_count_' . $this->price_id, count($product_ids));
     $shared_product_ids = array();
     if (isset($this->options['export_shared_products']) && $this->options['export_shared_products'] == 'Y') {
         $categories_join = db_quote('INNER JOIN ?:categories ON ?:categories.category_id = ?:products_categories.category_id');
         $products_join = db_quote('INNER JOIN ?:products ON ?:products.product_id = ?:products_categories.product_id');
         $shared_product_ids = db_get_fields("SELECT DISTINCT ?:products_categories.product_id FROM ?:products_categories {$categories_join} {$products_join} " . "WHERE ?:categories.company_id = ?i AND link_type = 'A' AND ?:products.status = 'A' ", $this->company_id);
         $product_ids = array_merge($product_ids, $shared_product_ids);
     }
     $this->offer = new Offers($this->options, $this->log);
     $offers_count = 0;
     while ($ids = array_slice($product_ids, $this->offset, self::ITERATION_ITEMS)) {
         $this->offset += self::ITERATION_ITEMS;
         $products = db_get_array('SELECT ' . implode(', ', $fields) . ' FROM ?:products as p' . ' ' . implode(' ', $joins) . ' WHERE p.product_id IN(?n)' . ' GROUP BY p.product_id', $ids);
         $products_images_main = fn_get_image_pairs($ids, 'product', 'M', false, true, $this->lang_code);
         $products_images_additional = fn_get_image_pairs($ids, 'product', 'A', false, true, $this->lang_code);
         $params = array('get_options' => true, 'get_taxed_prices' => false, 'detailed_params' => false);
         fn_gather_additional_products_data($products, $params);
         foreach ($products as $k => &$product) {
             if (in_array($product['product_id'], $shared_product_ids)) {
                 $this->prepareSharedProduct($product);
             }
             $product['product_features'] = $this->getProductFeatures($product);
             if (!$this->preBuild($product, $products_images_main, $products_images_additional)) {
                 $this->yml2_product_skip++;
                 continue;
             }
             list($xml, $product_skip) = $this->offer->build($product);
             $this->yml2_product_skip += $product_skip;
             $this->stopGeneration();
             fwrite($file, $xml . "\n");
             $this->yml2_product_export++;
         }
         $offers_count += count($products);
         fn_set_storage_data('yml2_export_offset_' . $this->price_id, $this->offset);
         if (!defined('CONSOLE') && $offers_count >= self::ITERATION_OFFERS) {
             fn_set_storage_data('yml2_product_export_' . $this->price_id, $this->yml2_product_export);
             fn_set_storage_data('yml2_product_skip_' . $this->price_id, $this->yml2_product_skip);
             fclose($file);
             fn_set_storage_data('yml2_status_generate_' . $this->price_id, 'redirect');
             fn_redirect(fn_yml_get_generate_link($this->price_list) . "/" . $this->offset);
         }
     }
     return true;
 }
예제 #16
0
function fn_ls_wishlist_products_footer()
{
    //wishlist products footer carousel
    $_SESSION['wishlist'] = isset($_SESSION['wishlist']) ? $_SESSION['wishlist'] : array();
    $wishlist =& $_SESSION['wishlist'];
    $_SESSION['continue_url'] = isset($_SESSION['continue_url']) ? $_SESSION['continue_url'] : '';
    $auth =& $_SESSION['auth'];
    //view products
    $wishlistProductsIds = array();
    $products_footer = !empty($wishlist['products']) ? $wishlist['products'] : array();
    $extra_products = array();
    $wishlist_is_empty = fn_cart_is_empty($wishlist);
    if (!empty($products_footer)) {
        foreach ($products_footer as $k => $v) {
            $wishlistProductsIds[$k] = $v['product_id'];
            $_options = array();
            $extra = $v['extra'];
            if (!empty($v['product_options'])) {
                $_options = $v['product_options'];
            }
            $products_footer[$k] = fn_get_product_data($v['product_id'], $auth, CART_LANGUAGE, '', true, true, true, false, false, true, false, true);
            if (empty($products_footer[$k])) {
                unset($products_footer[$k], $wishlist['products'][$k]);
                continue;
            }
            $products_footer[$k]['extra'] = empty($products_footer[$k]['extra']) ? array() : $products_footer[$k]['extra'];
            $products_footer[$k]['extra'] = array_merge($products_footer[$k]['extra'], $extra);
            if (isset($products_footer[$k]['extra']['product_options']) || $_options) {
                $products_footer[$k]['selected_options'] = empty($products_footer[$k]['extra']['product_options']) ? $_options : $products_footer[$k]['extra']['product_options'];
            }
            if (!empty($products_footer[$k]['selected_options'])) {
                $options = fn_get_selected_product_options($v['product_id'], $v['product_options'], CART_LANGUAGE);
                foreach ($products_footer[$k]['selected_options'] as $option_id => $variant_id) {
                    foreach ($options as $option) {
                        if ($option['option_id'] == $option_id && !in_array($option['option_type'], array('I', 'T', 'F')) && empty($variant_id)) {
                            $products_footer[$k]['changed_option'] = $option_id;
                            break 2;
                        }
                    }
                }
            }
            $products_footer[$k]['display_subtotal'] = $products_footer[$k]['price'] * $v['amount'];
            $products_footer[$k]['display_amount'] = $v['amount'];
            $products_footer[$k]['cart_id'] = $k;
            /* $products_footer[$k]['product_options'] = fn_get_selected_product_options($v['product_id'], $v['product_options'], CART_LANGUAGE);
               $products_footer[$k]['price'] = fn_apply_options_modifiers($v['product_options'], $products_footer[$k]['price'], 'P'); */
            if (!empty($products_footer[$k]['extra']['parent'])) {
                $extra_products[$k] = $products_footer[$k];
                unset($products_footer[$k]);
                continue;
            }
        }
    }
    fn_gather_additional_products_data($products_footer, array('get_icon' => true, 'get_detailed' => true, 'get_options' => true, 'get_discounts' => true));
    return array($wishlistProductsIds, $products_footer);
}
예제 #17
0
파일: xls.php 프로젝트: askzap/ultimate
function fn_price_list_print_products($params, &$worksheet, &$counter, &$row, &$width, $selected_fields, $price_schema, $styles)
{
    $worksheet->getRowDimension($row)->setRowHeight(FIELD_HEADING_HEIGHT);
    $col = 'A';
    foreach ($selected_fields as $field => $active) {
        $worksheet->setCellValue($col . $row, $price_schema['fields'][$field]['title']);
        $worksheet->getStyle($col . $row)->applyFromArray($styles['field_heading']);
        if (!isset($width[$col]) || $width[$col] < strlen($price_schema['fields'][$field]['title'])) {
            $width[$col] = strlen($price_schema['fields'][$field]['title']);
        }
        $col++;
    }
    $row++;
    $total = ITEMS_PER_PAGE;
    $fill = 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']++;
        $_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);
        // Write products information
        foreach ($products as $product) {
            if (Registry::get('addons.price_list.include_options') == 'Y' && $product['has_options']) {
                $product_comb = fn_price_list_get_combination($product);
                if (!empty($selected_fields['image'])) {
                    $default_image = $product['main_pair'];
                    $comb_hashes = db_get_hash_single_array("SELECT oi.combination, oi.combination_hash FROM ?:product_options_inventory AS oi LEFT JOIN ?:images_links as il ON oi.combination_hash = il.object_id AND object_type = ?s WHERE oi.product_id = ?i", array('combination', 'combination_hash'), 'product_option', $product['product_id']);
                    if (!empty($comb_hashes)) {
                        $default_image = fn_get_image_pairs($product['product_id'], 'product', 'M', true, false, CART_LANGUAGE);
                    }
                }
                foreach ($product_comb['combinations'] as $c_id => $c_value) {
                    if (!empty($selected_fields['image'])) {
                        $combination = fn_get_options_combination($c_value);
                        if (!empty($comb_hashes[$combination])) {
                            $product['main_pair'] = fn_get_image_pairs($comb_hashes[$combination], 'product_option', 'M', true, true, CART_LANGUAGE);
                        } else {
                            $product['main_pair'] = $default_image;
                        }
                    }
                    $product['price'] = $product_comb['combination_prices'][$c_id];
                    $product['weight'] = $product_comb['combination_weight'][$c_id];
                    $product['amount'] = $product_comb['combination_amount'][$c_id];
                    $product['product_code'] = $product_comb['combination_code'][$c_id];
                    fn_price_list_print_product_data($product, $worksheet, $row, $width, $selected_fields, $styles, $c_value);
                    $row++;
                }
            } else {
                fn_price_list_print_product_data($product, $worksheet, $row, $width, $selected_fields, $styles);
                $row++;
            }
        }
        $counter->Out();
    }
    return true;
}
예제 #18
0
파일: func.php 프로젝트: askzap/ultimate
function fn_format_categories_items($params, $lang_code)
{
    $items_data = $additional_data = $timestamps = array();
    if (empty($params['category_id'])) {
        return array($items_data, $additional_data);
    } else {
        $params['cid'] = $params['category_id'];
        $params['sort_by'] = 'updated_timestamp';
        $params['sort_order'] = 'desc';
        if (Registry::get('settings.General.show_products_from_subcategories') == 'Y') {
            $params['subcats'] = 'Y';
        }
    }
    $category_data = fn_get_category_data($params['category_id'], $lang_code, '*');
    list($products, ) = fn_get_products($params, Registry::get('addons.rss_feed.category_max_products_items'));
    fn_gather_additional_products_data($products, array('get_icon' => true, 'get_detailed' => true, 'get_options' => true, 'get_discounts' => true, 'get_features' => false));
    $additional_data['title'] = $category_data['category'];
    $additional_data['description'] = strip_tags(!empty($category_data['description']) ? $category_data['description'] : $additional_data['title']);
    $additional_data['link'] = fn_url('categories.view?category_id=' . $params['category_id'], 'C', 'current', $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, array(), $lang_code);
    return array($items_data, $additional_data);
}
예제 #19
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);
}
예제 #20
0
function fn_gather_additional_products_data_for_search(&$products)
{
    fn_gather_additional_products_data($products, array('get_icon' => true, 'get_detailed' => true));
}
예제 #21
0
 $cart['calculate_shipping'] = true;
 list($cart_products, Tygh::$app['session']['shipping_product_groups']) = fn_calculate_cart_content($cart, $auth, 'A', true, 'F', true);
 $cart_shippings = array();
 foreach (Tygh::$app['session']['shipping_product_groups'] as $key_group => $group) {
     if (!empty($group['shippings'])) {
         foreach ($group['shippings'] as $shipping) {
             $shipping_id = $shipping['shipping_id'];
             if (empty($cart_shippings[$shipping_id])) {
                 $cart_shippings[$shipping_id] = $shipping;
                 $cart_shippings[$shipping_id]['rates'] = array();
             }
             $cart_shippings[$shipping_id]['rates'][$key_group] = $shipping['rate'];
         }
     }
 }
 fn_gather_additional_products_data($cart_products, array('get_icon' => false, 'get_detailed' => false, 'get_options' => true, 'get_discounts' => false));
 // Determine the tax calculation type
 $tax_calculation_type = 'amazon';
 // If the tax calculation method is not based on the "subtotal", or taxes have absolute rates or one of the product has multiple applied tax, the calculation type will be changed to "default"
 if (Registry::get('settings.General.tax_calculation') == 'unit_price') {
     $tax_calculation_type = 'default';
 } else {
     $_taxed_products = array();
     if (!empty($cart['taxes'])) {
         foreach ($cart['taxes'] as $tax_id => $tax) {
             if ($tax['rate_type'] != 'P') {
                 $tax_calculation_type = 'default';
                 break;
             }
             if (!empty($tax['applies']['items']['P'])) {
                 foreach ($tax['applies']['items']['P'] as $product_id => $product) {
예제 #22
0
/**
 * Gets products from feature comparison list
 *
 * @return array List of compared products
 */
function fn_get_comparison_products()
{
    $compared_products = array();
    if (!empty($_SESSION['comparison_list'])) {
        $_products = db_get_hash_array("SELECT product_id, product FROM ?:product_descriptions WHERE product_id IN (?n) AND lang_code = ?s", 'product_id', $_SESSION['comparison_list'], CART_LANGUAGE);
        $params = array('pid' => $_SESSION['comparison_list']);
        list($products, $search) = fn_get_products($params);
        fn_gather_additional_products_data($products, array('get_icon' => true, 'get_detailed' => true, 'get_additional' => false, 'get_options' => false));
        $_products = array();
        foreach ($products as $product) {
            $_products[$product['product_id']] = $product;
        }
        $products = $_products;
        unset($_products);
        foreach ($_SESSION['comparison_list'] as $k => $p_id) {
            if (empty($products[$p_id])) {
                unset($_SESSION['comparison_list'][$k]);
                continue;
            }
            $compared_products[] = $products[$p_id];
        }
    }
    /**
     * Changes compared products
     *
     * @param array $compared_products List of compared products
     */
    fn_set_hook('get_comparison_products_post', $compared_products);
    return $compared_products;
}