Ejemplo n.º 1
0
 public function gbasefeed($data)
 {
     $producthelper = new producthelper();
     $stockroomhelper = new rsstockroomhelper();
     $shippinghelper = new shipping();
     $unpublished_data = $data['unpublished_data'];
     $cid = $data['cid'];
     $url = JURI::root();
     $currency = new CurrencyHelper();
     $product_img_url = $url . 'components/com_redshop/assets/images/product/';
     $file_path = JPATH_COMPONENT_SITE . "/assets/document/gbase";
     $file_name = $file_path . "/product.xml";
     if (count($cid)) {
         $cids = implode(',', $cid);
         if ($unpublished_data == 1) {
             $query = "SELECT p.*,m.manufacturer_name FROM " . $this->_table_prefix . "product AS p " . " LEFT JOIN " . $this->_table_prefix . "manufacturer AS m" . " ON p.manufacturer_id = m.manufacturer_id" . " WHERE p.product_id IN (" . $cids . ")";
         } else {
             $query = "SELECT p.*,m.manufacturer_name FROM " . $this->_table_prefix . "product AS p " . " LEFT JOIN " . $this->_table_prefix . "manufacturer AS m" . " ON p.manufacturer_id = m.manufacturer_id" . " WHERE p.product_id IN (" . $cids . ") and p.published =1";
         }
         $this->_db->setQuery($query);
         $rs = $this->_db->loadObjectlist();
         // For shipping information
         $shippingArr = $shippinghelper->getShopperGroupDefaultShipping();
         $default_shipping = 0.0;
         $shipping_rate = $currency->convert(number_format($shippingArr['shipping_rate'], PRICE_DECIMAL, PRICE_SEPERATOR, THOUSAND_SEPERATOR), '', CURRENCY_CODE);
         $default_shipping = count($shippingArr) > 0 ? $shipping_rate : number_format($default_shipping, PRICE_DECIMAL, PRICE_SEPERATOR, THOUSAND_SEPERATOR);
         $default_shipping_country = DEFAULT_SHIPPING_COUNTRY;
         $xml_code = '<?xml version="1.0" encoding="UTF-8" ';
         $xml_code .= '<rss version ="2.0" xmlns:g="http://base.google.com/ns/1.0" xmlns:c="http://base.google.com/cns/1.0">';
         $xml_code .= "<channel>";
         for ($i = 0; $i < count($rs); $i++) {
             // For additional images
             $additional_images = $producthelper->getAdditionMediaImage($rs[$i]->product_id, $section = "product", $mediaType = "images");
             $add_image = "";
             for ($ad = 0; $ad < 10; $ad++) {
                 if (trim($additional_images[$ad]->product_full_image) != trim($additional_images[$ad]->media_name) && trim($additional_images[$ad]->media_name) != "") {
                     $add_image .= "<g:additional_image_link>" . $product_img_url . htmlspecialchars($additional_images[$ad]->media_name, ENT_NOQUOTES, "UTF-8") . "</g:additional_image_link>";
                 }
             }
             // For getting product Category
             $category_name = $producthelper->getCategoryNameByProductId($rs[$i]->product_id);
             if (USE_STOCKROOM == 1) {
                 // For c**t attributes
                 $attributes_set = array();
                 if ($rs[$i]->attribute_set_id > 0) {
                     $attributes_set = $producthelper->getProductAttribute(0, $rs[$i]->attribute_set_id, 0, 1);
                 }
                 $attributes = $producthelper->getProductAttribute($rs[$i]->product_id);
                 $attributes = array_merge($attributes, $attributes_set);
                 $totalatt = count($attributes);
                 // Get stock details
                 $isStockExists = $stockroomhelper->isStockExists($rs[$i]->product_id);
                 if ($totalatt > 0 && !$isStockExists) {
                     $isStockExists = $stockroomhelper->isAttributeStockExists($product_id);
                 }
                 $isPreorderStockExists = $stockroomhelper->isPreorderStockExists($product_id);
                 if ($totalatt > 0 && !$isPreorderStockExists) {
                     $isPreorderStockExists = $stockroomhelper->isAttributePreorderStockExists($product_id);
                 }
                 if (!$isStockExists) {
                     $product_preorder = $rs[$i]->preorder;
                     if ($product_preorder == "global" && ALLOW_PRE_ORDER || $product_preorder == "yes" || $product_preorder == "" && ALLOW_PRE_ORDER) {
                         if (!$isPreorderStockExists) {
                             $product_status = JText::_('COM_REDSHOP_OUT_OF_STOCK');
                         } else {
                             $product_status = JText::_('COM_REDSHOP_PREORDER');
                         }
                     } else {
                         $product_status = JText::_('COM_REDSHOP_OUT_OF_STOCK');
                     }
                 } else {
                     $product_status = JText::_('COM_REDSHOP_AVAILABLE_FOR_ORDER');
                 }
             } else {
                 $product_status = JText::_('COM_REDSHOP_AVAILABLE_FOR_ORDER');
             }
             $product_on_sale = 0;
             if ($rs[$i]->product_on_sale == 1 && ($rs[$i]->discount_stratdate == 0 && $rs[$i]->discount_enddate == 0 || $rs[$i]->discount_stratdate <= time() && $rs[$i]->discount_enddate >= time())) {
                 $product_on_sale = 1;
             }
             // For price and vat settings
             $product_price = $rs[$i]->product_price;
             $discount_price = $rs[$i]->discount_price;
             $sale_price = $product_on_sale == 1 ? $discount_price : $product_price;
             $price_vat = $producthelper->getGoogleVatRates($rs[$i]->product_id, $product_price, USE_TAX_EXEMPT);
             $sale_price_vat = $producthelper->getGoogleVatRates($rs[$i]->product_id, $sale_price, USE_TAX_EXEMPT);
             if (DEFAULT_VAT_COUNTRY != "USA") {
                 $product_price = $rs[$i]->product_price + $price_vat;
                 $sale_price = $sale_price + $sale_price_vat;
             }
             $product_price = $currency->convert(number_format($product_price, PRICE_DECIMAL, PRICE_SEPERATOR, THOUSAND_SEPERATOR), '', CURRENCY_CODE);
             $discount_price = $currency->convert(number_format($discount_price, PRICE_DECIMAL, PRICE_SEPERATOR, THOUSAND_SEPERATOR), '', CURRENCY_CODE);
             $sale_price = $currency->convert(number_format($sale_price, PRICE_DECIMAL, PRICE_SEPERATOR, THOUSAND_SEPERATOR), '', CURRENCY_CODE);
             $price_vat = $currency->convert(number_format($price_vat, PRICE_DECIMAL, PRICE_SEPERATOR, THOUSAND_SEPERATOR), '', CURRENCY_CODE);
             $product_url = $url . "index.php?option=com_redshop&amp;view=product&amp;pid=" . $rs[$i]->product_id;
             $xml_code .= "\n<item>";
             $xml_code .= "\n<g:id>" . htmlspecialchars($rs[$i]->product_id, ENT_NOQUOTES, "UTF-8") . "</g:id>";
             $xml_code .= "\n<title>" . htmlspecialchars($rs[$i]->product_name, ENT_NOQUOTES, "UTF-8") . "</title>";
             $xml_code .= "\n<description>'" . htmlspecialchars($rs[$i]->product_s_desc, ENT_NOQUOTES, "UTF-8") . "'</description>";
             $xml_code .= "\n<g:product_type>'" . htmlspecialchars($category_name, ENT_NOQUOTES, "UTF-8") . "'</g:product_type>";
             $xml_code .= "\n<link>" . htmlspecialchars($product_url, ENT_NOQUOTES, "UTF-8") . "</link>";
             $xml_code .= "\n<g:image_link>" . $product_img_url . htmlspecialchars($rs[$i]->product_full_image, ENT_NOQUOTES, "UTF-8") . "</g:image_link>";
             $xml_code .= "\n<g:brand>" . htmlspecialchars($rs[$i]->manufacturer_name, ENT_NOQUOTES, "UTF-8") . "</g:brand>";
             $xml_code .= "\n<g:condition>New</g:condition>";
             $xml_code .= "\n<g:availability>" . $product_status . "</g:availability>";
             $xml_code .= "\n<g:price>" . $product_price . " " . CURRENCY_CODE . "</g:price>";
             $xml_code .= "\n<g:sale_price>" . $sale_price . " " . CURRENCY_CODE . "</g:sale_price>";
             if ($product_on_sale == 1) {
                 $discount_start_date = date("c", $rs[$i]->discount_stratdate);
                 $discount_end_date = date("c", $rs[$i]->discount_enddate);
                 $xml_code .= "\n<g:sale_price_effective_date>" . $discount_start_date . "/" . $discount_end_date . "</g:sale_price_effective_date>";
             }
             $xml_code .= "\n<g:mpn>" . htmlspecialchars($rs[$i]->product_number, ENT_NOQUOTES, "UTF-8") . "</g:mpn>";
             if (DEFAULT_VAT_COUNTRY == "USA" || DEFAULT_VAT_COUNTRY == "GBR") {
                 $xml_code .= "\n<g:delivery>\r\n\t\t\t\t\t\t<g:country>" . DEFAULT_SHIPPING_COUNTRY . "</g:country>\r\n\t\t\t\t\t    <g:price>" . $default_shipping . " " . CURRENCY_CODE . "</g:price>\r\n\t\t\t\t\t</g:delivery>";
                 if ($rs[$i]->weight != 0) {
                     $xml_code .= "\n<g:delivery_weight>" . $rs[$i]->weight . " " . DEFAULT_WEIGHT_UNIT . "</g:delivery_weight>";
                 }
             } else {
                 $xml_code .= "\n<g:shipping>\r\n\t\t\t\t\t\t<g:country>" . DEFAULT_SHIPPING_COUNTRY . "</g:country>\r\n\t\t\t\t\t    <g:price>" . $default_shipping . " " . CURRENCY_CODE . "</g:price>\r\n\t\t\t\t\t</g:shipping>";
                 if ($rs[$i]->weight != 0) {
                     $xml_code .= "\n<g:shipping_weight>" . $rs[$i]->weight . " " . DEFAULT_WEIGHT_UNIT . "</g:shipping_weight>";
                 }
             }
             if (DEFAULT_VAT_COUNTRY == "USA") {
                 $xml_code .= "\n<g:tax>\r\n\t\t\t\t\t\t\t\t   <g:country>US</g:country>\r\n\t\t\t\t\t\t\t\t   <g:rate>" . $price_vat . "</g:rate>\r\n\t\t\t\t\t\t\t  </g:tax>";
             }
             $xml_code .= "\n" . $add_image;
             $xml_code .= "\n</item>";
         }
         $xml_code .= '</channel>';
         $xml_code .= '</rss>';
         $fp = fopen($file_name, "w");
         fwrite($fp, $xml_code);
         fclose($fp);
         if (!file_exists($file_name)) {
             return false;
         } else {
             return true;
         }
     }
     return false;
 }
Ejemplo n.º 2
0
 public function getproductStockStatus($product_id = 0, $totalatt = 0, $selectedpropertyId = 0, $selectedsubpropertyId = 0)
 {
     $stockroomhelper = new rsstockroomhelper();
     $producDetail = $this->getProductById($product_id);
     $product_preorder = trim($producDetail->preorder);
     $rsltdata = array();
     $rsltdata['preorder'] = 0;
     $rsltdata['preorder_stock'] = 0;
     if ($selectedpropertyId) {
         if ($selectedsubpropertyId) {
             // Count status for selected subproperty
             $stocksts = $stockroomhelper->isStockExists($selectedsubpropertyId, "subproperty");
             if (!$stocksts && ($product_preorder == "global" && ALLOW_PRE_ORDER || $product_preorder == "yes")) {
                 $prestocksts = $stockroomhelper->isPreorderStockExists($selectedsubpropertyId, "subproperty");
                 $rsltdata['preorder'] = 1;
                 $rsltdata['preorder_stock'] = $prestocksts;
             }
         } else {
             // Count status for selected property
             $stocksts = $stockroomhelper->isStockExists($selectedpropertyId, "property");
             if (!$stocksts && ($product_preorder == "global" && ALLOW_PRE_ORDER || $product_preorder == "yes")) {
                 $prestocksts = $stockroomhelper->isPreorderStockExists($selectedpropertyId, "property");
                 $rsltdata['preorder'] = 1;
                 $rsltdata['preorder_stock'] = $prestocksts;
             }
         }
     } else {
         $stocksts = $stockroomhelper->getFinalStockofProduct($product_id, $totalatt);
         if (!$stocksts && ($product_preorder == "global" && ALLOW_PRE_ORDER || $product_preorder == "yes")) {
             $prestocksts = $stockroomhelper->getFinalPreorderStockofProduct($product_id, $totalatt);
             $rsltdata['preorder'] = 1;
             $rsltdata['preorder_stock'] = $prestocksts;
         }
     }
     $rsltdata['regular_stock'] = $stocksts;
     return $rsltdata;
 }
Ejemplo n.º 3
0
JHTML::Script('redBOX.js', 'components/com_redshop/assets/js/', false);
JHTML::Stylesheet('fetchscript.css', 'components/com_redshop/assets/css/');
$producthelper = new producthelper();
$redhelper = new redhelper();
$redTemplate = new Redtemplate();
$extraField = new extraField();
$stockroomhelper = new rsstockroomhelper();
$config = new Redconfiguration();
$module_id = "mod_" . $module->id;
echo "<div id='" . $module_id . "' class='mod_redshop_products_wrapper'>";
for ($i = 0; $i < count($rows); $i++) {
    $row = $rows[$i];
    if ($show_stockroom_status == 1) {
        $isStockExists = $stockroomhelper->isStockExists($row->product_id);
        if (!$isStockExists) {
            $isPreorderStockExists = $stockroomhelper->isPreorderStockExists($row->product_id);
        }
        if (!$isStockExists) {
            $product_preorder = $row->preorder;
            if ($product_preorder == "global" && ALLOW_PRE_ORDER || $product_preorder == "yes" || $product_preorder == "" && ALLOW_PRE_ORDER) {
                if (!$isPreorderStockExists) {
                    $stock_status = "<div  class='mod_product_outstock' align='center'>" . JText::_('COM_REDSHOP_OUT_OF_STOCK') . "</div>";
                } else {
                    $stock_status = "<div  class='mod_product_preorder' align='center'>" . JText::_('COM_REDSHOP_PRE_ORDER') . "</div>";
                }
            } else {
                $stock_status = "<div  class='mod_product_outstock' align='center'>" . JText::_('COM_REDSHOP_OUT_OF_STOCK') . "</div>";
            }
        } else {
            $stock_status = "<div  class='mod_product_instock' align='center'>" . JText::_('COM_REDSHOP_AVAILABLE_STOCK') . "</div>";
        }