Ejemplo n.º 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();
     }
 }
Ejemplo n.º 2
0
 $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];
                 foreach ($selected_fields as $field_name => $active) {
                     if ($field_name == 'image') {
                         continue;
                     } elseif ($field_name == 'product') {
                         $options = array();
                         foreach ($c_value as $option_id => $variant_id) {
                             $options[] = $product['product_options'][$option_id]['option_name'] . ': ' . $product['product_options'][$option_id]['variants'][$variant_id]['variant_name'];
                         }
                         $options = implode("\n", $options);
                         $worksheet->write($col . $row, $product[$field_name] . "\n" . $options, $row % 2 == 0 ? $field_simple_odd : $field_simple);
Ejemplo n.º 3
0
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;
}