File tree Expand file tree Collapse file tree 1 file changed +31
-1
lines changed
Expand file tree Collapse file tree 1 file changed +31
-1
lines changed Original file line number Diff line number Diff 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
You can’t perform that action at this time.
0 commit comments