Class: Magento::Category
Overview
www.magentocommerce.com/wiki/doc/webservices-api/api/catalog_category 100 Requested store view not found. 101 Requested website not found. 102 Category not exists. 103 Invalid data given. Details in error message. 104 Category not moved. Details in error message. 105 Category not deleted. Details in error message. 106 Requested product is not assigned to category.
Instance Attribute Summary
Attributes inherited from Base
Class Method Summary collapse
-
.assign_product(*args) ⇒ Object
catalog_category.assignProduct Assign product to category.
-
.assigned_products(*args) ⇒ Object
catalog_category.assignedProducts Retrieve list of assigned products.
-
.create(attributes) ⇒ Object
catalog_category.create Create new category and return its id.
-
.current_store(*args) ⇒ Object
catalog_category.currentStore Set/Get current store view.
-
.delete(*args) ⇒ Object
catalog_category.delete Delete category.
- .find_by_id(id) ⇒ Object
-
.info(*args) ⇒ Object
catalog_category.info Retrieve category data.
-
.level(*args) ⇒ Object
catalog_category.level Retrieve one level of categories by website/store view/parent category.
-
.move(*args) ⇒ Object
catalog_category.move Move category in tree.
-
.remove_product(*args) ⇒ Object
catalog_category.removeProduct Remove product assignment from category.
-
.tree(*args) ⇒ Object
catalog_category.tree Retrieve hierarchical tree of categories.
-
.update(*args) ⇒ Object
catalog_category.update Update category.
-
.update_product(*args) ⇒ Object
catalog_category.updateProduct Update assigned product.
Instance Method Summary collapse
- #assign_product(*args) ⇒ Object
- #assigned_products(*args) ⇒ Object
- #delete ⇒ Object
- #remove_product(*args) ⇒ Object
- #update_attribute(name, value) ⇒ Object
- #update_attributes(attrs) ⇒ Object
- #update_product(*args) ⇒ Object
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
.assign_product(*args) ⇒ Object
catalog_category.assignProduct Assign product to category
Return: boolean
Arguments:
int $categoryId - category ID mixed $product - product ID or sku int $position - position of product in category (optional)
149 150 151 |
# File 'lib/magento/category.rb', line 149 def assign_product(*args) commit("assignProduct", *args) end |
.assigned_products(*args) ⇒ Object
catalog_category.assignedProducts Retrieve list of assigned products
Return: array
Arguments:
int $categoryId - category ID mixed $store - store ID or code
135 136 137 |
# File 'lib/magento/category.rb', line 135 def assigned_products(*args) commit("assignedProducts", *args) end |
.create(attributes) ⇒ Object
catalog_category.create Create new category and return its id.
Return: int
Arguments:
int $parentId - ID of parent category array $categoryData - category data ( array(’attribute_code’⇒‘attribute_value’ ) mixed $storeView - store view ID or code (optional)
22 23 24 25 26 27 |
# File 'lib/magento/category.rb', line 22 def create(attributes) id = commit("create", attributes) record = new(attributes) record.id = id record end |
.current_store(*args) ⇒ Object
catalog_category.currentStore Set/Get current store view
Return: int
Arguments:
mixed storeView - Store view ID or code.
77 78 79 |
# File 'lib/magento/category.rb', line 77 def current_store(*args) commit("currentStore", *args) end |
.delete(*args) ⇒ Object
catalog_category.delete Delete category
Return: boolean
Arguments:
int $categoryId - category ID
65 66 67 |
# File 'lib/magento/category.rb', line 65 def delete(*args) commit("delete", *args) end |
.find_by_id(id) ⇒ Object
180 181 182 |
# File 'lib/magento/category.rb', line 180 def find_by_id(id) info(id) end |
.info(*args) ⇒ Object
catalog_category.info Retrieve category data
Return: array
Arguments:
int $categoryId - category ID mixed $storeView - store view id or code (optional) array $attributes - return only specified attributes (optional)
39 40 41 |
# File 'lib/magento/category.rb', line 39 def info(*args) new(commit("info", *args)) end |
.level(*args) ⇒ Object
catalog_category.level Retrieve one level of categories by website/store view/parent category
Return: array
Arguments:
mixed website - website code or Id (optional) mixed storeView - store view code or Id (optional) mixed parentCategory - parent category Id (optional)
104 105 106 |
# File 'lib/magento/category.rb', line 104 def level(*args) commit("level", *args) end |
.move(*args) ⇒ Object
catalog_category.move Move category in tree
Return: boolean
Arguments:
int $categoryId - category ID for moving int $parentId - new category parent int $afterId - category ID after what position it will be moved (optional)
NOTE Please make sure that you are not moving category to any of its own children. There are no extra checks to prevent doing it through webservices API, and you won’t be able to fix this from admin interface then
122 123 124 |
# File 'lib/magento/category.rb', line 122 def move(*args) commit("move", *args) end |
.remove_product(*args) ⇒ Object
catalog_category.removeProduct Remove product assignment from category
Return: boolean
Arguments:
int $categoryId - category ID mixed $product - product ID or sku
176 177 178 |
# File 'lib/magento/category.rb', line 176 def remove_product(*args) commit("removeProduct", *args) end |
.tree(*args) ⇒ Object
catalog_category.tree Retrieve hierarchical tree of categories.
Return: array
Arguments:
int parentId - parent category id (optional) mixed storeView - store view (optional)
90 91 92 |
# File 'lib/magento/category.rb', line 90 def tree(*args) commit("tree", *args) end |
.update(*args) ⇒ Object
catalog_category.update Update category
Return: boolean
Arguments:
int $categoryId - ID of category for updating array $categoryData - category data ( array(’attribute_code’⇒‘attribute_value’ ) mixed storeView - store view ID or code (optional)
53 54 55 |
# File 'lib/magento/category.rb', line 53 def update(*args) commit("update", *args) end |
.update_product(*args) ⇒ Object
catalog_category.updateProduct Update assigned product
Return: boolean
Arguments:
int $categoryId - category ID mixed $product - product ID or sku int $position - position of product in category (optional)
163 164 165 |
# File 'lib/magento/category.rb', line 163 def update_product(*args) commit("updateProduct", *args) end |
Instance Method Details
#assign_product(*args) ⇒ Object
203 204 205 |
# File 'lib/magento/category.rb', line 203 def assign_product(*args) self.class.assign_product(self.id, *args) end |
#assigned_products(*args) ⇒ Object
199 200 201 |
# File 'lib/magento/category.rb', line 199 def assigned_products(*args) self.class.assigned_products(self.id, *args) end |
#delete ⇒ Object
185 186 187 |
# File 'lib/magento/category.rb', line 185 def delete self.class.delete(self.id) end |
#remove_product(*args) ⇒ Object
211 212 213 |
# File 'lib/magento/category.rb', line 211 def remove_product(*args) self.class.remove_product(self.id, *args) end |
#update_attribute(name, value) ⇒ Object
189 190 191 192 |
# File 'lib/magento/category.rb', line 189 def update_attribute(name, value) @attributes[name] = value self.class.update(self.id, Hash[*[name.to_sym, value]]) end |
#update_attributes(attrs) ⇒ Object
194 195 196 197 |
# File 'lib/magento/category.rb', line 194 def update_attributes(attrs) attrs.each_pair { |k, v| @attributes[k] = v } self.class.update(self.id, attrs) end |
#update_product(*args) ⇒ Object
207 208 209 |
# File 'lib/magento/category.rb', line 207 def update_product(*args) self.class.update_product(self.id, *args) end |