From d05b6451cc294058abe4faa58d5f188722d81045 Mon Sep 17 00:00:00 2001 From: prashant-webkul Date: Fri, 26 Oct 2018 09:54:26 +0530 Subject: [PATCH 1/6] Product grid bug fixes --- packages/Webkul/Admin/src/Listeners/Product.php | 1 - 1 file changed, 1 deletion(-) diff --git a/packages/Webkul/Admin/src/Listeners/Product.php b/packages/Webkul/Admin/src/Listeners/Product.php index 97a7d0776..005542480 100644 --- a/packages/Webkul/Admin/src/Listeners/Product.php +++ b/packages/Webkul/Admin/src/Listeners/Product.php @@ -142,7 +142,6 @@ class Product { } else { $productGridObject->update($data['parent']); if(count($data['variants'])) { - dd($data['variants']); foreach($data['variants'] as $variant) { $variantObject = $this->productGrid->findOneByField('product_id', $variant['product_id']); if(!is_null($variantObject)) { From f69e396bfdde866679d31c0c1544a07b70cbcc10 Mon Sep 17 00:00:00 2001 From: prashant-webkul Date: Fri, 26 Oct 2018 11:14:42 +0530 Subject: [PATCH 2/6] Product grid update event bind successful --- .../Admin/src/DataGrids/ProductDataGrid.php | 8 +-- .../Webkul/Admin/src/Listeners/Product.php | 58 +++++-------------- .../Http/Controllers/ProductController.php | 2 +- 3 files changed, 20 insertions(+), 48 deletions(-) diff --git a/packages/Webkul/Admin/src/DataGrids/ProductDataGrid.php b/packages/Webkul/Admin/src/DataGrids/ProductDataGrid.php index 4c2fdc94d..a9c5fa443 100644 --- a/packages/Webkul/Admin/src/DataGrids/ProductDataGrid.php +++ b/packages/Webkul/Admin/src/DataGrids/ProductDataGrid.php @@ -70,19 +70,19 @@ class ProductDataGrid 'name' => 'prods.name', 'alias' => 'ProductName', 'type' => 'string', - 'label' => 'Product Name', + 'label' => 'Name', 'sortable' => false, ], [ 'name' => 'prods.type', 'alias' => 'ProductType', 'type' => 'string', - 'label' => 'Product Type', + 'label' => 'Type', 'sortable' => false, ], [ 'name' => 'prods.status', 'alias' => 'ProductStatus', 'type' => 'string', - 'label' => 'Product Status', + 'label' => 'Status', 'sortable' => false, 'wrapper' => function ($value) { if($value == 1) @@ -94,7 +94,7 @@ class ProductDataGrid 'name' => 'prods.price', 'alias' => 'ProductPrice', 'type' => 'string', - 'label' => 'Product Price', + 'label' => 'Price', 'sortable' => false, 'wrapper' => function ($value) { return core()->formatBasePrice($value); diff --git a/packages/Webkul/Admin/src/Listeners/Product.php b/packages/Webkul/Admin/src/Listeners/Product.php index 005542480..78a82a86e 100644 --- a/packages/Webkul/Admin/src/Listeners/Product.php +++ b/packages/Webkul/Admin/src/Listeners/Product.php @@ -50,6 +50,8 @@ class Product { */ public function prepareData($product) { $gridObject = []; + $variantObjects = []; + $gridObject = [ 'product_id' => $product->id, 'sku' => $product->sku, @@ -57,15 +59,13 @@ class Product { 'attribute_family_name' => $product->attribute_family->name, ]; - $variantObjects = []; - if($this->productGrid->findOneByField('product_id', $product->id)) { $gridObject['name'] = $product->name; $gridObject['status'] = $product->status; if($product->type == 'configurable') { $gridObject['quantity'] = 0; - $gridObject['price'] = $this->price->getMinimalPrice($product); + $gridObject['price'] = 0; $variants = $product->variants; @@ -80,13 +80,13 @@ class Product { 'status' => $variant->status, ]; - $qty = 1; - - foreach($variant->toArray()['inventories'] as $inventorySource) { - $qty = $qty + $inventorySource['qty']; + $qty = 0; + //inventories and inventory sources relation for the variants return empty or null collection objects only + foreach($variant->inventories()->get() as $inventory_source) { + $qty = $qty + $inventory_source->qty; } - $variantObject['price'] = $product->price; + $variantObject['price'] = $variant->price; $variantObject['quantity'] = $qty; array_push($variantObjects, $variantObject); @@ -97,8 +97,8 @@ class Product { } else { $qty = 0; - foreach($product->toArray()['inventories'] as $inventorySource) { - $qty = $qty + $inventorySource['qty']; + foreach($product->inventories->get() as $inventory_source) { + $qty = $qty + $inventory_source->qty; } $gridObject['price'] = $product->price; @@ -107,7 +107,6 @@ class Product { $qty = 0; } } - // dd($gridObject, $variantObjects); return [ 'parent' => $gridObject, 'variants' => $variantObjects @@ -136,14 +135,16 @@ class Product { $productGridObject = $this->productGrid->findOneByField('product_id', $product->id); // dd($product, $data, $productGridObject); - if (!is_null($productGridObject)) { + if(!is_null($productGridObject)) { if($product->type == 'simple') { $r = $productGridObject->update($data['parent']); } else { $productGridObject->update($data['parent']); + if(count($data['variants'])) { foreach($data['variants'] as $variant) { $variantObject = $this->productGrid->findOneByField('product_id', $variant['product_id']); + if(!is_null($variantObject)) { $variantObject->update($variant); } else { @@ -155,7 +156,7 @@ class Product { } else { $this->productGrid->create($data['parent']); - //no need for tese lines + //no need for these lines if(count($data['variants'])) { foreach($data['variants'] as $variant) { $this->productGrid->create($variant); @@ -175,37 +176,8 @@ class Product { } /** - * Event after the product update - * - * @var collection product - * - * return boolean + * Manually invoke this function when you have created the products by importing or seeding or factory. */ - public function afterProductUpdate($product) { - //update product grid here - $this->productGrid->updateWhere($product); - - return true; - } - - /** - * Event after deletion of the product - * - * @return boolean - */ - public function afterProductDelete($productId) { - return true; - } - - /** - * Fill attributes for that product after the creation - * - * @return boolean - */ - public function fillAttribute() { - - } - public function sync() { $gridObject = []; diff --git a/packages/Webkul/Product/src/Http/Controllers/ProductController.php b/packages/Webkul/Product/src/Http/Controllers/ProductController.php index 4a85a2143..401a94db8 100644 --- a/packages/Webkul/Product/src/Http/Controllers/ProductController.php +++ b/packages/Webkul/Product/src/Http/Controllers/ProductController.php @@ -203,7 +203,7 @@ class ProductController extends Controller $this->product->delete($id); //before update of product - Event::fire('product.delete.after', $id); + // Event::fire('product.delete.after', $id); session()->flash('success', 'Product deleted successfully.'); From 74605cbeff04bcf289b024dd10a9025beb5c98cc Mon Sep 17 00:00:00 2001 From: prashant-webkul Date: Fri, 26 Oct 2018 11:57:57 +0530 Subject: [PATCH 3/6] storefront header fixed --- .../Shop/src/Resources/assets/sass/app.scss | 17 +++++- .../Webkul/Shop/src/Resources/lang/en/app.php | 11 ++++ .../views/layouts/header/index.blade.php | 57 ++++++++----------- public/themes/default/assets/css/shop.css | 25 +++++++- public/themes/default/assets/js/shop.js | 15 ----- 5 files changed, 73 insertions(+), 52 deletions(-) diff --git a/packages/Webkul/Shop/src/Resources/assets/sass/app.scss b/packages/Webkul/Shop/src/Resources/assets/sass/app.scss index f73444e11..4acefdc9e 100644 --- a/packages/Webkul/Shop/src/Resources/assets/sass/app.scss +++ b/packages/Webkul/Shop/src/Resources/assets/sass/app.scss @@ -655,13 +655,18 @@ section.slider-block { flex-direction: row; justify-content: flex-end; align-items: center; - // cursor: pointer; .currency-switcher { float: right; border-right: 2px solid $border-color; cursor: pointer; + .dropdown-toggle { + line-height: 25px; + margin-left: 14px; + margin-right: 14px; + } + .dropdown-list { width: 100px; top: 37px; @@ -675,12 +680,20 @@ section.slider-block { ul.account-dropdown-container { float: right; border-right: 2px solid $border-color; + cursor: pointer; li.account-dropdown { display: flex; flex-direction: row; - margin-right: 14px; margin-left: 14px; + margin-right: 14px; + + .account { + display: flex; + flex-direction: row; + justify-content: space-between; + align-items: center; + } .dropdown-list { width: 300px; diff --git a/packages/Webkul/Shop/src/Resources/lang/en/app.php b/packages/Webkul/Shop/src/Resources/lang/en/app.php index dc4441e94..9ed2eac23 100644 --- a/packages/Webkul/Shop/src/Resources/lang/en/app.php +++ b/packages/Webkul/Shop/src/Resources/lang/en/app.php @@ -7,6 +7,17 @@ return [ 'new-products' => 'New Products' ], + 'header' => [ + 'title' => 'Account', + 'dropdown-text' => 'Manage Cart, Orders & Wishlist.', + 'sign-in' => 'Sign In', + 'sign-up' => 'Sign Up', + 'profile' => 'Profile', + 'wishlist' => 'Wishlist', + 'cart' => 'Cart', + 'logout' => 'Logout' + ], + 'footer' => [ 'subscribe-newsletter' => 'Subscribe Newsletter', 'subscribe' => 'Subscribe', diff --git a/packages/Webkul/Shop/src/Resources/views/layouts/header/index.blade.php b/packages/Webkul/Shop/src/Resources/views/layouts/header/index.blade.php index 49799a87a..fc91e0539 100644 --- a/packages/Webkul/Shop/src/Resources/views/layouts/header/index.blade.php +++ b/packages/Webkul/Shop/src/Resources/views/layouts/header/index.blade.php @@ -26,9 +26,9 @@
@if (core()->getCurrentChannel()->currencies->count() > 1) -
+
    @@ -43,27 +43,25 @@
- + @endif
    - - @inject ('productImageHelper', 'Webkul\Product\Helpers\ProductImage')
  • - @include('shop::checkout.cart.mini-cart')
@@ -109,22 +102,18 @@