Skip to content

Commit 1ace946

Browse files
authored
Update README.md
1 parent eb901b1 commit 1ace946

File tree

1 file changed

+31
-1
lines changed

1 file changed

+31
-1
lines changed

README.md

Lines changed: 31 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -134,8 +134,38 @@ $data = [
134134
],
135135
];
136136
137-
137+
// Create a product using create() method
138138
$product = Product::create($data);
139+
140+
// Create a product using save() method
141+
$categories = [
142+
[
143+
'id' => 1,
144+
],
145+
[
146+
'id' => 3,
147+
],
148+
];
149+
150+
$images = [
151+
[
152+
'src' => 'http://demo.woothemes.com/woocommerce/wp-content/uploads/sites/56/2013/06/T_2_front.jpg',
153+
],
154+
[
155+
'src' => 'http://demo.woothemes.com/woocommerce/wp-content/uploads/sites/56/2013/06/T_2_back.jpg',
156+
],
157+
];
158+
159+
$product = new Product;
160+
$product->name = 'Product Eloquent 2';
161+
$product->type = 'simple';
162+
$product->regular_price = '100';
163+
$product->sale_price = '50';
164+
$product->description = 'Product Description';
165+
$product->short_description = 'Product Short Description';
166+
$product->categories = $categories;
167+
$product->images = $images;
168+
$product->save();
139169
```
140170
#Update existing Product
141171

0 commit comments

Comments
 (0)