Permalink
Browse files

Added parent_id to Category.create()

Category create now takes a parent_id and attributes for create
  • Loading branch information...
1 parent ae6e389 commit eb9b48e35ee9db0e2135ff6474f12cf0e3274ca3 @pstuteville committed Nov 5, 2012
Showing with 46 additions and 46 deletions.
  1. +46 −46 lib/magento/category.rb
@@ -11,28 +11,28 @@ class Category < Base
class << self
# 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)
- def create(attributes)
- id = commit("create", attributes)
+ def create(parent_id, attributes)
+ id = commit("create", parent_id, attributes)
record = new(attributes)
record.id = id
record
end
# 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)
@@ -42,11 +42,11 @@ def info(*args)
# 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)
@@ -56,35 +56,35 @@ def update(*args)
# catalog_category.delete
# Delete category
- #
+ #
# Return: boolean
- #
+ #
# Arguments:
- #
+ #
# int $categoryId - category ID
def delete(*args)
commit("delete", *args)
end
# catalog_category.currentStore
# Set/Get current store view
- #
+ #
# Return: int
- #
+ #
# Arguments:
- #
+ #
# mixed storeView - Store view ID or code.
def current_store(*args)
commit("currentStore", *args)
end
# catalog_category.tree
# Retrieve hierarchical tree of categories.
- #
+ #
# Return: array
- #
+ #
# Arguments:
- #
+ #
# int parentId - parent category id (optional)
# mixed storeView - store view (optional)
def tree(*args)
@@ -93,11 +93,11 @@ def tree(*args)
# 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)
@@ -107,29 +107,29 @@ def level(*args)
# 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
+ #
+ # 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
def move(*args)
commit("move", *args)
end
# catalog_category.assignedProducts
# Retrieve list of assigned products
- #
+ #
# Return: array
- #
+ #
# Arguments:
- #
+ #
# int $categoryId - category ID
# mixed $store - store ID or code
def assigned_products(*args)
@@ -138,11 +138,11 @@ def assigned_products(*args)
# 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)
@@ -152,11 +152,11 @@ def assign_product(*args)
# 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)
@@ -166,36 +166,36 @@ def update_product(*args)
# catalog_category.removeProduct
# Remove product assignment from category
- #
+ #
# Return: boolean
- #
+ #
# Arguments:
- #
+ #
# int $categoryId - category ID
# mixed $product - product ID or sku
def remove_product(*args)
commit("removeProduct", *args)
end
-
+
def find_by_id(id)
info(id)
end
end
-
+
def delete
self.class.delete(self.id)
end
-
+
def update_attribute(name, value)
@attributes[name] = value
self.class.update(self.id, Hash[*[name.to_sym, value]])
end
-
+
def update_attributes(attrs)
attrs.each_pair { |k, v| @attributes[k] = v }
self.class.update(self.id, attrs)
end
-
+
def assigned_products(*args)
self.class.assigned_products(self.id, *args)
end

0 comments on commit eb9b48e

Please sign in to comment.