在我的应用程序中,我必须创建这样一个结构:
$arrProducts = array(
array(
“product_id” => “1”,
“qty” => 2
"options" => array(
optionId_1 => optionValue_1,
...,
optionId_n => optionValue_n
)我做了这个数组,所以:
NSDictionary *dict = @{
@"product_id" : productID,
@"qty": self.qty
};
NSArray *array2 = @[dict];这个数组应该与Magento商店一起工作,当我运行该应用程序时,它会向我显示以下消息:
error cart_product.add: SQLSTATE[21000]: Cardinality violation: 1241 Operand should contain 1 column(s)
我猜这个问题,取决于我如何创建这个数组,但是我不知道这个数组有什么问题,你能帮我修复它吗?
更新:
我用来连接Magento的库需要这样的结构:
[Magento call:@[@"customer.create", @{
@"email": email,
@"password": password,
@"firstname": firstname,
@"lastname": lastname,
@"website_id": @1,
@"store_id": Magento.service.storeID
}] success:^(AFHTTPRequestOperation *operation, id responseObject) {
Magento.service.customerID = responseObject;
NSLog(@"signUp customerID = %@", Magento.service.customerID);
} failure:^(AFHTTPRequestOperation *operation, NSError *error) {
NSLog(@"error %@", error.localizedDescription);
}];我将使用它将产品添加到购物车中,如果您查看Magento SOAP将产品添加到cart中,您可以看到在php中,通过使用数组的数组来添加产品。我需要复制同样的结构。
发布于 2013-11-18 10:27:51
首先,在数组中放置一个NSDictionary,然后再执行一次。这是错误的。这样做吧:
NSDictionary *product1 = @{@"product_id" : productID, @"qty": self.qty, "options" : @{optionId_n : optionValue_n}};
NSDictionary *product2 = @{@"product_id" : productID, @"qty": self.qty, "options" : @{optionId_n : optionValue_n}};
NSArray *products = @[product1, product2];https://stackoverflow.com/questions/20045348
复制相似问题