From af88e8951add78d33b498c2a4e4ea8a6c3adb147 Mon Sep 17 00:00:00 2001 From: Prashant Singh Date: Tue, 16 Apr 2019 14:39:30 +0530 Subject: [PATCH 1/3] Unnecessary Tax models removed from core, were originally moved from core to Tax module --- config/concord.php | 2 +- .../Webkul/Core/src/Models/TaxCategory.php | 28 ------------------- .../Core/src/Models/TaxCategoryProxy.php | 10 ------- packages/Webkul/Core/src/Models/TaxMap.php | 24 ---------------- .../Webkul/Core/src/Models/TaxMapProxy.php | 10 ------- packages/Webkul/Core/src/Models/TaxRate.php | 26 ----------------- .../Webkul/Core/src/Models/TaxRateProxy.php | 10 ------- 7 files changed, 1 insertion(+), 109 deletions(-) delete mode 100755 packages/Webkul/Core/src/Models/TaxCategory.php delete mode 100644 packages/Webkul/Core/src/Models/TaxCategoryProxy.php delete mode 100755 packages/Webkul/Core/src/Models/TaxMap.php delete mode 100644 packages/Webkul/Core/src/Models/TaxMapProxy.php delete mode 100755 packages/Webkul/Core/src/Models/TaxRate.php delete mode 100644 packages/Webkul/Core/src/Models/TaxRateProxy.php diff --git a/config/concord.php b/config/concord.php index c1fa7e851..3585e74c6 100755 --- a/config/concord.php +++ b/config/concord.php @@ -19,4 +19,4 @@ return [ \Webkul\Tax\Providers\ModuleServiceProvider::class, \Webkul\User\Providers\ModuleServiceProvider::class ] -]; +]; \ No newline at end of file diff --git a/packages/Webkul/Core/src/Models/TaxCategory.php b/packages/Webkul/Core/src/Models/TaxCategory.php deleted file mode 100755 index 02cd5f543..000000000 --- a/packages/Webkul/Core/src/Models/TaxCategory.php +++ /dev/null @@ -1,28 +0,0 @@ -belongsToMany(TaxRateProxy::modelClass(), 'tax_categories_tax_rates', 'tax_category_id')->withPivot('id'); - } -} \ No newline at end of file diff --git a/packages/Webkul/Core/src/Models/TaxCategoryProxy.php b/packages/Webkul/Core/src/Models/TaxCategoryProxy.php deleted file mode 100644 index 01df18f7d..000000000 --- a/packages/Webkul/Core/src/Models/TaxCategoryProxy.php +++ /dev/null @@ -1,10 +0,0 @@ -belongsToMany(TaxCategoryProxy::modelClass(), 'tax_categories_tax_rates', 'tax_rate_id', 'id'); - } -} \ No newline at end of file diff --git a/packages/Webkul/Core/src/Models/TaxRateProxy.php b/packages/Webkul/Core/src/Models/TaxRateProxy.php deleted file mode 100644 index d7ff30546..000000000 --- a/packages/Webkul/Core/src/Models/TaxRateProxy.php +++ /dev/null @@ -1,10 +0,0 @@ - Date: Tue, 16 Apr 2019 14:41:12 +0530 Subject: [PATCH 2/3] Removed unforced controller file from attribute package's Repositories directory --- .../Attribute/src/Repositories/Controller.php | 13 ------------- packages/Webkul/Core/src/Contracts/TaxCategory.php | 7 ------- packages/Webkul/Core/src/Contracts/TaxMap.php | 7 ------- packages/Webkul/Core/src/Contracts/TaxRate.php | 7 ------- 4 files changed, 34 deletions(-) delete mode 100755 packages/Webkul/Attribute/src/Repositories/Controller.php delete mode 100644 packages/Webkul/Core/src/Contracts/TaxCategory.php delete mode 100644 packages/Webkul/Core/src/Contracts/TaxMap.php delete mode 100644 packages/Webkul/Core/src/Contracts/TaxRate.php diff --git a/packages/Webkul/Attribute/src/Repositories/Controller.php b/packages/Webkul/Attribute/src/Repositories/Controller.php deleted file mode 100755 index 59b522ad3..000000000 --- a/packages/Webkul/Attribute/src/Repositories/Controller.php +++ /dev/null @@ -1,13 +0,0 @@ - Date: Tue, 16 Apr 2019 14:47:28 +0530 Subject: [PATCH 3/3] Removed product grid events, product grid table is now obselete and maybe used in future for someother purposes. In result we will have a faster product creation and a new grid will be added with product flat table --- .../Webkul/Admin/src/Listeners/Product.php | 185 ------------------ .../src/Providers/EventServiceProvider.php | 4 - 2 files changed, 189 deletions(-) diff --git a/packages/Webkul/Admin/src/Listeners/Product.php b/packages/Webkul/Admin/src/Listeners/Product.php index 6fad7284f..70914e17d 100755 --- a/packages/Webkul/Admin/src/Listeners/Product.php +++ b/packages/Webkul/Admin/src/Listeners/Product.php @@ -49,185 +49,6 @@ class Product { $this->price = $price; } - /** - * Creates a new entry in the product grid whenever a new product is created. - * - * @return boolean - */ - public function afterProductCreated($product) { - $result = $this->productCreated($product); - - if ($result) { - return true; - } else { - return false; - } - } - - /** - * Save the product to the product as the product data grid instance - * - * @return boolean - */ - public function productCreated($product) { - $gridObject = [ - 'product_id' => $product->id, - 'sku' => $product->sku, - 'type' => $product->type, - 'attribute_family_name' => $product->toArray()['attribute_family']['name'], - 'name' => $product->name, - 'quantity' => 0, - 'status' => $product->status, - 'price' => $product->price - ]; - - $variants = []; - - $found = $this->productGrid->findOneByField('product_id', $product->id); - - //extra measure to stop duplicate entries - if ($found == null) { - $this->productGrid->create($gridObject); - - if ($product->type == 'configurable') { - $variants = $product->variants()->get(); - - foreach ($variants as $variant) { - $variantObj = [ - 'product_id' => $variant->id, - 'sku' => $variant->sku, - 'type' => $variant->type, - 'attribute_family_name' => $variant->toArray()['attribute_family']['name'], - 'name' => $variant->name, - 'quantity' => 0, - 'status' => $variant->status, - 'price' => $variant->price - ]; - - $this->productGrid->create($variantObj); - } - } - } - - return true; - } - - /** - * Event before the product update - * - * @return boolean - */ - // public function beforeProductUpdate($productId) { - // return true; - // } - - /** - * Event handle for after.product.update - * - * @return boolean - */ - public function afterProductUpdate($product) { - $result = $this->productUpdated($product); - - return $result; - } - - /** - * This will be invoked from afterProductUpdate - * - * @return boolean - */ - public function productUpdated($product) { - $productGridObject = $this->productGrid->findOneByField('product_id', $product->id); - - if (! $productGridObject) { - return false; - } - - $gridObject = [ - 'product_id' => $product->id, - 'sku' => $product->sku, - 'type' => $product->type, - 'attribute_family_name' => $product->toArray()['attribute_family']['name'], - 'name' => $product->name, - 'status' => $product->status, - ]; - - if ($product->type == 'configurable') { - $gridObject['quantity'] = 0; - $gridObject['price'] = 0; - } else { - $qty = 0; - //inventories and inventory sources relation for the variants return empty or null collection objects only - foreach ($product->inventories()->get() as $inventory_source) { - $qty = $qty + $inventory_source->qty; - } - - $gridObject['quantity'] = $qty; - $gridObject['price'] = $product->price; - } - - $this->productGrid->update($gridObject, $productGridObject->id); - - if ($product->type == 'configurable') { - $variants = $product->variants()->get(); - - foreach ($variants as $variant) { - $variantObj = [ - 'product_id' => $variant->id, - 'sku' => $variant->sku, - 'type' => $variant->type, - 'attribute_family_name' => $variant->toArray()['attribute_family']['name'], - 'name' => $variant->name, - 'status' => $variant->status, - 'price' => $variant->price, - ]; - - $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; - } - - $variantObj['quantity'] = $qty; - - $qty = 0; - - $productGridVariant = $this->productGrid->findOneByField('product_id', $variant->id); - - if (isset($productGridVariant)) { - $this->productGrid->update($variantObj, $productGridVariant->id); - } else { - $variantObj = [ - 'product_id' => $variant->id, - 'sku' => $variant->sku, - 'type' => $variant->type, - 'attribute_family_name' => $variant->toArray()['attribute_family']['name'], - 'name' => $variant->name, - 'status' => $variant->status, - 'price' => $variant->price, - ]; - - $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; - } - - $variantObj['quantity'] = $qty; - - $qty = 0; - - $this->productGrid->create($variantObj); - } - } - } - - return true; - } - /** * Manually invoke this function when you have created the products by importing or seeding or factory. */ @@ -274,10 +95,4 @@ class Product { return true; } - - public function findRepeated() { - //find if there is duplicacy in the products grid here - } - - public function syncFlat() {} } \ No newline at end of file diff --git a/packages/Webkul/Admin/src/Providers/EventServiceProvider.php b/packages/Webkul/Admin/src/Providers/EventServiceProvider.php index c4b202050..0651d4859 100755 --- a/packages/Webkul/Admin/src/Providers/EventServiceProvider.php +++ b/packages/Webkul/Admin/src/Providers/EventServiceProvider.php @@ -23,9 +23,5 @@ class EventServiceProvider extends ServiceProvider Event::listen('checkout.order.save.after', 'Webkul\Admin\Listeners\Order@updateProductInventory'); Event::listen('products.datagrid.sync', 'Webkul\Admin\Listeners\Product@sync'); - - Event::listen('catalog.product.create.after', 'Webkul\Admin\Listeners\Product@afterProductCreated'); - - Event::listen('catalog.product.update.after', 'Webkul\Admin\Listeners\Product@afterProductUpdate'); } } \ No newline at end of file