Last active
August 29, 2015 14:08
-
-
Save ferencbeutel4711/ae8e1f5eb2a42e5596cd to your computer and use it in GitHub Desktop.
Produkte laden und Ausgeben
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#Der Aufruf der Methode getUrl(250, 250) sorgt dafür, dass das Bild in der entsprechenden Größe angefordert und angezeigt wird. | |
require 'aboutyou-sdk' | |
shopApi = AY.new(100, '3ed93394c2b5ebd12c104b177b928ad0') | |
criteria = shopApi.productSearchCriteria.selectProductFields([ | |
AboutYou::SDK::Criteria::ProductFields::DEFAULT_IMAGE | |
]) | |
products = shopApi.fetchProductSearch(criteria).products | |
products.each do |product| | |
puts product.defaultImage.url(250, 250) | |
puts product.name | |
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
require 'aboutyou-sdk' | |
shopApi = Ay.new(100, '3ed93394c2b5ebd12c104b177b928ad0') | |
id = 508560 | |
productsResult = shopApi.fetchProductsByIds([id], [ | |
AboutYou::SDK::Criteria::ProductFields::MIN_PRICE, | |
AboutYou::SDK::Criteria::ProductFields::MAX_PRICE, | |
AboutYou::SDK::Criteria::ProductFields::IS_SALE, | |
AboutYou::SDK::Criteria::ProductFields::DESCRIPTION_SHORT, | |
AboutYou::SDK::Criteria::ProductFields::DESCRIPTION_LONG | |
]) | |
if (productsResult.productsNotFound || !(productsResult.key?(id))) | |
puts 'Exception! product not found: ' + String(id) | |
end | |
product = productsResult[id] | |
if !(product.isActive) | |
raise 'Exception! product is inactive: ' + String(id); | |
end | |
puts 'Product: ' + product.name | |
puts ' sale: ' + product.isSale | |
puts ' min/max price: ' String(product.minPrice / 100) + '€ / ' + String(product.maxPrice / 100) + '€' | |
puts ' short: ' + product.descriptionShort | |
puts ' long: ' + product.descriptionLong |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
require 'aboutyou-sdk' | |
shopApi = AY.new(100, '3ed93394c2b5ebd12c104b177b928ad0') | |
productsResult = shopApi.fetchProductsByIds([508558, 508560]) | |
productsResult.each do |product| | |
puts ' ' + product.id + ': ' + product.name | |
end | |
productsResult = shopApi.fetchProductsByEans(['419597259', '419596663']) | |
productsResult.each do |product| | |
puts ' ' + product.id + ': ' + product.name | |
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
require 'aboutyou-sdk' | |
shopApi = AY.new(100, '3ed93394c2b5ebd12c104b177b928ad0') | |
# fetchProductsByIds() | |
productsByIdResult = shopApi.fetchProductsByIds([507865], [ | |
AboutYou::SDK::Criteria::ProductFields::BRAND, | |
AboutYou::SDK::Criteria::ProductFields::VARIANTS | |
]) | |
# fetchProductsByEans() | |
productsByEanResult = shopApi.fetchProductsByEans(['419597259'], [ | |
AboutYou::SDK::Criteria::ProductFields::VARIANTS | |
]) | |
# fetchProductSearch() | |
criteria = shopApi.productSearchCriteria.selectProductFields([ | |
AboutYou::SDK::Criteria::ProductFields::DEFAULT_IMAGE | |
]) | |
productSearchResult = shopApi.fetchProductSearch(criteria).products |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
require 'aboutyou-sdk' | |
shopApi = AY.new(100, '3ed93394c2b5ebd12c104b177b928ad0') | |
id = 507865 | |
productsResult = shopApi.fetchProductsByIds([id], [ | |
AboutYou::SDK::Criteria::ProductFields::BRAND, | |
AboutYou::SDK::Criteria::ProductFields::VARIANTS | |
]) | |
if (productsResult.productsNotFound || !(productsResult.key?(id))) | |
raise 'Exception! product not found: ' + String(id) | |
end | |
product = productsResult[id]; | |
puts 'Produkt: ' + product.id | |
puts 'Brand: ' + product.brand.name + ' (ID: ' + String(product.brand.id) + ')' | |
product.styles.each do |style| | |
puts 'Style: ' + String(style.id) | |
puts 'Varianten:' | |
style.variants.each do |variant| | |
puts variant.id | |
end | |
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
require 'aboutyou-sdk' | |
shopApi = AY.new(100, '3ed93394c2b5ebd12c104b177b928ad0') | |
result = shopApi.fetchVariantsByIds([6732075, 6732076]) | |
variants = result.variantsFound | |
variants.each do |variant| | |
echo 'EAN: ' + variant.ean | |
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
require 'aboutyou-sdk' | |
shopApi = AY.new(100, '3ed93394c2b5ebd12c104b177b928ad0') | |
id = 507865 | |
productsResult = shopApi.fetchProductsByIds([id], [ | |
AboutYou::SDK::Criteria::ProductFields::VARIANTS, | |
AboutYou::SDK::Criteria::ProductFields::CATEGORIES, | |
AboutYou::SDK::Criteria::ProductFields::MIN_PRICE, | |
AboutYou::SDK::Criteria::ProductFields::MAX_PRICE | |
]) | |
product = productsResult[id] | |
category = product.categoryWithLongestActivePath | |
puts breadcrumb(category) | |
puts 'ab ' + String(product.minPrice / 100) + '€' | |
puts 'bis ' + String(product.maxPrice / 100) + '€' | |
product.variants.each do |variant| | |
if (variant.isDefault) | |
images = variant.images | |
defaultImage = images[0] | |
end | |
end | |
if (defaultImage) | |
puts defaultImage.url | |
end | |
def breadcrumb(category, path = nil) | |
if (path) | |
path = category.name + path | |
else | |
path = category.name | |
end | |
if (category.parent) | |
path = breadcrumb(category.parent, path) | |
end | |
return path; | |
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
require 'aboutyou-sdk' | |
shopApi = AY.new(100, '3ed93394c2b5ebd12c104b177b928ad0') | |
productResult = shopApi.fetchProductsByEans(['419597259'], [AboutYou::SDK::Criteria::ProductFields::VARIANTS]) | |
productResult.each do |product| | |
variants = product.variantsByEan('419597259') | |
variants.each do |variant| | |
puts 'Anzahl: ' + variant.quantity | |
end | |
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
require 'aboutyou-sdk' | |
shopApi = AY.new(100, '3ed93394c2b5ebd12c104b177b928ad0') | |
productResult = shopApi.fetchProductsByIds( | |
[507857], | |
[AboutYou::SDK::Criteria::ProductFields::VARIANTS, | |
AboutYou::SDK::Criteria::ProductFields::DEFAULT_IMAGE] | |
) | |
products = productResult.products | |
products.each do |product| | |
puts product.defaultImage.url(250, 250) | |
puts product.name | |
variants = product.variants | |
variants.each do |variant| | |
images = variant.images | |
images.each do |image| | |
puts image.url(125, 125) | |
puts variant.id | |
end | |
end | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment