Inhalte aufrufen

Profilbild

product variations - unique price for product attributes combinations

combinations variants products catalog

14 Antworten zu diesem Thema

#1 sebaherrera

sebaherrera

    Member

  • Members
  • 12 Beiträge

Geschrieben: 04 April 2014 - 15:49

Hello, using the following product as example http://frontend.smar...pc-konfigurator I would like to know if its possible to define a unique price for product attributes combinations. 

 

eg: Intel Core I-7 + 4GB RAM + OS/WINDOWS ENTERPRISE = 1200 usd. as the unique price and not as the sum of prices. On attribute combination page, inside product variant for product I realized that each combination could have:

its on sku,

- GTIN (global trade item number)

- other unique details

- but not a unique price for that combination.

 

Do you know if its possible this option, otherwise, any idea of what do I have to override in order to add a field like price and override the current one. 

 

brgds thank you!



#2 Marcus Gesing

Marcus Gesing

    SmartStore AG

  • Administrators
  • 3034 Beiträge

Geschrieben: 04 April 2014 - 18:35

It's not possible at the moment, but there's already an issue for it.
 
To override values of product properties like the price, you need to change primarily two things:
Perform a value override in \SmartStore.Services\Catalog\ProductExtensions.cs::MergeWithCombination.
Modify the price property of \SmartStore.Core\Domain\Catalog\Product.cs like it has been done with SKU for instance.
 

  • sebaherrera gefällt das

Schöne Grüße aus Düsseldorf,
Marcus Gesing


#3 sebaherrera

sebaherrera

    Member

  • Members
  • 12 Beiträge

Geschrieben: 05 April 2014 - 02:26

 

It's not possible at the moment, but there's already an issue for it.
 
To override values of product properties like the price, you need to change primarily two things:
Perform a value override in \SmartStore.Services\Catalog\ProductExtensions.cs::MergeWithCombination.
Modify the price property of \SmartStore.Core\Domain\Catalog\Product.cs like it has been done with SKU for instance.

 

 

issue says that it will be release with smartstore 2.0 and today smartstore version was updated, do you know if its included? brgds!



#4 sebaherrera

sebaherrera

    Member

  • Members
  • 12 Beiträge

Geschrieben: 05 April 2014 - 07:05

I Installed the new version smartstore 2.0 and I tested. the possiblity to define a price directly on product attribute combination its not available. you can define an extra vale for each combination, but not a single price if the selection matches a combination. brgds!



#5 Marcus Gesing

Marcus Gesing

    SmartStore AG

  • Administrators
  • 3034 Beiträge

Geschrieben: 05 April 2014 - 09:49

It's not included yet. I reassigned the issue. I'm trying to implement it in the near future.


Schöne Grüße aus Düsseldorf,
Marcus Gesing


#6 sebaherrera

sebaherrera

    Member

  • Members
  • 12 Beiträge

Geschrieben: 05 April 2014 - 18:27

thank you!

brgds



#7 sebaherrera

sebaherrera

    Member

  • Members
  • 12 Beiträge

Geschrieben: 05 April 2014 - 21:45

Ok, I tried this solution: 

To override values of product properties like the price, you need to change primarily two things:
Perform a value override in \SmartStore.Services\Catalog\ProductExtensions.cs::MergeWithCombination.
Modify the price property of \SmartStore.Core\Domain\Catalog\Product.cs like it has been done with SKU for instance.

 

I create a field inside ProductVariantAttributeCombination Database Table with name Price (decimal 18,4).

I Inserted into SmartStore.Data\Mapping\ProductVariantAttributeCombinationMap file : 

 
            this.Property(pvac => pvac.Price).HasPrecision(18, 4);
 
On SmartStore.Core\Domain\Catalog\Product.cs I inserted the following details:
private decimal _price;
 
        /// <summary>
        /// Gets or sets the override price
        /// </summary>
        [DataMember]
        public decimal Price
        {
            get
            {
                return this.GetMergedDataValue<decimal>("Price", _price);
            }
            set
            {
                _price = value;
            }
        }

 

on SmartStore.Service\Catalog\ProductExtensions.cs inside MergeWithCombination(this)..

 

            if (combination.Price.HasValue)
                product.MergedDataValues.Add("Price", combination.Price);
 
inside SmartStore.Admin\Models\ProductVariantAttributeCombinationModel.cs I inserted 
 
 
        [SmartResourceDisplayName("Admin.Catalog.Products.Fields.Price")]
        public decimal? Price { get; set; }
 
 
consequently then I opened the admin area for product AttributeCombinationEditPopup.cshtml to test the field price but its not appearing on the webpage.
 
any idea will be welcome.
brgds


#8 sebaherrera

sebaherrera

    Member

  • Members
  • 12 Beiträge

Geschrieben: 06 April 2014 - 05:12

attached the modified files.

Angehängte Bilder



#9 Marcus Gesing

Marcus Gesing

    SmartStore AG

  • Administrators
  • 3034 Beiträge

Geschrieben: 06 April 2014 - 15:37

 I've pushed the code. You can find it here.


Schöne Grüße aus Düsseldorf,
Marcus Gesing


#10 sebaherrera

sebaherrera

    Member

  • Members
  • 12 Beiträge

Geschrieben: 06 April 2014 - 17:57

hi marcus, sorry probably I made a mistake explaining. I modified all those files but I cannot see the field into productvariations. I uploaded the code because I supposed it was simpler for the community to check and find what is missing in order to contribute / help me.



#11 Marcus Gesing

Marcus Gesing

    SmartStore AG

  • Administrators
  • 3034 Beiträge

Geschrieben: 07 April 2014 - 09:49

The control for the new price field has to be rendered in _CreateOrUpdateAttributeCombinationPopup.cshtml (not in AttributeCombinationEditPopup.cshtml).
It got a new table row as you can find in my commit:
 
<tr>
	<td class="adminTitle">
		@Html.SmartLabelFor(model => model.Price)
	</td>
	<td class="adminData">
		@Html.EditorFor(model => model.Price)
		@Html.ValidationMessageFor(model => model.Price)
	</td>
</tr>


Schöne Grüße aus Düsseldorf,
Marcus Gesing


#12 sebaherrera

sebaherrera

    Member

  • Members
  • 12 Beiträge

Geschrieben: 07 April 2014 - 18:40

ahh, ok thank you so much!



#13 sebaherrera

sebaherrera

    Member

  • Members
  • 12 Beiträge

Geschrieben: 08 April 2014 - 07:22

I tested the code and its working perfect at in admin area and inside product page. the calculation works perfect and display the particular price for the combination. On the other hand, when the product is sent to the cart,

1- on the upper area of cart ajax (id="shopbar-cart")that area do not display the override price based on attribute combinations. it display "Sub-Total=0.00 excl tax

2- Pressing the cart button with URL SmartStore/cart, Inside the cart you can see the price of the attributes combination ok.

3- SmartStore/checkout/confirm url display the price perfect.

4- I confirmed the order and the information moves to my account. Inside SmartStore/orderdetails/2 url the app do not display any price. all values are in 0.00 (cero) despite the fact that order displays values in step 2 and 3.

 

Override of price do not apply to Cart in header and order information. any idea please let me know and I will start working on that direction. brgds!



#14 Marcus Gesing

Marcus Gesing

    SmartStore AG

  • Administrators
  • 3034 Beiträge

Geschrieben: 08 April 2014 - 10:16

Due to 1 you must extend GetUnitPrice in SmartStore.Services/Catalog/PriceCalculationService.cs.
Replace the old else-block at attributesTotalPrice
decimal attributesTotalPrice = decimal.Zero;
var pvaValues = _productAttributeParser.ParseProductVariantAttributeValues(shoppingCartItem.Item.AttributesXml);

if (pvaValues != null)
{
	foreach (var pvaValue in pvaValues)
		attributesTotalPrice += GetProductVariantAttributeValuePriceAdjustment(pvaValue);
}

finalPrice = GetFinalPrice(product, customer, attributesTotalPrice, includeDiscounts, shoppingCartItem.Item.Quantity, shoppingCartItem.BundleItemData);

by

 

var combination = _productAttributeParser.FindProductVariantAttributeCombination(product, shoppingCartItem.Item.AttributesXml);

if (combination != null && combination.Price.HasValue)
{
	finalPrice = combination.Price.Value;
}
else
{
	decimal attributesTotalPrice = decimal.Zero;
	var pvaValues = _productAttributeParser.ParseProductVariantAttributeValues(shoppingCartItem.Item.AttributesXml);

	if (pvaValues != null)
	{
		foreach (var pvaValue in pvaValues)
			attributesTotalPrice += GetProductVariantAttributeValuePriceAdjustment(pvaValue);
	}

	finalPrice = GetFinalPrice(product, customer, attributesTotalPrice, includeDiscounts, shoppingCartItem.Item.Quantity, shoppingCartItem.BundleItemData);
}

Schöne Grüße aus Düsseldorf,
Marcus Gesing


#15 sebaherrera

sebaherrera

    Member

  • Members
  • 12 Beiträge

Geschrieben: 08 April 2014 - 17:59

thank you so much. I tested and all steps 1-4 are working perfect with your suggested modification. once again thank you. brgds!





Auf dieses Thema antworten



  

Auch markiert mit einem oder mehrerer dieser Schlüsselwörter: combinations, variants, products, catalog