Beispiel #1
0
 /**
  * Load the attributes for export
  *
  * @return  void
  */
 private function loadAttributes()
 {
     $producthelper = new producthelper();
     $db = JFactory::getDbo();
     $query = "SELECT * FROM `#__redshop_product` ORDER BY product_id asc ";
     $this->_db->setQuery($query);
     $cur = $this->_db->loadObjectList();
     $ret = null;
     if (count($cur) > 0) {
         $redhelper = new redhelper();
         $isrecrm = false;
         if ($redhelper->isredCRM()) {
             $isrecrm = true;
         }
         for ($i = 0; $i < count($cur); $i++) {
             if ($i == 0) {
                 echo '"product_number","attribute_name","attribute_ordering","allow_multiple_selection","hide_attribute_price","attribute_required","display_type","property_name","property_stock"';
                 if ($isrecrm) {
                     echo ',"property_stock_placement"';
                 }
                 echo ',"property_ordering","property_virtual_number","setdefault_selected","setdisplay_type","oprand","property_price","property_image","property_main_image","subattribute_color_name","subattribute_stock"';
                 if ($isrecrm) {
                     echo ',"subattribute_stock_placement"';
                 }
                 echo ',"subattribute_color_ordering","subattribute_setdefault_selected","subattribute_color_title","subattribute_virtual_number","subattribute_color_oprand","required_sub_attribute","subattribute_color_price","subattribute_color_image","delete"';
                 echo "\r\n";
             }
             // Added attribute of products
             $attribute = $producthelper->getProductAttribute($cur[$i]->product_id);
             $attr = array();
             for ($att = 0; $att < count($attribute); $att++) {
                 if ($attribute[$att]->attribute_name != "") {
                     echo '"' . $cur[$i]->product_number . '","' . $attribute[$att]->attribute_name . '","' . $attribute[$att]->ordering . '","' . $attribute[$att]->allow_multiple_selection . '","' . $attribute[$att]->hide_attribute_price . '","' . $attribute[$att]->attribute_required . '","' . $attribute[$att]->display_type . '"';
                     if ($isrecrm) {
                         echo ',,';
                     }
                     echo ',,,,,,,,,,,,,,,,"0"';
                     echo "\r\n";
                     $att_property = $producthelper->getAttibuteProperty(0, $attribute[$att]->attribute_id);
                     for ($prop = 0; $prop < count($att_property); $prop++) {
                         $property_image = "";
                         $property_main_image = "";
                         $main_attribute_stock = "";
                         $sel_arrtibute_stock = "select * from `#__redshop_product_attribute_stockroom_xref` where section_id='" . $att_property[$prop]->property_id . "'";
                         $this->_db->setQuery($sel_arrtibute_stock);
                         $fetch_arrtibute_stock = $this->_db->loadObjectList();
                         for ($h = 0; $h < count($fetch_arrtibute_stock); $h++) {
                             $main_attribute_stock .= $fetch_arrtibute_stock[$h]->stockroom_id . ":" . $fetch_arrtibute_stock[$h]->quantity . "#";
                         }
                         if ($att_property[$prop]->property_image != "") {
                             $property_image = REDSHOP_FRONT_IMAGES_ABSPATH . 'product_attributes/' . $att_property[$prop]->property_image;
                         }
                         if ($att_property[$prop]->property_main_image != "") {
                             $property_main_image = REDSHOP_FRONT_IMAGES_ABSPATH . 'property/' . $att_property[$prop]->property_main_image;
                         }
                         echo '"' . $cur[$i]->product_number . '","' . $attribute[$att]->attribute_name . '",,,,,,"' . $att_property[$prop]->property_name . '","' . $main_attribute_stock . '"';
                         if ($isrecrm) {
                             $main_attribute_stock_placement = "";
                             // Initialiase variables.
                             $query = $this->_db->getQuery(true);
                             // Prepare query.
                             $query->select('stock_placement');
                             $query->from('#__redcrm_attribute_stock_placement');
                             $query->where('section = "property"');
                             $query->where('section_id = "' . $att_property[$prop]->property_id . '"');
                             // Inject the query and load the result.
                             $this->_db->setQuery($query);
                             $main_attribute_stock_placement = $this->_db->loadResult();
                             echo ',"' . $main_attribute_stock_placement . '"';
                         }
                         echo ',"' . $att_property[$prop]->ordering . '","' . $att_property[$prop]->property_number . '","' . $att_property[$prop]->setdefault_selected . '","' . $att_property[$prop]->setdisplay_type . '","' . $att_property[$prop]->oprand . '","' . $att_property[$prop]->property_price . '","' . $property_image . '","' . $property_main_image . '"';
                         if ($isrecrm) {
                             echo ',';
                         }
                         echo ',,,,,,,,,"0"';
                         echo "\n";
                         $subatt_property = $producthelper->getAttibuteSubProperty(0, $att_property[$prop]->property_id);
                         for ($subprop = 0; $subprop < count($subatt_property); $subprop++) {
                             $subattribute_color_image = "";
                             $main_attribute_stock_sub = "";
                             $sel_arrtibute_stock_sub = "select * from `#__redshop_product_attribute_stockroom_xref` where section_id='" . $subatt_property[$subprop]->subattribute_color_id . "'";
                             $this->_db->setQuery($sel_arrtibute_stock_sub);
                             $fetch_arrtibute_stock_sub = $this->_db->loadObjectList();
                             for ($b = 0; $b < count($fetch_arrtibute_stock_sub); $b++) {
                                 $main_attribute_stock_sub .= $fetch_arrtibute_stock_sub[$b]->stockroom_id . ":" . $fetch_arrtibute_stock_sub[$b]->quantity . "#";
                             }
                             if ($subatt_property[$subprop]->subattribute_color_image != "") {
                                 $subattribute_color_image = REDSHOP_FRONT_IMAGES_ABSPATH . 'subcolor/' . $subatt_property[$subprop]->subattribute_color_image;
                             }
                             echo '"' . $cur[$i]->product_number . '","' . $attribute[$att]->attribute_name . '",,,,,,"' . $att_property[$prop]->property_name . '"';
                             if ($isrecrm) {
                                 echo ',';
                             }
                             echo ',,,,,,,,,,"' . $subatt_property[$subprop]->subattribute_color_name . '","' . $main_attribute_stock_sub . '"';
                             if ($isrecrm) {
                                 $main_attribute_stock_sub_placement = "";
                                 // Initialiase variables.
                                 $query = $this->_db->getQuery(true);
                                 // Prepare query.
                                 $query->select('stock_placement');
                                 $query->from('#__redcrm_attribute_stock_placement');
                                 $query->where('section = "subproperty"');
                                 $query->where('section_id = "' . $subatt_property[$subprop]->subattribute_color_id . '"');
                                 // Inject the query and load the result.
                                 $this->_db->setQuery($query);
                                 $main_attribute_stock_sub_placement = $this->_db->loadResult();
                                 echo ',"' . $main_attribute_stock_sub_placement . '"';
                             }
                             echo ',"' . $subatt_property[$subprop]->ordering . '","' . $subatt_property[$subprop]->setdefault_selected . '","' . $subatt_property[$subprop]->subattribute_color_title . '","' . $subatt_property[$subprop]->subattribute_color_number . '","' . $subatt_property[$subprop]->oprand . '","' . $att_property[$prop]->setrequire_selected . '","' . $subatt_property[$subprop]->subattribute_color_price . '","' . $subattribute_color_image . '","0"';
                             echo "\n";
                         }
                     }
                 }
             }
         }
     }
 }
Beispiel #2
0
if ($product_item->product_full_image) {
    $product_image = JURI::base(true) . '/components/com_redshop/assets/images/product/' . $product_item->product_full_image;
}
$product_template = $slide->template_description;
$product_template = str_replace("{product_image}", '<img src="' . $product_image . '">', $product_template);
$product_template = str_replace("{product_name}", $product_item->product_name, $product_template);
$product_template = str_replace("{product_description}", $product_item->product_s_desc, $product_template);
$product_template = str_replace("{product_price}", $product_item->product_price, $product_template);
$product_template = str_replace("{product_quantity}", "<input class=\"product-quantity\" type=\"number\" value=\"1\" style=\"width:30px\">", $product_template);
$product_template = str_replace("{addtocart_button}", "<input class=\"addtocart-button\" type=\"submit\" value=\"Add to cart\" style=\"width:100px\">", $product_template);
require_once JPATH_SITE . '/components/com_redshop/helpers/helper.php';
$product_helper = new producthelper();
$attribute_list = $product_helper->getProductAttribute($product_item->product_id);
$product_attribute_html = "";
foreach ($attribute_list as $attribute) {
    $attribute_properties = $product_helper->getAttibuteProperty(0, $attribute->attribute_id);
    $select_row = new stdClass();
    $select_row->value = "0";
    $select_row->text = "Select " . $attribute->text;
    $attribute_properties = array_merge(array(0 => $select_row), $attribute_properties);
    $product_attribute_html .= "<div>" . JHtml::_('select.genericlist', $attribute_properties, '', 'class="product-attribute" name="product-attribute" style="width:100px"') . "</div>";
}
$product_template = str_replace("{product_attribute}", $product_attribute_html, $product_template);
?>

<li>
	<div class="content">
		<img src="<?php 
echo $slide->imgslide;
?>
" />
Beispiel #3
0
 function replaceAttributeData($product_id = 0, $accessory_id = 0, $attributes = array(), $user_id, $uniqueid = "")
 {
     $uri = JURI::getInstance();
     $url = $uri->root();
     $producthelper = new producthelper();
     $attributelist = "";
     $product = $producthelper->getProductById($product_id);
     if ($accessory_id != 0) {
         $prefix = $uniqueid . "acc_";
     } else {
         $prefix = $uniqueid . "prd_";
     }
     $attributelist .= '<span id="att_lebl" style="display:none;">' . JText::_('COM_REDSHOP_ATTRIBUTE_IS_REQUIRED') . '</span>';
     for ($a = 0; $a < count($attributes); $a++) {
         $property = $producthelper->getAttibuteProperty(0, $attributes[$a]->attribute_id);
         if ($attributes[$a]->text != "" && count($property) > 0) {
             $commonid = $prefix . $product_id . '_' . $accessory_id . '_' . $attributes[$a]->attribute_id;
             $hiddenattid = 'attribute_id_' . $prefix . $product_id . '_' . $accessory_id;
             $propertyid = 'property_id_' . $commonid;
             for ($i = 0; $i < count($property); $i++) {
                 $attributes_property_vat = 0;
                 if ($property[$i]->property_price > 0) {
                     $propertyOprand = $property[$i]->oprand;
                     $propertyPrice = $producthelper->getProductFormattedPrice($property[$i]->property_price);
                     // Get product vat to include.
                     $attributes_property_vat = $producthelper->getProducttax($product_id, $property[$i]->property_price, $user_id);
                     $property[$i]->property_price += $attributes_property_vat;
                     $propertyPriceWithVat = $producthelper->getProductFormattedPrice($property[$i]->property_price);
                     $property[$i]->text = urldecode($property[$i]->property_name) . " ({$propertyOprand} {$propertyPrice} excl. vat / {$propertyPriceWithVat})";
                 } else {
                     $property[$i]->text = urldecode($property[$i]->property_name);
                 }
                 $attributelist .= '<input type="hidden" id="' . $propertyid . '_oprand' . $property[$i]->value . '" value="' . $property[$i]->oprand . '" />';
                 $attributelist .= '<input type="hidden" id="' . $propertyid . '_protax' . $property[$i]->value . '" value="' . $attributes_property_vat . '" />';
                 $attributelist .= '<input type="hidden" id="' . $propertyid . '_proprice' . $property[$i]->value . '" value="' . $property[$i]->property_price . '" />';
             }
             $tmp_array = array();
             $tmp_array[0] = new stdClass();
             $tmp_array[0]->value = 0;
             $tmp_array[0]->text = JText::_('COM_REDSHOP_SELECT') . " " . urldecode($attributes[$a]->text);
             $new_property = array_merge($tmp_array, $property);
             $at_id = $product->product_id;
             $chklist = "";
             if ($attributes[$a]->allow_multiple_selection) {
                 for ($chk = 0; $chk < count($property); $chk++) {
                     if ($attributes[$a]->attribute_required == 1) {
                         $required = "required='" . $attributes[$a]->attribute_required . "'";
                     } else {
                         $required = "";
                     }
                     $chklist .= "<br /><input type='checkbox' value='" . $property[$chk]->value . "' name='" . $propertyid . "[]' id='" . $propertyid . "' class='inputbox' attribute_name='" . $attributes[$a]->attribute_name . "' required='" . $attributes[$a]->attribute_required . "' onchange='javascript:changeOfflinePropertyDropdown(\"" . $product_id . "\",\"" . $accessory_id . "\",\"" . $attributes[$a]->attribute_id . "\",\"" . $uniqueid . "\");'  />&nbsp;" . $property[$chk]->text;
                 }
             } else {
                 $chklist = JHTML::_('select.genericlist', $new_property, $propertyid . '[]', 'id="' . $propertyid . '"  class="inputbox" size="1" attribute_name="' . $attributes[$a]->attribute_name . '" required="' . $attributes[$a]->attribute_required . '" onchange="javascript:changeOfflinePropertyDropdown(\'' . $product_id . '\',\'' . $accessory_id . '\',\'' . $attributes[$a]->attribute_id . '\',\'' . $uniqueid . '\');" ', 'value', 'text', '');
             }
             $lists['property_id'] = $chklist;
             $attributelist .= "<input type='hidden' name='" . $hiddenattid . "[]' value='" . $attributes[$a]->value . "' />";
             if ($attributes[$a]->attribute_required > 0) {
                 $pos = ASTERISK_POSITION > 0 ? urldecode($attributes[$a]->text) . "<span id='asterisk_right'> * " : "<span id='asterisk_left'>* </span>" . urldecode($attributes[$a]->text);
                 $attr_title = $pos;
             } else {
                 $attr_title = urldecode($attributes[$a]->text);
             }
             $attributelist .= "<tr><td>" . $attr_title . " : " . $lists['property_id'] . "</td></tr>";
             $attributelist .= "<tr><td><div id='property_responce" . $commonid . "' style='display:none;'></td></tr>";
         }
     }
     return $attributelist;
 }
Beispiel #4
0
 public function getTotalProperty($productId)
 {
     $producthelper = new producthelper();
     // Collect Attributes
     $attribute = $producthelper->getProductAttribute($productId);
     $attributeId = $attribute[0]->value;
     // Collect Property
     $property = $producthelper->getAttibuteProperty(0, $attributeId, $productId);
     return count($property);
 }
Beispiel #5
0
 function getProductData($userData)
 {
     $producthelper = new producthelper();
     if ($userData->product_id) {
         $productDetail = "";
         $product_data = $producthelper->getProductById($userData->product_id);
         if ($userData->subproperty_id) {
             $subproperty_data = $producthelper->getAttibuteSubProperty($userData->subproperty_id);
             $property_data = $producthelper->getAttibuteProperty($userData->property_id);
         } else {
             if ($userData->property_id) {
                 $property_data = $producthelper->getAttibuteProperty($userData->property_id);
             }
         }
         $productData = array();
         $productDetail = $product_data->product_name;
         if (count($property_data) > 0) {
             $productDetail .= "<br/>" . $property_data['property_name'];
         }
         if (count($subproperty_data) > 0) {
             $productDetail .= "<br/>" . $subproperty_data['subproperty_name'];
         }
         $productData['product_name'] = $product_data->product_name;
         $productData['product_detail'] = $productDetail;
         return $productData;
     }
 }
Beispiel #6
0
$section_id = JRequest::getCmd('section_id');
$model = $this->getModel('media');
$sectionadata = array();
$sectiona_primary_image = "";
$section_name = "";
$directory = $media_section;
if ($showbuttons == 1) {
    switch ($media_section) {
        case "product":
            $sectionadata = $producthelper->getProductById($section_id);
            $section_name = $sectionadata->product_name;
            $sectiona_primary_image = $sectionadata->product_full_image;
            $directory = $media_section;
            break;
        case "property":
            $sectionadata = $producthelper->getAttibuteProperty($section_id);
            $section_name = $sectionadata[0]->property_name;
            $sectiona_primary_image = $sectionadata[0]->property_main_image;
            $directory = 'property';
            break;
        case "subproperty":
            $sectionadata = $producthelper->getAttibuteSubProperty($section_id);
            $section_name = $sectionadata[0]->subattribute_color_name;
            $sectiona_primary_image = $sectionadata[0]->subattribute_color_main_image;
            $directory = 'subproperty';
            break;
    }
}
if ($showbuttons == 1) {
    ?>
	<fieldset>
 /**
  * Function delete_prop.
  *
  * @param   int  $attribute_id  attribute_id
  * @param   int  $property_id   property_id
  *
  * @return  void
  */
 public function delete_prop($attribute_id, $property_id)
 {
     $producthelper = new producthelper();
     if ($property_id) {
         $property = $producthelper->getAttibuteProperty($property_id, $attribute_id);
     } else {
         $property = $producthelper->getAttibuteProperty(0, $attribute_id);
     }
     for ($j = 0; $j < count($property); $j++) {
         $property_id = $property[$j]->property_id;
         $query = "DELETE FROM `" . $this->table_prefix . "product_attribute_property`\r\n\t\t\t\t\t  WHERE `attribute_id`='" . $attribute_id . "'\r\n\t\t\t\t\t  AND `property_id` = '" . $property[$j]->property_id . "' ";
         $this->_db->setQuery($query);
         if ($this->_db->query()) {
             $this->delete_image($property[$j]->property_image, 'product_attributes');
             $this->delete_subprop(0, $property_id);
         }
     }
     exit;
 }
 public function removepropertyImage($pid)
 {
     $producthelper = new producthelper();
     $image = $producthelper->getAttibuteProperty($pid);
     $image = $image[0];
     $imagename = $image->property_image;
     $imagethumbsrcphy = REDSHOP_FRONT_IMAGES_RELPATH . "product_attributes/thumb/" . $imagename;
     if (is_file($imagethumbsrcphy)) {
         @unlink($imagethumbsrcphy);
     }
     $imagesrc = REDSHOP_FRONT_IMAGES_ABSPATH . "product_attributes/" . $imagename;
     $imagesrcphy = REDSHOP_FRONT_IMAGES_RELPATH . "product_attributes/" . $imagename;
     if (is_file($imagesrcphy)) {
         @unlink($imagesrcphy);
     }
     $query = "UPDATE `" . $this->_table_prefix . "product_attribute_property` SET `property_image` = '' WHERE `property_id` = " . $pid;
     $this->_db->setQuery($query);
     if (!$this->_db->Query()) {
         return false;
     }
     return true;
 }
Beispiel #9
0
 public function getFinalPreorderStockofProduct($product_id, $totalatt)
 {
     $producthelper = new producthelper();
     $isStockExists = $this->isPreorderStockExists($product_id);
     $isPreorderStockExists = '';
     if ($totalatt > 0 && !$isStockExists) {
         $property = $producthelper->getAttibuteProperty(0, 0, $product_id);
         for ($att_j = 0; $att_j < count($property); $att_j++) {
             $isSubpropertyStock = false;
             $sub_property = $producthelper->getAttibuteSubProperty(0, $property[$att_j]->property_id);
             for ($sub_j = 0; $sub_j < count($sub_property); $sub_j++) {
                 $isSubpropertyStock = $this->isPreorderStockExists($sub_property[$sub_j]->subattribute_color_id, 'subproperty');
                 if ($isSubpropertyStock) {
                     $isStockExists = $isSubpropertyStock;
                     break;
                 }
             }
             if ($isSubpropertyStock) {
                 break;
             } else {
                 $isPropertystock = $this->isPreorderStockExists($property[$att_j]->property_id, "property");
                 if ($isPropertystock) {
                     $isStockExists = $isPropertystock;
                     break;
                 }
             }
         }
     }
     return $isStockExists;
 }
Beispiel #10
0
// Replace product in stock tags
$template_desc = $producthelper->replaceProductInStock($this->data->product_id, $template_desc, $attributes, $attribute_template);
// Product attribute  Start
$totalatt = count($attributes);
$template_desc = $producthelper->replaceAttributeData($this->data->product_id, 0, 0, $attributes, $template_desc, $attribute_template, $isChilds);
// Product attribute  End
$pr_number = $this->data->product_number;
$preselectedresult = array();
$moreimage_response = '';
$attributeproductStockStatus = null;
$selectedpropertyId = 0;
$selectedsubpropertyId = 0;
if (count($attributes) > 0 && count($attribute_template) > 0) {
    for ($a = 0; $a < count($attributes); $a++) {
        $selectedId = array();
        $property = $producthelper->getAttibuteProperty(0, $attributes[$a]->attribute_id);
        if ($attributes[$a]->text != "" && count($property) > 0) {
            for ($i = 0; $i < count($property); $i++) {
                if ($property[$i]->setdefault_selected) {
                    $selectedId[] = $property[$i]->property_id;
                }
            }
            if (count($selectedId) > 0) {
                $selectedpropertyId = $selectedId[count($selectedId) - 1];
                $subproperty = $producthelper->getAttibuteSubProperty(0, $selectedpropertyId);
                $selectedId = array();
                for ($sp = 0; $sp < count($subproperty); $sp++) {
                    if ($subproperty[$sp]->setdefault_selected) {
                        $selectedId[] = $subproperty[$sp]->subattribute_color_id;
                    }
                }