Nop 3.10: Emulate behaviour of Product With Single Variant

This topic was automatically closed 365 days after the last reply. New replies are no longer allowed.
10 years ago
Hi,

Is it possible to have a Grouped Product show up in search like a product w/ single variant used to?  IE have the Add To Cart button, and a single price instead of 'From 123.99' etc?

We are using Grouped Products to house our content on a UPC / Gtin basis, and publish an associated product based upon vendor availability and lowest price, etc.

Any ideas?
10 years ago
This works:

(From CatalogController.cs)


switch (product.ProductType)
                    {
                        case ProductType.GroupedProduct:
                            {
                                #region Grouped product

                                var associatedProducts = _productService.SearchProducts(
                                    storeId: _storeContext.CurrentStore.Id,
                                    visibleIndividuallyOnly: false,
                                    parentGroupedProductId: product.Id);

                                switch (associatedProducts.Count)
                                {
                                    case 0:
                                        {
                                            //no associated products
                                            priceModel.OldPrice = null;
                                            priceModel.Price = null;
                                            priceModel.DisableBuyButton = true;
                                            priceModel.DisableWishlistButton = true;
                                            priceModel.AvailableForPreOrder = false;
                                        }
                                        break;
                                    //edited to add case for single product variant - ajk
                                    case 1:
                                        {
                                            if (_permissionService.Authorize(StandardPermissionProvider.DisplayPrices))
                                            {
                                                var associatedProduct = associatedProducts.First();
                                                var tmpPrice = _priceCalculationService.GetFinalPrice(associatedProduct,
                                                        _workContext.CurrentCustomer, decimal.Zero, true, int.MaxValue);

                                                Product minPriceProduct = associatedProduct;
                                                decimal? minPossiblePrice = tmpPrice;

                                                decimal taxRate = decimal.Zero;
                                                decimal finalPriceBase = _taxService.GetProductPrice(minPriceProduct, minPossiblePrice.Value, out taxRate);
                                                decimal finalPrice = _currencyService.ConvertFromPrimaryStoreCurrency(finalPriceBase, _workContext.WorkingCurrency);

                                                priceModel.OldPrice = null;
                                                priceModel.Price = _priceFormatter.FormatPrice(finalPrice);

                                                model.Availability = associatedProduct.FormatStockMessage(_localizationService);

                                            }
                                        }
                                        break;
This topic was automatically closed 365 days after the last reply. New replies are no longer allowed.