Beispiel #1
1
function listProductUpdateData($products, $setUrl = 0)
{
    $jshopConfig = JSFactory::getConfig();
    $userShop = JSFactory::getUserShop();
    $taxes = JSFactory::getAllTaxes();
    if ($jshopConfig->product_list_show_manufacturer) {
        $manufacturers = JSFactory::getAllManufacturer();
    }
    if ($jshopConfig->product_list_show_vendor) {
        $vendors = JSFactory::getAllVendor();
    }
    if ($jshopConfig->show_delivery_time) {
        $deliverytimes = JSFactory::getAllDeliveryTime();
    }
    $image_path = $jshopConfig->image_product_live_path;
    $noimage = $jshopConfig->noimage;
    JPluginHelper::importPlugin('jshoppingproducts');
    $dispatcher = JDispatcher::getInstance();
    foreach ($products as $key => $value) {
        $dispatcher->trigger('onListProductUpdateDataProduct', array(&$products, &$key, &$value));
        $use_userdiscount = 1;
        if ($jshopConfig->user_discount_not_apply_prod_old_price && $products[$key]->product_old_price > 0) {
            $use_userdiscount = 0;
        }
        $products[$key]->_original_product_price = $products[$key]->product_price;
        $products[$key]->product_price_wp = $products[$key]->product_price;
        $products[$key]->product_price_default = 0;
        if ($jshopConfig->product_list_show_min_price) {
            if ($products[$key]->min_price > 0) {
                $products[$key]->product_price = $products[$key]->min_price;
            }
        }
        $products[$key]->show_price_from = 0;
        if ($jshopConfig->product_list_show_min_price && $value->different_prices) {
            $products[$key]->show_price_from = 1;
        }
        $products[$key]->product_price = getPriceFromCurrency($products[$key]->product_price, $products[$key]->currency_id);
        $products[$key]->product_old_price = getPriceFromCurrency($products[$key]->product_old_price, $products[$key]->currency_id);
        $products[$key]->product_price_wp = getPriceFromCurrency($products[$key]->product_price_wp, $products[$key]->currency_id);
        $products[$key]->product_price = getPriceCalcParamsTax($products[$key]->product_price, $products[$key]->tax_id);
        $products[$key]->product_old_price = getPriceCalcParamsTax($products[$key]->product_old_price, $products[$key]->tax_id);
        $products[$key]->product_price_wp = getPriceCalcParamsTax($products[$key]->product_price_wp, $products[$key]->tax_id);
        if ($userShop->percent_discount && $use_userdiscount) {
            $products[$key]->product_price_default = $products[$key]->_original_product_price;
            $products[$key]->product_price_default = getPriceFromCurrency($products[$key]->product_price_default, $products[$key]->currency_id);
            $products[$key]->product_price_default = getPriceCalcParamsTax($products[$key]->product_price_default, $products[$key]->tax_id);
            $products[$key]->product_price = getPriceDiscount($products[$key]->product_price, $userShop->percent_discount);
            $products[$key]->product_old_price = getPriceDiscount($products[$key]->product_old_price, $userShop->percent_discount);
            $products[$key]->product_price_wp = getPriceDiscount($products[$key]->product_price_wp, $userShop->percent_discount);
        }
        if ($jshopConfig->list_products_calc_basic_price_from_product_price) {
            $products[$key]->basic_price_info = getProductBasicPriceInfo($value, $products[$key]->product_price_wp);
        } else {
            $products[$key]->basic_price_info = getProductBasicPriceInfo($value, $products[$key]->product_price);
        }
        if ($value->tax_id) {
            $products[$key]->tax = $taxes[$value->tax_id];
        }
        if ($jshopConfig->product_list_show_manufacturer && $value->product_manufacturer_id && isset($manufacturers[$value->product_manufacturer_id])) {
            $products[$key]->manufacturer = $manufacturers[$value->product_manufacturer_id];
        } else {
            $products[$key]->manufacturer = new stdClass();
            $products[$key]->manufacturer->name = '';
        }
        if ($jshopConfig->admin_show_product_extra_field) {
            $products[$key]->extra_field = getProductExtraFieldForProduct($value);
        } else {
            $products[$key]->extra_field = '';
        }
        if ($jshopConfig->product_list_show_vendor) {
            $vendordata = $vendors[$value->vendor_id];
            $vendordata->products = SEFLink("index.php?option=com_jshopping&controller=vendor&task=products&vendor_id=" . $vendordata->id, 1);
            $products[$key]->vendor = $vendordata;
        } else {
            $products[$key]->vendor = '';
        }
        if ($jshopConfig->hide_delivery_time_out_of_stock && $products[$key]->product_quantity <= 0) {
            $products[$key]->delivery_times_id = 0;
            $value->delivery_times_id = 0;
        }
        if ($jshopConfig->show_delivery_time && $value->delivery_times_id) {
            $products[$key]->delivery_time = $deliverytimes[$value->delivery_times_id];
        } else {
            $products[$key]->delivery_time = '';
        }
        $products[$key]->_display_price = getDisplayPriceForProduct($products[$key]->product_price);
        if (!$products[$key]->_display_price) {
            $products[$key]->product_old_price = 0;
            $products[$key]->product_price_default = 0;
            $products[$key]->basic_price_info['price_show'] = 0;
            $products[$key]->tax = 0;
            $jshopConfig->show_plus_shipping_in_product = 0;
        }
        if ($jshopConfig->product_list_show_qty_stock) {
            $products[$key]->qty_in_stock = getDataProductQtyInStock($products[$key]);
        }
        $image = getPatchProductImage($products[$key]->image, 'thumb');
        $products[$key]->product_name_image = $products[$key]->image;
        $products[$key]->product_thumb_image = $image;
        if (!$image) {
            $image = $noimage;
        }
        $products[$key]->image = $image_path . "/" . $image;
        $products[$key]->template_block_product = "product.php";
        if (!$jshopConfig->admin_show_product_labels) {
            $products[$key]->label_id = null;
        }
        if ($products[$key]->label_id) {
            $image = getNameImageLabel($products[$key]->label_id);
            if ($image) {
                $products[$key]->_label_image = $jshopConfig->image_labels_live_path . "/" . $image;
            }
            $products[$key]->_label_name = getNameImageLabel($products[$key]->label_id, 2);
        }
        if ($jshopConfig->display_short_descr_multiline) {
            $products[$key]->short_description = nl2br($products[$key]->short_description);
        }
    }
    if ($setUrl) {
        addLinkToProducts($products, 0, 1);
    }
    $dispatcher->trigger('onListProductUpdateData', array(&$products));
    return $products;
}
Beispiel #2
0
 function getVendorInfo()
 {
     $vendors = JSFactory::getAllVendor();
     if (isset($vendors[$this->vendor_id])) {
         return $vendors[$this->vendor_id];
     } else {
         return null;
     }
 }