/** * Get quantity for a given attribute combination * Check if quantity is enough to deserve customer * * @param integer $product_attribute_id Product attribute combination id * @param integer $qty Quantity needed * @return boolean Quantity is available or not */ public static function checkAttributeQty($product_attribute_id, $qty, JeproshopShopModelShop $shop = null) { if (!$shop) { $shop = JeproshopContext::getContext()->shop; } $result = JeproshopStockAvailableModelStockAvailable::getQuantityAvailableByProduct(null, (int) $product_attribute_id, $shop->shop_id); return $result && $qty <= $result; }
/** * * This method allow to add stock information on a product detail * * If advanced stock management is active, get physical stock of this product in the warehouse associated to the product for the current order * Else get the available quantity of the product in function of the shop associated to the order * * @param array &$product */ protected function setProductCurrentStock(&$product) { if (JeproshopSettingModelSetting::getValue('advanced_stock_management') && (int) $product->advanced_stock_management == 1 && (int) $product->warehouse_id > 0) { $product->current_stock = JeproshopStockManagerFactory::getManager()->getProductPhysicalQuantities($product->product_id, $product->product_attribute_id, (int) $product->warehouse_id, true); } else { $product->current_stock = JeproshopStockAvailableModelStockAvailable::getQuantityAvailableByProduct($product->product_id, $product->product_attribute_id, (int) $this->shop_id); } }
/** * Check product availability * * @param integer $qty Quantity desired * @return boolean True if product is available with this quantity */ public function checkQuantity($qty) { if (JeproshopProductPack::isPack((int) $this->product_id) && !JeproshopProductPack::isInStock((int) $this->product_id)) { return false; } if ($this->isAvailableWhenOutOfStock(JeproshopStockAvailableModelStockAvailable::outOfStock($this->product_id))) { return true; } if (isset($this->product_attribute_id)) { $product_attribute_id = $this->product_attribute_id; } else { $product_attribute_id = 0; } return $qty <= JeproshopStockAvailableModelStockAvailable::getQuantityAvailableByProduct($this->product_id, $product_attribute_id); }
public function renderView($tpl = NULL) { if (!isset($this->context) || $this->context == null) { $this->context = JeproshopContext::getContext(); } $app = JFactory::getApplication(); $order = new JeproshopOrderModelOrder($app->input->get('order_id')); if (!JeproshopTools::isLoadedObject($order, 'order_id')) { JError::raiseError(500, JText::_('COM_JEPROSHOP_THE_ORDER_CANNOT_BE_FOUND_WITHIN_YOUR_DATA_BASE_MESSAGE')); } $customer = new JeproshopCustomerModelCustomer($order->customer_id); $carrier = new JeproshopCarrierModelCarrier($order->carrier_id); $products = $this->getProducts($order); $currency = new JeproshopCurrencyModelCurrency((int) $order->currency_id); // Carrier module call $carrier_module_call = null; if ($carrier->is_module) { /*$module = Module::getInstanceByName($carrier->external_module_name); if (method_exists($module, 'displayInfoByCart')) $carrier_module_call = call_user_func(array($module, 'displayInfoByCart'), $order->id_cart); */ } // Retrieve addresses information $addressInvoice = new JeproshopAddressModelAddress($order->address_invoice_id, $this->context->language->lang_id); if (JeproshopTools::isLoadedObject($addressInvoice, 'address_id') && $addressInvoice->state_id) { $invoiceState = new JeproshopStateModelState((int) $addressInvoice->state_id); } if ($order->address_invoice_id == $order->address_delivery_id) { $addressDelivery = $addressInvoice; if (isset($invoiceState)) { $deliveryState = $invoiceState; } } else { $addressDelivery = new JeproshopAddressModelAddress($order->address_delivery_id, $this->context->language->lang_id); if (JeproshopTools::isLoadedObject($addressDelivery, 'address_id') && $addressDelivery->state_id) { $deliveryState = new JeproshopStateModelState((int) $addressDelivery->state_id); } } $title = JText::_('COM_JEPROSHOP_ORDER_LABEL') . ' '; //todo learn how to display //$toolbar_title = sprintf($this->l('Order #%1$d (%2$s) - %3$s %4$s'), $order->order_id, $order->reference, $customer->firstname, $customer->lastname); if (JeproshopShopModelShop::isFeaturePublished()) { $shop = new JeproshopShopModelShop((int) $order->shop_id); //$this->toolbar_title .= ' - '.sprintf($this->l('Shop: %s'), $shop->name); } JToolBarHelper::title($title); // gets warehouses to ship products, if and only if advanced stock management is activated $warehouse_list = null; $order_details = $order->getOrderDetailList(); foreach ($order_details as $order_detail) { $product = new JeproshopProductModelProduct($order_detail->product_id); if (JeproshopSettingModelSetting::getValue('advanced_stock_management') && $product->advanced_stock_management) { $warehouses = JeproshopWarehouseModelWarehouse::getWarehousesByProductId($order_detail->product_id, $order_detail->product_attribute_id); foreach ($warehouses as $warehouse) { if (!isset($warehouse_list[$warehouse->warehouse_id])) { $warehouse_list[$warehouse->warehouse_id] = $warehouse; } } } } $payment_methods = array(); /*foreach (PaymentModule::getInstalledPaymentModules() as $payment) { $module = Module::getInstanceByName($payment['name']); if (Validate::isLoadedObject($module) && $module->active) $payment_methods[] = $module->displayName; }*/ // display warning if there are products out of stock $display_out_of_stock_warning = false; $current_order_status = $order->getCurrentOrderStatus(); if (JeproshopSettingModelSetting::getValue('stock_management') && (!JeproshopTools::isLoadedObject($current_order_status, 'order_id') || $current_order_status->delivery != 1 && $current_order_status->shipped != 1)) { $display_out_of_stock_warning = true; } // products current stock (from stock_available) foreach ($products as &$product) { $product->current_stock = JeproshopStockAvailableModelStockAvailable::getQuantityAvailableByProduct($product->product_id, $product->product_attribute_id, $product->shop_id); $resume = JeproshopOrderSlipModelOrderSlip::getProductSlipResume($product->order_detail_id); $product->quantity_refundable = $product->product_quantity - $resume->product_quantity; $product->amount_refundable = $product->total_price_tax_incl - $resume->amount_tax_incl; $product->amount_refund = JeproshopTools::displayPrice($resume->amount_tax_incl, $currency); $product->refund_history = JeproshopOrderSlipModelOrderSlip::getProductSlipDetail($product->order_detail_id); $product->return_history = JeproshopOrderReturnModelOrderReturn::getProductReturnDetail($product->order_detail_id); // if the current stock requires a warning if ($product->current_stock == 0 && $display_out_of_stock_warning) { JError::raiseWarning(500, JText::_('COM_JEPROSHOP_THIS_PRODUCT_IS_OUT_OF_STOCK_LABEL') . ' : ' . $product->product_name); } if ($product->warehouse_id != 0) { $warehouse = new JeproshopWarehouseModelWarehouse((int) $product->warehouse_id); $product->warehouse_name = $warehouse->name; } else { $product->warehouse_name = '--'; } } //$gender = new Gender((int)$customer->id_gender, $this->context->language->id); $history = $order->getHistory($this->context->language->lang_id); foreach ($history as &$order_state) { $order_state->text_color = JeproshopTools::getBrightness($order_state->color) < 128 ? 'white' : 'black'; } $this->setLayout('view'); $this->assignRef('order', $order); $cart = new JeproshopCartModelCart($order->cart_id); $this->assignRef('cart', $cart); $this->assignRef('customer', $customer); $customer_addresses = $customer->getAddresses($this->context->language->lang_id); $this->assignRef('customer_addresses', $customer_addresses); $this->assignRef('delivery_address', $addressDelivery); $this->assignRef('deliveryState', isset($deliveryState) ? $deliveryState : null); $this->assignRef('invoice_address', $addressInvoice); $this->assignRef('invoiceState', isset($invoiceState) ? $invoiceState : null); $customerStats = $customer->getStats(); $this->assignRef('customerStats', $customerStats); $this->assignRef('products', $products); $discounts = $order->getCartRules(); $this->assignRef('discounts', $discounts); $orderTotalPaid = $order->getOrdersTotalPaid(); $this->assignRef('orders_total_paid_tax_incl', $orderTotalPaid); // Get the sum of total_paid_tax_incl of the order with similar reference $totalPaid = $order->getTotalPaid(); $this->assignRef('total_paid', $totalPaid); $returns = JeproshopOrderReturnModelOrderReturn::getOrdersReturn($order->customer_id, $order->order_id); $this->assignRef('returns', $returns); $customerThreads = JeproshopCustomerThreadModelCustomerThread::getCustomerMessages($order->customer_id); $this->assignRef('customer_thread_message', $customerThreads); $orderMessages = JeproshopOrderMessageModelOrderMessage::getOrderMessages($order->lang_id); $this->assignRef('order_messages', $orderMessages); $messages = JeproshopMessageModelMessage::getMessagesByOrderId($order->order_id, true); $this->assignRef('messages', $messages); $carrier = new JeproshopCarrierModelCarrier($order->carrier_id); $this->assignRef('carrier', $carrier); $this->assignRef('history', $history); $statues = JeproshopOrderStatusModelOrderStatus::getOrderStatus($this->context->language->lang_id); $this->assignRef('order_statues', $statues); $this->assignRef('warehouse_list', $warehouse_list); $sources = JeproshopConnectionSourceModelConnectionSource::getOrderSources($order->order_id); $this->assignRef('sources', $sources); $orderStatus = $order->getCurrentOrderStatus(); $this->assignRef('current_status', $orderStatus); $this->assignRef('currency', new JeproshopCurrencyModelCurrency($order->currency_id)); $currencies = JeproshopCurrencyModelCurrency::getCurrenciesByShopId($order->shop_id); $this->assignRef('currencies', $currencies); $previousOrder = $order->getPreviousOrderId(); $this->assignRef('previousOrder', $previousOrder); $nextOrder = $order->getNextOrderId(); $this->assignRef('nextOrder', $nextOrder); //$this->assignRef('current_index', self::$currentIndex); $this->assignRef('carrier_module_call', $carrier_module_call); $this->assignRef('iso_code_lang', $this->context->language->iso_code); $this->assignRef('lang_id', $this->context->language->lang_id); $can_edit = true; $this->assignRef('can_edit', $can_edit); //($this->tabAccess['edit'] == 1)); $this->assignRef('current_id_lang', $this->context->language->lang_id); $invoiceCollection = $order->getInvoicesCollection(); $this->assignRef('invoices_collection', $invoiceCollection); $unPaid = $order->getNotPaidInvoicesCollection(); $this->assignRef('not_paid_invoices_collection', $unPaid); $this->assignRef('payment_methods', $payment_methods); $invoiceAllowed = JeproshopSettingModelSetting::getValue('invoice_allowed'); $this->assignRef('invoice_management_active', $invoiceAllowed); $display_warehouse = (int) JeproshopSettingModelSetting::getValue('advanced_stock_management'); $this->assignRef('display_warehouse', $display_warehouse); $stockManagement = JeproshopSettingModelSetting::getValue('stock_management'); $this->assignRef('stock_management', $stockManagement); /*$this->assignRef('HOOK_CONTENT_ORDER', Hook::exec('displayAdminOrderContentOrder', array( 'order' => $order, 'products' => $products, 'customer' => $customer) ), $this->assignRef('HOOK_CONTENT_SHIP' => Hook::exec('displayAdminOrderContentShip', array( 'order' => $order, 'products' => $products, 'customer' => $customer) ), $this->assignRef('HOOK_TAB_ORDER' => Hook::exec('displayAdminOrderTabOrder', array( 'order' => $order, 'products' => $products, 'customer' => $customer) $this->assignRef('HOOK_TAB_SHIP' => Hook::exec('displayAdminOrderTabShip', array( $this->assignRef('order' => $order, $this->assignRef('products' => $products, $this->assignRef('customer' => $customer) */ $this->addToolBar(); $this->sideBar = JHtmlSideBar::render(); parent::display($tpl); }
public function renderView($tpl = null) { if (!$this->loadObject(true)) { return; } if (!isset($this->context)) { $this->context = JeproshopContext::getContext(); } $customer = new JeproshopCustomerModelCustomer($this->cart->customer_id); $currency = new JeproshopCurrencyModelCurrency($this->cart->currency_id); $this->context->cart = $this->cart; $this->context->currency = $currency; $this->context->customer = $customer; //$this->toolbar_title = sprintf($this->l('Cart #%06d'), $this->context->cart->cart_id); $products = $this->cart->getProducts(); $customized_datas = JeproshopProductModelProduct::getAllCustomizedDatas((int) $this->cart->cart_id); JeproshopProductModelProduct::addCustomizationPrice($products, $customized_datas); $summary = $this->cart->getSummaryDetails(); /* Display order information */ $order_id = (int) JeproshopOrderModelOrder::getOrderIdByCartId($this->cart->cart_id); $order = new JeproshopOrderModelOrder($order_id); if (JeproshopTools::isLoadedObject($order, 'order_id')) { $tax_calculation_method = $order->getTaxCalculationMethod(); $shop_id = (int) $order->shop_id; } else { $shop_id = (int) $this->cart->shop_id; $tax_calculation_method = JeproshopGroupModelGroup::getPriceDisplayMethod(JeproshopGroupModelGroup::getCurrent()->group_id); } if ($tax_calculation_method == COM_JEPROSHOP_TAX_EXCLUDED) { $total_products = $summary->total_products; $total_discounts = $summary->total_discounts_tax_exc; $total_wrapping = $summary->total_wrapping_tax_exc; $total_price = $summary->total_price_without_tax; $total_shipping = $summary->total_shipping_tax_exc; } else { $total_products = $summary->total_products_wt; $total_discounts = $summary->total_discounts; $total_wrapping = $summary->total_wrapping; $total_price = $summary->total_price; $total_shipping = $summary->total_shipping; } foreach ($products as $k => &$product) { if ($tax_calculation_method == COM_JEPROSHOP_TAX_EXCLUDED) { $product->product_price = $product->price; $product->product_total = $product->total; } else { $product->product_price = $product->price_wt; $product->product_total = $product->total_wt; } $image = array(); $db = JFactory::getDBO(); if (isset($product->product_attribute_id) && (int) $product->product_attribute_id) { $query = "SELECT " . $db->quoteName('image_id') . " FROM " . $db->quoteName('#__jeproshop_product_attribute_image') . " WHERE product_attribute_id = " . (int) $product->product_attribute_id; $db->setQuery($query); $image = $db->loadObject(); } if (!isset($image->image_id)) { $query = "SELECT " . $db->quoteName('image_id') . " FROM " . $db->quoteName('#__jeproshop_image') . " WHERE " . $db->quoteName('product_id') . " = " . (int) $product->product_id . " AND cover = 1 "; $db->setQuery($query); $image = $db->loadObject(); } $product_obj = new JeproshopProductModelProduct($product->product_id); $product->qty_in_stock = JeproshopStockAvailableModelStockAvailable::getQuantityAvailableByProduct($product->product_id, isset($product->product_attribute_id) ? $product->product_attribute_id : null, (int) $shop_id); $image_product = new JeproshopImageModelImage($image->image_id); $product->image = isset($image->image_id) ? JeproshopImageManager::thumbnail(COM_JEPROSHOP_IMAGE_DIR . 'products/' . $image_product->getExistingImagePath() . '.jpg', 'product_mini_' . (int) $product->product_id . (isset($product->product_attribute_id) ? '_' . (int) $product->product_attribute_id : '') . '.jpg', 45, 'jpg') : '--'; } /*$helper = new HelperKpi(); $helper->id = 'box-kpi-cart'; $helper->icon = 'icon-shopping-cart'; $helper->color = 'color1'; $helper->title = $this->l('Total Cart', null, null, false); $helper->subtitle = sprintf($this->l('Cart #%06d', null, null, false), $cart->id); $helper->value = Tools::displayPrice($total_price, $currency); $kpi = $helper->generate(); */ //$this->assignRef('kpi', $kpi); $this->assignRef('products', $products); $discounts = $this->cart->getCartRules(); $this->assignRef('discounts', $discounts); $this->assignRef('order', $order); $this->assignRef('currency', $currency); $this->assignRef('customer', $customer); $customerStats = $customer->getStats(); $this->assignRef('customer_stats', $customerStats); $this->assignRef('total_products', $total_products); $this->assignRef('total_discounts', $total_discounts); $this->assignRef('total_wrapping', $total_wrapping); $this->assignRef('total_price', $total_price); $this->assignRef('total_shipping', $total_shipping); $this->assignRef('customized_datas', $customized_datas); if ($this->getLayout() != 'modal') { $this->addToolBar(); $this->sideBar = JHtmlSidebar::render(); } parent::display($tpl); }
private function initQuantitiesForm() { if (!$this->context->controller->default_form_language) { $this->languages = $this->context->controller->getLanguages(); } if ($this->product->product_id) { if ($this->product_exists_in_shop) { //Get all product_attribute_id $attributes = $this->product->getAttributesResume($this->context->language->lang_id); if (empty($attributes)) { $attributes[] = new JObject(); $attributes[0]->set('product_attribute_id', 0); $attributes[0]->set('attribute_designation', ''); } /** get available quantities **/ $available_quantity = array(); $product_designation = array(); foreach ($attributes as $attribute) { $product_attribute_id = is_object($attribute) ? $attribute->product_attribute_id : $attribute['product_attribute_id']; $attribute_designation = is_object($attribute) ? $attribute->attribute_designation : $attribute['attribute_designation']; // Get available quantity for the current product attribute in the current shop $available_quantity[$product_attribute_id] = JeproshopStockAvailableModelStockAvailable::getQuantityAvailableByProduct((int) $this->product->product_id, $product_attribute_id); // Get all product designation $product_designation[$product_attribute_id] = rtrim($this->product->name[$this->context->language->lang_id] . ' - ' . $attribute_designation, ' - '); } $show_quantities = true; $shop_context = JeproshopShopModelShop::getShopContext(); $shop_group = new JeproshopShopGroupModelShopGroup((int) JeproshopShopModelShop::getContextShopGroupID()); // if we are in all shops context, it's not possible to manage quantities at this level if (JeproshopShopModelShop::isFeaturePublished() && $shop_context == JeproshopShopModelShop::CONTEXT_ALL) { $show_quantities = false; // if we are in group shop context } elseif (JeproshopShopModelShop::isFeaturePublished() && $shop_context == JeproshopShopModelShop::CONTEXT_GROUP) { // if quantities are not shared between shops of the group, it's not possible to manage them at group level if (!$shop_group->share_stock) { $show_quantities = false; } } else { // if we are in shop context // if quantities are shared between shops of the group, it's not possible to manage them for a given shop if ($shop_group->share_stock) { $show_quantities = false; } } $stock_management = JeproshopSettingModelSetting::getValue('stock_management'); $this->assignRef('stock_management', $stock_management); $has_attribute = $this->product->hasAttributes(); $this->assignRef('has_attribute', $has_attribute); // Check if product has combination, to display the available date only for the product or for each combination $db = JFactory::getDBO(); if (JeproshopCombinationModelCombination::isFeaturePublished()) { $query = "SELECT COUNT(product_id) FROM " . $db->quoteName('#__jeproshop_product_attribute') . " WHERE "; $query .= " product_id = " . (int) $this->product->product_id; $db->setQuery($query); $countAttributes = (int) $db->loadResult(); } else { $countAttributes = false; } $this->assignRef('count_attributes', $countAttributes); // if advanced stock management is active, checks associations $advanced_stock_management_warning = false; if (JeproshopSettingModelSetting::getValue('advanced_stock_management') && $this->product->advanced_stock_management) { $product_attributes = JeproshopProductModelProduct::getProductAttributesIds($this->product->product_id); $warehouses = array(); if (!$product_attributes) { $warehouses[] = JeproshopWarehouseModelWarehouse::getProductWarehouseList($this->product->product_id, 0); } foreach ($product_attributes as $product_attribute) { $ws = JeproshopWarehouseModelWarehouse::getProductWarehouseList($this->product->product_id, $product_attribute->product_attribute_id); if ($ws) { $warehouses[] = $ws; } } $warehouses = JeproshopTools::arrayUnique($warehouses); if (empty($warehouses)) { $advanced_stock_management_warning = true; } } if ($advanced_stock_management_warning) { JError::raiseWarning(500, JText::_('If you wish to use the advanced stock management, you must:')); JError::raiseWarning(500, '- ' . JText::_('associate your products with warehouses.')); JError::raiseWarning(500, '- ' . JText::_('associate your warehouses with carriers.')); JError::raiseWarning(500, '- ' . JText::_('associate your warehouses with the appropriate shops.')); } $pack_quantity = null; // if product is a pack if (JeproshopProductPack::isPack($this->product->product_id)) { $items = JeproshopProductPack::getItems((int) $this->product->product_id, JeproshopSettingModelSetting::getValue('default_lang')); // gets an array of quantities (quantity for the product / quantity in pack) $pack_quantities = array(); foreach ($items as $item) { if (!$item->isAvailableWhenOutOfStock((int) $item->out_of_stock)) { $pack_id_product_attribute = JeproshopProductModelProduct::getDefaultAttribute($item->product_id, 1); $pack_quantities[] = JeproshopProductModelProduct::getQuantity($item->id, $pack_id_product_attribute) / ($item->pack_quantity !== 0 ? $item->pack_quantity : 1); } } // gets the minimum if (count($pack_quantities)) { $pack_quantity = $pack_quantities[0]; foreach ($pack_quantities as $value) { if ($pack_quantity > $value) { $pack_quantity = $value; } } } if (!JeproshopWarehouseModelWarehouse::getPackWarehouses((int) $this->product->product_id)) { $this->displayWarning($this->l('You must have a common warehouse between this pack and its product.')); } } $this->assignRef('attributes', $attributes); $this->assignRef('available_quantity', $available_quantity); $this->assignRef('pack_quantity', $pack_quantity); $stock_management_active = JeproshopSettingModelSetting::getValue('advanced_stock_management'); $this->assignRef('stock_management_active', $stock_management_active); $this->assignRef('product_designation', $product_designation); $this->assignRef('show_quantities', $show_quantities); $order_out_of_stock = JeproshopSettingModelSetting::getValue('allow_out_of_stock_ordering'); $this->assignRef('order_out_of_stock', $order_out_of_stock); /*'token_preferences' => Tools::getAdminTokenLite('AdminPPreferences'), 'token' => $this->token, 'languages' => $this->_languages, 'id_lang' => $this->context->language->id ));*/ } else { JError::raiseWarning(500, JText::_('You must save the product in this shop before managing quantities.')); } } else { JError::raiseWarning(500, JText::_('You must save this product before managing quantities.')); } }
/** * Get all available product attributes resume * * @param integer $lang_id Language id * @param string $attribute_value_separator * @param string $attribute_separator * @return array Product attributes combinations */ public function getAttributesResume($lang_id, $attribute_value_separator = ' - ', $attribute_separator = ', ') { if (!JeproshopCombinationModelCombination::isFeaturePublished()) { return array(); } $add_shop = ''; $db = JFactory::getDBO(); $query = "SELECT product_attribute.*, product_attribute_shop.* FROM " . $db->quoteName('#__jeproshop_product_attribute'); $query .= " AS product_attribute " . JeproshopShopModelShop::addSqlAssociation('product_attribute') . "\tWHERE product_attribute."; $query .= $db->quoteName('product_id') . " = " . (int) $this->product_id . " GROUP BY product_attribute." . $db->quoteName('product_attribute_id'); $db->setQuery($query); $combinations = $db->loadObjectList(); if (!$combinations) { return false; } $product_attributes = array(); foreach ($combinations as $combination) { $product_attributes[] = (int) $combination->product_attribute_id; } $query = "SELECT product_attribute_combination.product_attribute_id, GROUP_CONCAT(attribute_group_lang." . $db->quoteName('name') . ", "; $query .= $db->quote($attribute_value_separator) . ",attribute_lang." . $db->quoteName('name') . " ORDER BY attribute_group_lang."; $query .= $db->quoteName('attribute_group_id') . " SEPARATOR " . $db->quote($attribute_separator) . ") as attribute_designation FROM "; $query .= $db->quoteName('#__jeproshop_product_attribute_combination') . " AS product_attribute_combination LEFT JOIN "; $query .= $db->quoteName('#__jeproshop_attribute') . " AS attribute ON attribute." . $db->quoteName('attribute_id') . " = product_attribute_combination."; $query .= $db->quoteName('attribute_id') . " LEFT JOIN " . $db->quoteName('#__jeproshop_attribute_group') . " AS attribute_group ON attribute_group."; $query .= $db->quoteName('attribute_group_id') . " = attribute." . $db->quoteName('attribute_group_id') . " LEFT JOIN " . $db->quoteName('#__jeproshop_attribute_lang'); $query .= " AS attribute_lang ON (attribute." . $db->quoteName('attribute_id') . " = attribute_lang." . $db->quoteName('attribute_id') . " AND attribute_lang."; $query .= $db->quoteName('lang_id') . " = " . (int) $lang_id . ") LEFT JOIN " . $db->quoteName('#__jeproshop_attribute_group_lang'); $query .= " AS attribute_group_lang ON (attribute_group." . $db->quoteName('attribute_group_id') . " = attribute_group_lang." . $db->quoteName('attribute_group_id'); $query .= " AND attribute_group_lang." . $db->quoteName('lang_id') . " = " . (int) $lang_id . ") WHERE product_attribute_combination.product_attribute_id IN ("; $query .= implode(',', $product_attributes) . ") GROUP BY product_attribute_combination.product_attribute_id"; $db->setQuery($query); $lang = $db->loadObjectList(); foreach ($lang as $k => $row) { $combinations[$k]->attribute_designation = $row->attribute_designation; } //Get quantity of each variations foreach ($combinations as $key => $row) { $cache_key = $row->product_id . '_' . $row->product_attribute_id . '_quantity'; if (!JeproshopCache::isStored($cache_key)) { JeproshopCache::store($cache_key, JeproshopStockAvailableModelStockAvailable::getQuantityAvailableByProduct($row->product_id, $row->product_attribute_id)); } $combinations[$key]->quantity = JeproshopCache::retrieve($cache_key); } return $combinations; }