Class: Magento::Product
Overview
www.magentocommerce.com/wiki/doc/webservices-api/api/catalog_product 100 Requested store view not found. 101 Product not exists. 102 Invalid data given. Details in error message. 103 Product not deleted. Details in error message.
Instance Attribute Summary
Attributes inherited from Base
Class Method Summary collapse
- .all ⇒ Object
-
.create(*args) ⇒ Object
catalog_product.create Create new product and return product id.
-
.current_store(*args) ⇒ Object
catalog_product.currentStore Set/Get current store view.
-
.delete(*args) ⇒ Object
catalog_product.delete Delete product.
- .find(find_type, options = {}) ⇒ Object
- .find_by_id(id) ⇒ Object
- .find_by_id_or_sku(id) ⇒ Object
-
.get_special_price(*args) ⇒ Object
catalog_product.getSpecialPrice Get product special price data.
-
.info(*args) ⇒ Object
catalog_product.info Retrieve product.
-
.list(*args) ⇒ Object
catalog_product.list Retrieve products list by filters.
-
.set_special_price(*args) ⇒ Object
catalog_product.setSpecialPrice Update product special price.
-
.update(*args) ⇒ Object
catalog_product.update Update product.
Instance Method Summary collapse
Methods included from Base::ClassMethods
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
.all ⇒ Object
143 144 145 |
# File 'lib/magento/product.rb', line 143 def all list end |
.create(*args) ⇒ Object
catalog_product.create Create new product and return product id
Return: int
Arguments:
string type - product type int set - product attribute set ID string sku - product SKU array productData - array of attributes values
36 37 38 39 40 |
# File 'lib/magento/product.rb', line 36 def create(*args) id = commit("create", *args) record = info(id) record end |
.current_store(*args) ⇒ Object
catalog_product.currentStore Set/Get current store view
Return: int
Arguments:
mixed storeView - store view ID or code (optional)
91 92 93 |
# File 'lib/magento/product.rb', line 91 def current_store(*args) commit("currentStore", *args) end |
.delete(*args) ⇒ Object
catalog_product.delete Delete product
Return: boolean
Arguments:
mixed product - product ID or Sku
79 80 81 |
# File 'lib/magento/product.rb', line 79 def delete(*args) commit("delete", *args) end |
.find(find_type, options = {}) ⇒ Object
132 133 134 135 136 137 138 139 140 141 |
# File 'lib/magento/product.rb', line 132 def find(find_type, = {}) filters = {} .each_pair { |k, v| filters[k] = {:eq => v} } results = list(filters) if find_type == :first results.first else results end end |
.find_by_id(id) ⇒ Object
128 129 130 |
# File 'lib/magento/product.rb', line 128 def find_by_id(id) info(id) end |
.find_by_id_or_sku(id) ⇒ Object
124 125 126 |
# File 'lib/magento/product.rb', line 124 def find_by_id_or_sku(id) find_by_id(id) end |
.get_special_price(*args) ⇒ Object
catalog_product.getSpecialPrice Get product special price data
Return: array
Arguments:
mixed product - product ID or Sku mixed storeView - store view ID or code (optional)
120 121 122 |
# File 'lib/magento/product.rb', line 120 def get_special_price(*args) commit('getSpecialPrice', *args) end |
.info(*args) ⇒ Object
catalog_product.info Retrieve product
Return: array
Arguments:
mixed product - product ID or Sku mixed storeView - store view ID or code (optional) array attributes - list of attributes that will be loaded (optional)
52 53 54 |
# File 'lib/magento/product.rb', line 52 def info(*args) new(commit("info", *args)) end |
.list(*args) ⇒ Object
catalog_product.list Retrieve products list by filters
Return: array
Arguments:
array filters - array of filters by attributes (optional) mixed storeView - store view ID or code (optional)
18 19 20 21 22 23 |
# File 'lib/magento/product.rb', line 18 def list(*args) results = commit("list", *args) results.collect do |result| new(result) end end |
.set_special_price(*args) ⇒ Object
catalog_product.setSpecialPrice Update product special price
Return: boolean
Arguments:
mixed product - product ID or Sku float specialPrice - special price (optional) string fromDate - from date (optional) string toDate - to date (optional) mixed storeView - store view ID or code (optional)
107 108 109 |
# File 'lib/magento/product.rb', line 107 def set_special_price(*args) commit('setSpecialPrice', *args) end |
.update(*args) ⇒ Object
catalog_product.update Update product
Return: boolean
Arguments:
mixed product - product ID or Sku array productData - array of attributes values mixed storeView - store view ID or code (optional)
66 67 68 |
# File 'lib/magento/product.rb', line 66 def update(*args) commit("update", *args) end |
Instance Method Details
#delete ⇒ Object
149 150 151 |
# File 'lib/magento/product.rb', line 149 def delete self.class.delete(self.id) end |
#update_attribute(name, value) ⇒ Object
153 154 155 156 |
# File 'lib/magento/product.rb', line 153 def update_attribute(name, value) @attributes[name] = value self.class.update(self.id, Hash[*[name.to_sym, value]]) end |
#update_attributes(attrs) ⇒ Object
158 159 160 161 |
# File 'lib/magento/product.rb', line 158 def update_attributes(attrs) attrs.each_pair { |k, v| @attributes[k] = v } self.class.update(self.id, attrs) end |