Inheritance: extends Mage2\Framework\System\Models\BaseModel
 private function _getProductBySlug($slug)
 {
     $slugAttribute = ProductAttribute::where('identifier', '=', 'slug')->get()->first();
     $productVarcharValue = ProductVarcharValue::where('product_attribute_id', '=', $slugAttribute->id)->where('value', '=', $slug)->where('website_id', '=', $this->websiteId)->get()->first();
     $product = Product::findorfail($productVarcharValue->product_id);
     return $product;
 }
Esempio n. 2
0
 public function addToCart(Request $request, $id)
 {
     $cart = Session::get('cart');
     $product = Product::findorfail($id);
     if (null !== $request->get('qty') && !isset($cart[$id])) {
         $cart[$id] = ['id' => $id, 'qty' => $request->get('qty'), 'price' => $product->price, 'tax_amount' => $product->getTaxAmount(), 'model' => $product];
     } elseif (null !== $request->get('qty') && isset($cart[$id])) {
         $cart[$id]['qty'] += $request->get('qty');
     } elseif (null === $request->get('qty') && isset($cart[$id])) {
         $cart[$id]['qty'] += 1;
     } else {
         $cart[$id] = ['id' => $id, 'qty' => 1, 'price' => $product->price, 'tax_amount' => $product->getTaxAmount(), 'model' => $product];
     }
     Session::put('cart', $cart);
     return redirect()->back()->with('notificationText', 'Product Added to Cart Successfully!');
 }
 /**
  * Remove the specified resource from storage.
  *
  * @param int $id
  *
  * @return \Illuminate\Http\Response
  */
 public function destroy($id)
 {
     Product::destroy($id);
     return redirect()->route('admin.product.index');
 }
Esempio n. 4
0
 /**
  * Show the application dashboard.
  *
  * @return \Illuminate\Http\Response
  */
 public function index()
 {
     $product = new Product();
     $featureProducts = $product->getFeaturedProducts();
     return view('home.index')->with('featuredProducts', $featureProducts);
 }