2
我正在嘗試使用Magentor寶石。文檔非常薄弱。我成功地致電Magento::Category.info(1)
。如何使用Magentor寶石
但我沒有打電話給Magento::Category.create(args)
。
該方法的定義如下所示。
# 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)
record = new(attributes)
record.id = id
record
end
這裏就是我試過。(父ID爲1)
args = [1, {:name => 'Cars', :description => 'Great Cars', :is_active => '1', :url_key => 'cars'}]
category_id = Magento::Category.create(args)
exception: 1 -> SQLSTATE[21000]: Cardinality violation: 1241 Operand should contain 1 column(s)
誰能提供調用該方法的一個例子嗎?
看起來像一個有趣的項目。生成的rdoc實際上看起來比我預期的要好得多。 – pguardiario