Class: Magento::ProductMedia

Inherits:
Base
  • Object
show all
Defined in:
lib/magento/product_media.rb

Overview

www.magentocommerce.com/wiki/doc/webservices-api/api/catalog_product_attribute_media 100 Requested store view not found. 101 Product not exists. 102 Invalid data given. Details in error message. 103 Requested image not exists in product images’ gallery. 104 Image creation failed. Details in error message. 105 Image not updated. Details in error message. 106 Image not removed. Details in error message. 107 Requested product doesn’t support images

Instance Attribute Summary

Attributes inherited from Base

#attributes

Class Method Summary collapse

Methods included from Base::ClassMethods

#api_path, #commit

Methods included from Base::InstanceMethods

#id, #id=, #initialize, #method_missing, #object_attributes=

Dynamic Method Handling

This class handles dynamic methods through the method_missing method in the class Magento::Base::InstanceMethods

Class Method Details

.create(*args) ⇒ Object

catalog_product_attribute_media.create Upload new product image

Return: string - image file name

Arguments:

mixed product - product ID or code array data - image data. requires file content in base64, and image mime-type.

Example: array(’file’ ⇒ array(’content’ ⇒ base64_encode($file), ‘mime’ ⇒ ‘type/jpeg’)
mixed storeView - store view ID or code (optional)


40
41
42
43
44
# File 'lib/magento/product_media.rb', line 40

def create(*args)
  id = commit("create", *args)
  record = info(id)
  record
end

.current_store(*args) ⇒ Object

catalog_product_attribute_media.currentStore Set/Get current store view

Return: int

Arguments:

mixed storeView - store view code or ID (optional)



96
97
98
# File 'lib/magento/product_media.rb', line 96

def current_store(*args)
  commit("currentStore", *args)
end

.find_by_product_id_or_sku(id) ⇒ Object



112
113
114
# File 'lib/magento/product_media.rb', line 112

def find_by_product_id_or_sku(id)
  list(id)
end

.info(*args) ⇒ Object

catalog_product_attribute_media.info Retrieve product image data

Return: array

Arguments:

mixed product - product ID or Sku string file - image file name mixed storeView - store view ID or code (optional)



56
57
58
# File 'lib/magento/product_media.rb', line 56

def info(*args)
  new(commit("info", *args))
end

.list(*args) ⇒ Object

catalog_product_attribute_media.list Retrieve product image list

Return: array

Arguments:

mixed product - product ID or Sku mixed storeView - store view ID or code (optional)



22
23
24
25
26
27
# File 'lib/magento/product_media.rb', line 22

def list(*args)
  results = commit("list", *args)
  results.collect do |result|
    new(result)
  end
end

.remove(*args) ⇒ Object

catalog_product_attribute_media.remove Remove product image

Return: boolean

Arguments:

mixed product - product ID or Sku string file - image file name



84
85
86
# File 'lib/magento/product_media.rb', line 84

def remove(*args)
  commit("remove", *args)
end

.types(*args) ⇒ Object

catalog_product_attribute_media.types Retrieve product image types (image, small_image, thumbnail, etc…)

Return: array

Arguments:

int setId - product attribute set ID



108
109
110
# File 'lib/magento/product_media.rb', line 108

def types(*args)
  commit("types", *args)
end

.update(*args) ⇒ Object

catalog_product_attribute_media.update Update product image

Return: boolean

Arguments:

mixed product - product ID or code string file - image file name array data - image data (label, position, exclude, types) mixed storeView - store view ID or code (optional)



71
72
73
# File 'lib/magento/product_media.rb', line 71

def update(*args)
  commit("update", *args)
end