Inheritance: extends Mage2\Framework\System\Models\BaseModel
 /**
  * Bind data to the view.
  *
  * @param  View  $view
  * @return void
  */
 public function compose(View $view)
 {
     $productAttrobuteModel = new ProductAttribute();
     $isFeaturedOptions = $productAttrobuteModel->getIsFeaturedOptions();
     $statusOptions = $productAttrobuteModel->getStatusOptions();
     $view->with('isFeaturedOptions', $isFeaturedOptions)->with('statusOptions', $statusOptions);
 }
 /**
  * Bind data to the view.
  *
  * @param  View  $view
  * @return void
  */
 public function compose(View $view)
 {
     $productAttrobuteModel = new ProductAttribute();
     $trackStockOptions = $productAttrobuteModel->getTrackStockOptions();
     $inStockOptions = $productAttrobuteModel->getInStockOptions();
     $isTaxableOptions = $productAttrobuteModel->getIsTaxableOptions();
     $view->with('isTaxableOptions', $isTaxableOptions)->with('trackStockOptions', $trackStockOptions)->with('inStockOptions', $inStockOptions);
 }
Ejemplo n.º 3
0
 /**
  * Run the database seeds.
  *
  * @return void
  */
 public function run()
 {
     $productAttributeGroup = ProductAttributeGroup::create(['title' => 'Basic']);
     $seoGroup = ProductAttributeGroup::create(['title' => 'SEO']);
     $inventoryGroup = ProductAttributeGroup::create(['title' => 'Inventory']);
     ProductAttribute::insert([['title' => 'Title', 'product_attribute_group_id' => $productAttributeGroup->id, 'identifier' => 'title', 'type' => 'VARCHAR', 'field_type' => 'TEXT', 'validation' => 'required|max:255'], ['title' => 'Price', 'product_attribute_group_id' => $productAttributeGroup->id, 'identifier' => 'price', 'type' => 'FLOAT', 'field_type' => 'TEXT', 'validation' => 'required|max:8|regex:/^-?\\d*(\\.\\d+)?$/'], ['title' => 'Image', 'product_attribute_group_id' => 0, 'identifier' => 'image', 'type' => 'FILE', 'field_type' => 'FILE', 'validation' => ''], ['title' => 'SKU', 'product_attribute_group_id' => $productAttributeGroup->id, 'identifier' => 'sku', 'type' => 'VARCHAR', 'field_type' => 'TEXT', 'validation' => 'required|max:255'], ['title' => 'Slug', 'product_attribute_group_id' => $productAttributeGroup->id, 'identifier' => 'slug', 'type' => 'VARCHAR', 'field_type' => 'TEXT', 'validation' => 'required|max:255|alpha_dash'], ['title' => 'Page Title', 'product_attribute_group_id' => $seoGroup->id, 'identifier' => 'page_title', 'type' => 'VARCHAR', 'field_type' => 'TEXT', 'validation' => 'max:255'], ['title' => 'Page Description', 'product_attribute_group_id' => $seoGroup->id, 'identifier' => 'page_description', 'type' => 'VARCHAR', 'field_type' => 'TEXTAREA', 'validation' => 'max:255'], ['title' => 'Qty', 'product_attribute_group_id' => $inventoryGroup->id, 'identifier' => 'qty', 'type' => 'VARCHAR', 'field_type' => 'TEXT', 'validation' => ''], ['title' => 'Description', 'product_attribute_group_id' => $productAttributeGroup->id, 'identifier' => 'description', 'type' => 'TEXT', 'field_type' => 'TEXTAREA', 'validation' => 'required']]);
     $statusAttribute = ProductAttribute::create(['title' => 'Status', 'product_attribute_group_id' => $productAttributeGroup->id, 'identifier' => 'status', 'type' => 'VARCHAR', 'field_type' => 'SELECT', 'validation' => 'required']);
     AttributeDropdownOption::create(['product_attribute_id' => $statusAttribute->id, 'value' => '1', 'label' => 'Enabled']);
     AttributeDropdownOption::create(['product_attribute_id' => $statusAttribute->id, 'value' => '0', 'label' => 'Disabled']);
     $isTaxableAttribute = ProductAttribute::create(['title' => 'Is Taxable', 'product_attribute_group_id' => $inventoryGroup->id, 'identifier' => 'is_taxable', 'type' => 'VARCHAR', 'field_type' => 'SELECT', 'validation' => 'required']);
     AttributeDropdownOption::create(['product_attribute_id' => $isTaxableAttribute->id, 'value' => '1', 'label' => 'Yes']);
     AttributeDropdownOption::create(['product_attribute_id' => $isTaxableAttribute->id, 'value' => '0', 'label' => 'No']);
     $featureAttribute = ProductAttribute::create(['title' => 'Is Featured', 'product_attribute_group_id' => $productAttributeGroup->id, 'identifier' => 'is_featured', 'type' => 'VARCHAR', 'field_type' => 'SELECT', 'validation' => 'required']);
     AttributeDropdownOption::create(['product_attribute_id' => $featureAttribute->id, 'value' => '0', 'label' => 'No']);
     AttributeDropdownOption::create(['product_attribute_id' => $featureAttribute->id, 'value' => '1', 'label' => 'Yes']);
     $inStockAttribute = ProductAttribute::create(['title' => 'In Stock', 'product_attribute_group_id' => $inventoryGroup->id, 'identifier' => 'in_stock', 'type' => 'VARCHAR', 'field_type' => 'SELECT', 'validation' => 'required']);
     AttributeDropdownOption::create(['product_attribute_id' => $inStockAttribute->id, 'value' => '1', 'label' => 'Yes']);
     AttributeDropdownOption::create(['product_attribute_id' => $inStockAttribute->id, 'value' => '0', 'label' => 'No']);
     $trackStockAttribute = ProductAttribute::create(['title' => 'Track Stock', 'product_attribute_group_id' => $inventoryGroup->id, 'identifier' => 'track_stock', 'type' => 'VARCHAR', 'field_type' => 'SELECT', 'validation' => '']);
     AttributeDropdownOption::create(['product_attribute_id' => $trackStockAttribute->id, 'value' => '1', 'label' => 'Yes']);
     AttributeDropdownOption::create(['product_attribute_id' => $trackStockAttribute->id, 'value' => '0', 'label' => 'No']);
     OrderStatus::insert(['title' => 'pending', 'is_default' => 1, 'is_last_stage' => 0], ['title' => 'processing', 'is_default' => 0, 'is_last_stage' => 0], ['title' => 'complete', 'is_default' => 0, 'is_last_stage' => 1]);
     $path = public_path() . '/countries.json';
     $json = json_decode(file_get_contents($path), true);
     foreach ($json as $code => $name) {
         $countires[] = ['code' => $code, 'name' => $name];
     }
     Country::insert($countires);
 }
 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;
 }
Ejemplo n.º 5
0
 /**
  * Get the validation rules that apply to the request.
  *
  * @return array
  */
 public function rules()
 {
     //@todo validation is not working yet??
     if (count($this->request->get('website_id')) <= 0) {
         $validateArray['website_id[]'] = 'required';
     }
     $productAttributes = ProductAttribute::all();
     foreach ($productAttributes as $productAttribute) {
         if ($productAttribute->validation != '') {
             $validateArray[$productAttribute->identifier] = $productAttribute->validation;
         }
     }
     return $validateArray;
     //return [
     //      'title' => 'required|max:255',
     //      'identifier' => 'required|max:255|unique:product_attributes,id,' . $this->get('id'),
     //      'type' => 'required',
     //      'user.email' => 'required|email|unique:users,email,' . $user->id,
     //];
 }
Ejemplo n.º 6
0
 public function searchProduct(Request $request)
 {
     $query = $request->get('q');
     $titleAttribute = ProductAttribute::where('identifier', '=', 'title')->get()->first();
     $titleCollection = $titleAttribute->productVarcharValues()->where('value', 'like', '%' . $query . '%')->where('website_id', '=', $this->websiteId)->get();
     foreach ($titleCollection as $row) {
         $results[] = ['id' => $row->product_id, 'text' => $row->value];
     }
     return response()->json(['results' => $results]);
 }
Ejemplo n.º 7
0
 public function saveProductImages($product, ProductRequest $request)
 {
     $productAttribute = ProductAttribute::where('identifier', '=', 'image')->get()->first();
     $productAttribute->productVarcharValues()->where('product_id', '=', $product->id)->delete();
     if (count($request->get('image')) <= 0) {
         return true;
     }
     foreach ($request->get('image') as $image) {
         if (is_int($image)) {
             continue;
         }
         $productAttribute->productVarcharValues()->create(['product_id' => $product->id, 'website_id' => $this->websiteId, 'value' => $image]);
     }
 }
Ejemplo n.º 8
0
 public function getFeaturedProducts($paginate = 4)
 {
     $attribute = ProductAttribute::where('identifier', '=', 'is_featured')->get()->first();
     $products = Collection::make([]);
     $varcharValues = $attribute->productVarcharValues()->where('value', '=', 1)->get();
     foreach ($varcharValues as $varcharValue) {
         $products->push(self::findorfail($varcharValue->product_id));
     }
     return $products;
 }