Product

@objc(GFYProduct)
public class Product : NSObject, NSCopying, Encodable

Represents a distinct Product with basic identifiers, price, and display information, and further optional detailed information.

  • sku

    The specific SKU of the product/variant

    Declaration

    Swift

    @objc
    public let sku: String
  • The parent ID of the product

    Declaration

    Swift

    @objc
    public let productId: String
  • The name or title of the product

    Declaration

    Swift

    @objc
    public let title: String
  • The current unit price of the product (after discount or sale pricing)

    Declaration

    Swift

    @objc
    public let price: Price
  • The regular price of the product before sales or discounts

    Declaration

    Swift

    @objc
    public let regularPrice: Price
  • The address of the product image

    Declaration

    Swift

    @objc
    public let image: URL
  • url

    Deep link to app location

    Declaration

    Swift

    @objc
    public let url: URL
  • The stock information for the product

    Declaration

    Swift

    @objc
    public let stock: ProductStock?
  • The review and rating information for the product

    Declaration

    Swift

    @objc
    public let reviews: ProductReviews?
  • The broad category containing this item

    Declaration

    Swift

    @objc
    public let category: String?
  • Further categorical identification of item (optional)

    Declaration

    Swift

    @objc
    public let subCategory: String?
  • The color of the SKU item (optional)

    Declaration

    Swift

    @objc
    public let color: String?
  • The size of the SKU item (optional)

    Declaration

    Swift

    @objc
    public let size: String?
  • Named (keys) custom properties (values with a valid string representation) to be stored and reported to Granify with the product

    This is useful for adding additional properties that may be domain-specific to your site and do not fit into any of the existing properties available on this class.

    Declaration

    Swift

    @objc
    public let customProperties: [String : PrimitiveWrapper]
  • The site id of the child site this product belongs to

    Leave this nil unless your configuration uses child sites, in which case this value is required.

    Declaration

    Swift

    @objc
    public let childSiteOwnerId: SiteIdentifier?
  • Creates a Product instance

    Declaration

    Swift

    @objc
    public init(sku: String,
                productId: String,
                title: String,
                price: Price,
                regularPrice: Price,
                image: URL,
                url: URL,
                stock: ProductStock? = nil,
                reviews: ProductReviews? = nil,
                category: String? = nil,
                subCategory: String? = nil,
                color: String? = nil,
                size: String? = nil,
                childSiteOwnerId: SiteIdentifier? = nil,
                customProperties: [String: PrimitiveWrapper] = [:])

    Parameters

    sku

    The specific SKU of the product/variant

    productId

    The parent ID of the product

    title

    The name or title of the product

    price

    The current unit price of the product (after discount or sale pricing)

    regularPrice

    The regular price of the product before sales or discounts

    image

    The address of the product image

    url

    Deep link to app location

    stock

    The stock information for the product (optional)

    reviews

    The review and rating information for the product (optional)

    category

    The broad category containing this item (optional)

    subCategory

    Further categorical identification of item (optional)

    color

    The color of the SKU item (optional)

    size

    The size of the SKU item (optional)

    childSiteOwnerId

    The site id of the child site this product belongs to. (optional; leave this nil unless your configuration uses child sites, in which case this value is required)

    customProperties

    Named (keys) custom properites (values with a valid string or integer representation) to be stored and reported to Granify with the product. This is useful for adding additional properties that may be domain-specific to your application and do not fit into any of the existing properties available on this class.

  • Returns a new instance that’s a copy of the receiver.

    Required for conforming to NSCopying, which is required for using Product as an NSDictionary key when using Granify from Objective-C.

    Declaration

    Swift

    public func copy(with zone: NSZone? = nil) -> Any

    Parameters

    zone

    This parameter is ignored. Memory zones are no longer used by Objective-C.

    Return Value

    New copied Product instance

  • Override for Hashable protocol implementation to make Products rely only on the unique sku identifier

    Declaration

    Swift

    override public var hash: Int { get }
  • Returns a Boolean value that indicates whether the receiver and a given object are equal.

    Equality for Product objects is assessed by comparing only the unique sku identifiers.

    Declaration

    Swift

    override public func isEqual(_ object: Any?) -> Bool

    Parameters

    object

    The object to be compared to the receiver

    Return Value

    true if the receiver and object are equal, otherwise false

  • Retrieves String representation of Product

    Declaration

    Swift

    override public var description: String { get }