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.
-
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 -
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
nilunless your configuration uses child sites, in which case this value is required.Declaration
Swift
@objc public let childSiteOwnerId: SiteIdentifier? -
init(sku:productId: title: price: regularPrice: image: url: stock: reviews: category: subCategory: color: size: childSiteOwnerId: customProperties: ) Creates a
ProductinstanceDeclaration
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
skuThe specific SKU of the product/variant
productIdThe parent ID of the product
titleThe name or title of the product
priceThe current unit price of the product (after discount or sale pricing)
regularPriceThe regular price of the product before sales or discounts
imageThe address of the product image
urlDeep link to app location
stockThe stock information for the product (optional)
reviewsThe review and rating information for the product (optional)
categoryThe broad category containing this item (optional)
subCategoryFurther categorical identification of item (optional)
colorThe color of the SKU item (optional)
sizeThe size of the SKU item (optional)
childSiteOwnerIdThe site id of the child site this product belongs to. (optional; leave this
nilunless your configuration uses child sites, in which case this value is required)customPropertiesNamed (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 usingProductas anNSDictionarykey when using Granify from Objective-C.Declaration
Swift
public func copy(with zone: NSZone? = nil) -> AnyParameters
zoneThis parameter is ignored. Memory zones are no longer used by Objective-C.
Return Value
New copied
Productinstance -
Override for
Hashableprotocol implementation to makeProducts rely only on the unique sku identifierDeclaration
Swift
override public var hash: Int { get } -
Returns a Boolean value that indicates whether the receiver and a given object are equal.
Equality for
Productobjects is assessed by comparing only the unique sku identifiers.Declaration
Swift
override public func isEqual(_ object: Any?) -> BoolParameters
objectThe object to be compared to the receiver
Return Value
trueif the receiver andobjectare equal, otherwisefalse -
Retrieves
Stringrepresentation ofProductDeclaration
Swift
override public var description: String { get }
Product Class Reference