Product.fromJson constructor
Product.fromJson(
- Map<String, dynamic> json
)
Implementation
Product.fromJson(Map<String, dynamic> json)
: id = json['id'],
name = json['name'],
slug = json['slug'],
permalink = json['permalink'],
type = json['type'],
status = json['status'],
featured = json['featured'],
catalogVisibility = json['catalog_visibility'],
description = json['description'],
shortDescription = json['short_description'],
sku = json['sku'],
price = json['price'],
regularPrice = json['regular_price'],
salePrice = (json['sale_price'] is String
? json['sale_price']
: json['sale_price'].toString()),
priceHtml = json['price_html'],
onSale = json['on_sale'],
purchasable = json['purchasable'],
totalSales = json['total_sales'],
virtual = json['virtual'],
downloadable = json['downloadable'],
downloads = (json['downloads'] as List)
.map((i) => Download.fromJson(i))
.toList(),
downloadLimit = json['download_limit'],
downloadExpiry = json['download_expiry'],
externalUrl = json['external_url'],
buttonText = json['button_text'],
taxStatus = json['tax_status'],
taxClass = json['tax_class'],
manageStock = json['manage_stock'],
stockQuantity = json['stock_quantity'],
stockStatus = json['stock_status'],
backorders = json['backorders'],
backordersAllowed = json['backorders_allowed'],
backordered = json['backordered'],
soldIndividually = json['sold_individually'],
weight = json['weight'].toString(),
dimensions = Dimension.fromJson(json['dimensions']),
shippingRequired = json['shipping_required'],
shippingTaxable = json['shipping_taxable'],
shippingClass = json['shipping_class'],
shippingClassId = json['shipping_class_id'],
reviewsAllowed = json['reviews_allowed'],
averageRating = json['average_rating'],
ratingCount = json['rating_count'],
relatedIds = json['related_ids'].cast<int>(),
upsellIds = json['upsell_ids'].cast<int>(),
crossSellIds = json['cross_sell_ids'].cast<int>(),
parentId = json['parent_id'],
purchaseNote = json['purchase_note'],
categories = (json['categories'] as List)
.map((i) => Category.fromJson(i))
.toList(),
tags = (json['tags'] as List).map((i) => Tag.fromJson(i)).toList(),
images =
(json['images'] as List).map((i) => Image.fromJson(i)).toList(),
attributes = (json['attributes'] as List)
.map((i) => Attribute.fromJson(i))
.toList(),
defaultAttributes = (json['default_attributes'] as List)
.map((i) => DefaultAttribute.fromJson(i))
.toList(),
variations = json['variations'].cast<int>(),
groupedProducts = json['grouped_products'].cast<int>(),
menuOrder = json['menu_order'],
dateCreated = json['date_created'],
dateCreatedGMT = json['date_created_gmt'],
metaData = (json['meta_data'] as List)
.map((i) => MetaData.fromJson(i))
.toList();