class Shopify::Product
- Shopify::Product
- Shopify::Resource
- Reference
- Object
Extended Modules
- Shopify::Resource::ClassMethods
Defined in:
shopify/resources/product.crConstructors
Class Method Summary
-
.all(domain : String, depth : Int32 = 20, headers : HTTP::Headers = headers) : Array(Shopify::Product)
Used to return an array of products.
-
.all(domain : String, next_page_uri : String? = nil, depth : Int32 = 20, headers : HTTP::Headers = headers, &block : self -> )
Used to iterate over all products.
-
.count(domain : String, headers : HTTP::Headers = headers) : Int64
Used to get a count of all products.
-
.create(body : String, domain : String, headers : HTTP::Headers = headers) : Shopify::Product
Used to create one product.
-
.find(id : Int64, domain : String, headers : HTTP::Headers = headers) : Shopify::Product
Used to fetch one product.
- .uri(domain : String, path : String = "") : URI
- .with(store : Store)
Instance Method Summary
- #body_html : String
- #body_html=(body_html : String)
- #create_product_variant(body : String) : Shopify::ProductVariant
- #created_at : Time
- #created_at=(created_at : Time)
-
#delete
Used to delete one product.
- #handle : String
- #handle=(handle : String)
- #id : Int64
- #id=(id : Int64)
- #images : Array(JSON::Any)
- #images=(images : Array(JSON::Any))
- #options : JSON::Any
- #options=(options : JSON::Any)
- #product_type : String
- #product_type=(product_type : String)
- #published_at : Time?
- #published_at=(published_at : Time?)
- #published_scope : String
- #published_scope=(published_scope : String)
- #status : String
- #status=(status : String)
- #tags : String
- #tags=(tags : String)
- #template_suffix : String?
- #template_suffix=(template_suffix : String?)
- #title : String
- #title=(title : String)
-
#update(body : String) : self
Under the covers, this just runs:
plaintext PUT /admin/api/2022-01/products/{id}.json
- #updated_at : Time
- #updated_at=(updated_at : Time)
- #variants : Array(Shopify::ProductVariant)
- #variants=(variants : Array(Shopify::ProductVariant))
- #vendor : String
- #vendor=(vendor : String)
Instance methods inherited from class Shopify::Resource
store : Store
store,
store=(store : Store)
store=
Constructor methods inherited from class Shopify::Resource
new(pull : JSON::PullParser)
new
Class methods inherited from class Shopify::Resource
headers
headers
Constructor Detail
Class Method Detail
Used to return an array of products. Uses fibers to fetch pages concurrently.
NOTE It is recommended to use .all(domain, next_page_uri, headers, &block)
directly instead of this method as it is more performant.
Generally, this is used with .with(store)
:
Shopify::Product.with(store).all #=> Array(Shopify::Product)
But it can be used stand-alone, too:
Shopify::Product.all(domain, headers: headers) #=> Array(Shopify::Product)
This just runs the &block
version of .all(domain, next_page_uri, headers, &block)
to create an array
Used to iterate over all products. Uses fibers to fetch pages concurrently.
Generally, this is used with .with(store)
:
Shopify::Product.with(store).all do |product|
# do something with product
end
But it can be used stand-alone, too:
Shopify::Product.all(domain, headers: headers) do |product|
# do something with product
end
Under the covers, this just runs:
GET
/admin/api/2022-01/products.json
and follows every next Response Headers "Link" until there are no more.
Uses NextPreviousParser
to parse the response headers.
Used to get a count of all products.
Generally, this is used with .with(store)
:
Shopify::Product.with(store).count #=> Int64
But it can be used stand-alone, too:
Shopify::Product.count(domain, headers: headers) #=> Int64
Under the covers, this just runs:
GET
/admin/api/2022-01/products/count.json
Used to create one product.
Generally, this is used with .with(store)
:
Shopify::Product.with(store).create(body) #=> Shopify::Product
But it can be used stand-alone, too:
Shopify::Product.create(body, domain, headers: headers) #=> Shopify::Product
Under the covers, this just runs:
POST
/admin/api/2022-01/products.json
Used to fetch one product.
Generally, this is used with .with(store)
:
Shopify::Product.with(store).find(id) #=> Shopify::Product
But it can be used stand-alone, too:
Shopify::Product.find(id, domain, headers: headers) #=> Shopify::Product
Under the covers, this just runs:
GET
/admin/api/2022-01/products/{id}.json
Instance Method Detail
Used to delete one product.
Under the covers, this just runs:
DELETE
/admin/api/2022-01/products/{id}.json
Under the covers, this just runs:
PUT
/admin/api/2022-01/products/{id}.json