Inhalte aufrufen

Profilbild

Creating Image Square Attribute for Product Variant

Customization Image Square Product Attribute Product Variant Attribute Image Square Control Type

  • Bitte melden Sie sich an, um eine Antwort zu verfassen.
1 Antwort zu diesem Thema

#1 samdubey

samdubey

    Member

  • Members
  • PunktPunkt
  • 21 Beiträge

Geschrieben: 13 February 2015 - 07:50

Hello Team,
 
I am trying to create another attribute control type called "Image Squares" like the Color Squares except for images. 
 
It would be nice if a large image could be uploaded and a small predefined square piece be selected and cropped out to make the attribute value image, or a product could be selected and all the images for the product will be displayed and one chosen that would be automatically re-sized to make the attribute value image.
 
please find below mentioned code changes....

 

File Path: /SmartStoreNET/src/Libraries/SmartStore.Core/Domain/Catalog/AttributeControlType.cs

namespace SmartStore.Core.Domain.Catalog
{
  public enum AttributeControlType
    {
            .....
        /// <summary>
        /// Picture squares
        /// </summary>
        ImageSquares = 60,
    }
}

File Path: /SmartStoreNET/src/Libraries/SmartStore.Core/Domain/Catalog/ProductVariantAttributeValue.cs

namespace SmartStore.Core.Domain.Catalog
{
    public partial class ProductVariantAttributeValue : BaseEntity, ILocalizedEntity
    {
        ....
        ....
        /// <summary>
        /// Gets or sets the picture value (used with "Image squares" attribute type)
        /// </summary>
        public virtual int PictureId { get; set; }
    }
}

File Path: /SmartStoreNET/src/Presentation/SmartStore.Web/Administration/Models/Catalog/ProductVariantModel.cs

namespace SmartStore.Admin.Models.Catalog
{

  [Validator(typeof(ProductVariantValidator))]
    public class ProductVariantModel : EntityModelBase, ILocalizedModel<ProductVariantLocalizedModel>
    {
         

        [Validator(typeof(ProductVariantAttributeValueModelValidator))]
        public class ProductVariantAttributeValueModel : EntityModelBase, ILocalizedModel<ProductVariantAttributeValueLocalizedModel>
        {
                  .....
            [SmartResourceDisplayName("Admin.Catalog.Products.Variants.ProductVariantAttributes.Attributes.Values.Fields.ImageSquare")]
            [UIHint("Picture")]
            public int PictureId { get; set; }

            public bool DisplayImageSquares { get; set; }
       }
   }
}

File Path: /SmartStoreNET/src/Presentation/SmartStore.Web/Administration/Views/ProductVariant/_CreateOrUpdateProductAttributeValue.cshtml

@if (Model.DisplayImageSquares)
    {
        <tr>
            <td class="adminTitle">
                @Html.SmartLabelFor(model => model.PictureId)
            </td>
            <td class="adminData">
                @Html.EditorFor(model => model.PictureId)
                @Html.ValidationMessageFor(model => model.PictureId)
            </td>
        </tr>
    }

and many other changes in CatalogController , OrderController for ImageSquare as similar to ColorSquare

 

1. PictureId shows me the Picture Uploading control but vanishes as soon as click save button

2. How do i upload image and crop it to display as Image Square?


Sameer Dubey

Director - Technology & Solutions

C-DUCK CONSULTANCY SERVICES PVT. LTD.

sameer.dubey@c-duck.com

http://www.c-duck.com - Business Application Development using AngularJs and WebApi

http://www.housy.in - Service Commerce Redefined

http://www.hostify.in - Domains and Web Hosting


#2 Murat Cakir

Murat Cakir

    SmartStore AG

  • Administrators
  • 1118 Beiträge

Geschrieben: 13 February 2015 - 18:06

This is a rather sophisticated task. Image squares and many other attribute specific features will be available in V2.5 (hopefully 3rd quarter 2015). If you are not willing to wait you have to post some more code, which would help us understand what may be going on.

 

Concerning cropping you could use the ImageResizer, which SmartStore.NET uses internally to resize images: http://imageresizing...docs/howto/crop


Murat Cakir
SmartStore AG