Inheritance: extends Mage2\Framework\System\Models\BaseModel
コード例 #1
0
 /**
  * Bind data to the view.
  *
  * @param  View  $view
  * @return void
  */
 public function compose(View $view)
 {
     $cart = count(Session::get('cart'));
     $categoryModel = new Category();
     $baseCategories = $categoryModel->getAllCategories();
     $view->with('categories', $baseCategories)->with('cart', $cart);
 }
コード例 #2
0
 public function view($slug)
 {
     $productsOnCategoryPage = Configuration::getConfiguration('mage2_catalog_no_of_product_category_page');
     $category = Category::where('slug', '=', $slug)->get()->first();
     $products = $category->products()->paginate($productsOnCategoryPage);
     return view('catalog.category.view')->with('category', $category)->with('products', $products);
 }
コード例 #3
0
 private function _getCategoryOptions()
 {
     $options = Collection::make([0 => 'please select'] + Category::pluck('name', 'id')->toArray())->toArray();
     return $options;
 }
コード例 #4
0
 public function _deleteTestCategory()
 {
     //@todo If we run test second time it will fail. (try to use data using faker).
     Category::where('slug', '=', 'test-category')->delete();
 }
コード例 #5
0
 public function getCategoryOptions()
 {
     $options = Category::pluck('name', 'id');
     return $options;
 }