Example #1
0
 public function xml($product)
 {
     $yml2_product_skip = 0;
     $this->offer = $this->build($product);
     $this->gatherAdditional($product);
     $this->getApparelOffer($product);
     if ($this->options['export_stock'] == 'Y') {
         if ($product['tracking'] == 'B' && $product['amount'] <= 0) {
             $this->log->write(Logs::SKIP_PRODUCT, $product, __('yml2_log_product_amount_is_empty'));
             return '';
         }
     }
     list($product_combinations, ) = fn_get_product_options_inventory(array('product_id' => $product['product_id']));
     if (empty($product_combinations)) {
         $product_combinations = $this->generateCombinations($product);
     }
     if (empty($product_combinations)) {
         $this->log->write(Logs::SKIP_PRODUCT, $product, __('yml2_log_product_combinations_are_empty'));
     }
     if (!empty($this->offer['items']['param'])) {
         $this->params = $this->offer['items']['param'];
     }
     $xml = '';
     $offer_origin = $this->offer;
     foreach ($product_combinations as $combination) {
         if (!$this->buildOfferCombination($product, $combination)) {
             continue;
         }
         $xml .= $this->offerToXml($this->offer);
         if (!$this->postBuild($xml, $product, $this->offer)) {
             $yml2_product_skip++;
         }
         $this->offer = $offer_origin;
     }
     return array($xml, $yml2_product_skip);
 }
Example #2
0
    }
    if (!fn_allowed_for('ULTIMATE:FREE')) {
        if ($mode == 'delete_exception') {
            if (!empty($_REQUEST['exception_id'])) {
                db_query("DELETE FROM ?:product_options_exceptions WHERE exception_id = ?i", $_REQUEST['exception_id']);
            }
            $suffix = ".exceptions?product_id={$_REQUEST['product_id']}";
        }
    }
    return array(CONTROLLER_STATUS_OK, 'product_options' . $suffix);
}
//
// Product options combination inventory tracking
//
if ($mode == 'inventory') {
    list($inventory, $search) = fn_get_product_options_inventory($_REQUEST, Registry::get('settings.Appearance.admin_elements_per_page'));
    $product_options = fn_get_product_options($_REQUEST['product_id'], DESCR_SL, true, true);
    $product_inventory = db_get_field("SELECT tracking FROM ?:products WHERE product_id = ?i", $_REQUEST['product_id']);
    Registry::get('view')->assign('product_inventory', $product_inventory);
    Registry::get('view')->assign('product_options', $product_options);
    Registry::get('view')->assign('inventory', $inventory);
    Registry::get('view')->assign('search', $search);
    //
    // Options list
    //
} elseif ($mode == 'manage') {
    $params = $_REQUEST;
    list($product_options, $search) = fn_get_product_global_options($params, Registry::get('settings.Appearance.admin_elements_per_page'), DESCR_SL);
    Registry::get('view')->assign('product_options', $product_options);
    Registry::get('view')->assign('search', $search);
    Registry::get('view')->assign('object', 'global');
Example #3
0
 /**
  * Load options and combinations
  */
 public function loadOptions()
 {
     $options = fn_get_product_options($this->id, CART_LANGUAGE, true, true);
     $original_option_variants = $product_option_variants = array();
     foreach ($options as $item) {
         $option = new ProductOption($item['option_name']);
         foreach ($item['variants'] as $variant) {
             if (!empty($variant['image_pair']['icon']['http_image_path'])) {
                 $image_path = $variant['image_pair']['icon']['http_image_path'];
             } else {
                 $image_path = Registry::get('config.http_location') . '/images/no_image.png';
             }
             $this->setPicture($image_path);
             $option_variant = new ProductOptionVariant($option, $variant['variant_name'], $image_path);
             $option->setVariant($option_variant);
             $product_option_variants[$item['option_id']][$variant['variant_id']] = $option_variant;
             $original_option_variants[$item['option_id']][$variant['variant_id']] = $variant;
         }
         $this->options[$option->getId()] = $option;
     }
     list($inventory) = fn_get_product_options_inventory(array('product_id' => $this->id));
     foreach ($inventory as $combination) {
         $variants = array();
         $price = $this->base_price;
         if ($this->tracking === ProductTracking::TRACK_WITH_OPTIONS) {
             $amount = $combination['amount'];
         } else {
             $amount = $this->amount;
         }
         foreach ($combination['combination'] as $option_id => $variant_id) {
             if (isset($product_option_variants[$option_id][$variant_id])) {
                 $variants[] = $product_option_variants[$option_id][$variant_id];
                 $variant = $original_option_variants[$option_id][$variant_id];
                 if ($variant['modifier_type'] == 'A') {
                     $price += $variant['modifier'];
                 } else {
                     $price = $price + $price * $variant['modifier'] / 100;
                 }
             }
         }
         if (!empty($variants)) {
             $product_variation = new ProductVariation($price, $amount, $variants);
             $this->combinations[$product_variation->getId()] = $product_variation;
         }
     }
 }
Example #4
0
 public function index($id = 0, $params = array())
 {
     $lang_code = $this->safeGet($params, 'lang_code', DEFAULT_LANGUAGE);
     if (empty($id) && empty($params['product_id'])) {
         $status = Response::STATUS_BAD_REQUEST;
         $data['message'] = __('api_required_field', array('[field]' => 'product_id'));
     } else {
         $product_id = $this->safeGet($params, 'product_id', 0);
         if (empty($product_id)) {
             $product_id = db_get_field('SELECT product_id FROM ?:product_options_inventory WHERE combination_hash = ?s', $id);
         }
         $product_data = fn_get_product_data($product_id, $this->auth, $lang_code, '', false, false, false, false, false, false, false);
         if (empty($product_data)) {
             $status = Response::STATUS_NOT_FOUND;
             $data = array();
         } else {
             if (!empty($id)) {
                 $data = fn_get_product_options_combination_data($id, $lang_code);
                 $status = Response::STATUS_OK;
             } else {
                 $params['product_id'] = $product_id;
                 list($data) = fn_get_product_options_inventory($params, 0, $lang_code);
                 $status = Response::STATUS_OK;
             }
             if (empty($data)) {
                 $status = Response::STATUS_NOT_FOUND;
             }
         }
     }
     return array('status' => $status, 'data' => $data);
 }