Product Variant info in ver 2.6

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

how can I ad a field in to product variant info.

I need to ad product variant info. i.e. I would like to add "condition" and options new, used. It should show next to the price on product page. I dont want to ad it in specification or product attributes because I want to show it to next to the price.
11 years ago
do it in css. just press f12 ( developer tools) in ie./chrome or any other browser supperted. select the field you want to reposition. do changes in the margin values. and update the same in your style.css file in your theme/yourtheme/content/style.css file. you can achive it.  :)
11 years ago
Let me rephrase my question. I need a field in "product variant info" in admin area with options. The field name would be "condition" just like we have tax category. So I can put the condition of the item there and I want this to be displayed next to the price on product page.

I hope I was able to explain my question properly.

Any suggestion.

Thanks.
11 years ago
Check release notes for v2.6:
•Developers. Added generic attribute support (now you can add a new property to any entity without database changes). Previously we could do it only for "Customer" entity (we had "CustomerAttribute" associated entity). Now we have "GenericAttribute" and "IGenericAttributeService".
11 years ago
How do I change or add generic attributes? Can you please show me or explain me little bit.

Thanks
11 years ago
marifkhan wrote:
How do I change or add generic attributes? Can you please show me or explain me little bit.

Thanks

This will require some customization work,  but I am afraid I dont have coding experience :(. Lets hope someone else gives you some guidance
11 years ago
Here is how to extend tables using Generic Attributes. I have used it to extend Product as an example.

Generic Attribute Schema:

Column  Type
Id           int
EntityId   int
KeyGroup   nvarchar
Key           nvarchar
Value   nvarchar

Sample Data:
Id  EntityId  KeyGroup           Key                      Value
1  1          Customer           FirstName               Hari
2  1          Customer           LastName               Dupati
32  54845  ProductVariant   Barcode               111
33  54845  ProductVariant   YearToDateSales    222

Usage:

1.  Create SystemProductAttributeNames class under Nop.Core.Domain.Catalog Namespace

namespace Nop.Core.Domain.Catalog
{
    public partial class SystemProductAttributeNames
    {
        public static string Barcode { get { return "Barcode"; } }

        public static string YearToDateSales { get { return "YearToDateSales"; } }

    }
}

2. Inserting or Updating Attributes for an Entity.
                        


  _genericAttributeService = EngineContext.Current.Resolve<IGenericAttributeService>();

/// create an instance of productVariant

_genericAttributeService.SaveAttribute(productVariant, SystemProductAttributeNames.Barcode, "111");

_genericAttributeService.SaveAttribute(productVariant, SystemProductAttributeNames.YearToDateSales, "222");



3.Retreiving Attribute value based on Keygroup,Entity and Key using GenericAttributeServiceExtensions


string barcode = productVariant.GetAttribute<string>(SystemProductAttributeNames.Barcode);
decimal yeartodatesales = productVariant.GetAttribute<decimal>(SystemProductAttributeNames.YearToDateSales);

                        


Nop Code Reference:

Nop.Services:  Nop.Services\Common\IGenericAttributeService.cs
IGenericAttributeService (in Nop.Services.Common)
•  DeleteAttribute(GenericAttribute attribute):void
•  GetAttributeById(int attributeId):GenericAttribute
•  InsertAttribute(GenericAttribute attribute):void
•  UpdateAttribute(GenericAttribute attribute):void
•  GetAttributesForEntity(int entityId, string keyGroup):IList
•  SaveAttribute(BaseEntity entity, string key, TPropType value):void

GenericAttributeExtentions (in Nop.Services.Common)

•    GetAttribute(this BaseEntity entity, string key):TPropType
•    GetAttribute(this BaseEntity entity, string key, IGenericAttributeService genericAttributeService):TPropType
This topic was automatically closed 365 days after the last reply. New replies are no longer allowed.