Merge branch 'master' of https://github.com/bagisto/bagisto into development
This commit is contained in:
commit
01d2d7cfcb
|
|
@ -19,7 +19,9 @@ class OrderDataGrid extends DataGrid
|
|||
|
||||
public function prepareQueryBuilder()
|
||||
{
|
||||
$queryBuilder = DB::table('orders')->select('id', 'base_sub_total', 'base_grand_total', 'created_at', 'channel_name', 'status')->addSelect(DB::raw('CONCAT(customer_first_name, " ", customer_last_name) as full_name'));
|
||||
$queryBuilder = DB::table('orders')
|
||||
->select('id', 'base_sub_total', 'base_grand_total', 'created_at', 'channel_name', 'status')
|
||||
->addSelect(DB::raw('CONCAT(customer_first_name, " ", customer_last_name) as full_name'));
|
||||
|
||||
$this->addFilter('full_name', DB::raw('CONCAT(customer_first_name, " ", customer_last_name)'));
|
||||
|
||||
|
|
|
|||
|
|
@ -761,6 +761,7 @@ return [
|
|||
'user-define-error' => 'Can not delete system :name',
|
||||
'attribute-error' => ':name is used in configurable products.',
|
||||
'attribute-product-error' => ':name is used in products.',
|
||||
'customer-associate' => ':name can not be deleted because customer is associated with this group.'
|
||||
'customer-associate' => ':name can not be deleted because customer is associated with this group.',
|
||||
'currency-delete-error' => 'This currency is set as channel base currency so it can not be deleted.'
|
||||
],
|
||||
];
|
||||
|
|
@ -145,6 +145,8 @@ class CurrencyController extends Controller
|
|||
session()->flash('error', trans('admin::app.response.last-delete-error', ['name' => 'Currency']));
|
||||
} catch (\Exception $e) {
|
||||
session()->flash('error', $e->getMessage());
|
||||
|
||||
session()->flash('error', trans('admin::app.response.currency-delete-error', ['name' => 'Currency']));
|
||||
}
|
||||
|
||||
return redirect()->back();
|
||||
|
|
|
|||
|
|
@ -4,6 +4,7 @@ namespace Webkul\Product\Listeners;
|
|||
|
||||
use Illuminate\Support\Facades\Schema;
|
||||
use Illuminate\Database\Schema\Blueprint;
|
||||
use Webkul\Attribute\Repositories\AttributeRepository;
|
||||
use Webkul\Attribute\Repositories\AttributeOptionRepository;
|
||||
use Webkul\Product\Repositories\ProductFlatRepository;
|
||||
use Webkul\Product\Repositories\ProductAttributeValueRepository;
|
||||
|
|
@ -18,6 +19,13 @@ use Webkul\Product\Models\ProductAttributeValue;
|
|||
*/
|
||||
class ProductFlat
|
||||
{
|
||||
/**
|
||||
* AttributeRepository Repository Object
|
||||
*
|
||||
* @var object
|
||||
*/
|
||||
protected $attributeRepository;
|
||||
|
||||
/**
|
||||
* AttributeOptionRepository Repository Object
|
||||
*
|
||||
|
|
@ -63,17 +71,21 @@ class ProductFlat
|
|||
/**
|
||||
* Create a new listener instance.
|
||||
*
|
||||
* @param Webkul\Attribute\Repositories\AttributeRepository $attributeRepository
|
||||
* @param Webkul\Attribute\Repositories\AttributeOptionRepository $attributeOptionRepository
|
||||
* @param Webkul\Product\Repositories\ProductFlatRepository $productFlatRepository
|
||||
* @param Webkul\Product\Repositories\ProductAttributeValueRepository $productAttributeValueRepository
|
||||
* @return void
|
||||
*/
|
||||
public function __construct(
|
||||
AttributeRepository $attributeRepository,
|
||||
AttributeOptionRepository $attributeOptionRepository,
|
||||
ProductFlatRepository $productFlatRepository,
|
||||
ProductAttributeValueRepository $productAttributeValueRepository
|
||||
)
|
||||
{
|
||||
$this->attributeRepository = $attributeRepository;
|
||||
|
||||
$this->attributeOptionRepository = $attributeOptionRepository;
|
||||
|
||||
$this->productAttributeValueRepository = $productAttributeValueRepository;
|
||||
|
|
@ -105,8 +117,10 @@ class ProductFlat
|
|||
}
|
||||
}
|
||||
|
||||
public function afterAttributeDeleted($attribute)
|
||||
public function afterAttributeDeleted($attributeId)
|
||||
{
|
||||
$attribute = $this->attributeRepository->find($attributeId);
|
||||
|
||||
if (Schema::hasTable('product_flat')) {
|
||||
if (Schema::hasColumn('product_flat', strtolower($attribute->code))) {
|
||||
Schema::table('product_flat', function (Blueprint $table) use($attribute) {
|
||||
|
|
|
|||
|
|
@ -156,10 +156,6 @@ class ProductRepository extends Repository
|
|||
|
||||
$product->update($data);
|
||||
|
||||
if (isset($data['categories'])) {
|
||||
$product->categories()->sync($data['categories']);
|
||||
}
|
||||
|
||||
$attributes = $product->attribute_family->custom_attributes;
|
||||
|
||||
foreach ($attributes as $attribute) {
|
||||
|
|
@ -189,38 +185,44 @@ class ProductRepository extends Repository
|
|||
}
|
||||
}
|
||||
|
||||
$previousVariantIds = $product->variants->pluck('id');
|
||||
if (request()->route()->getName() != 'admin.catalog.products.massupdate') {
|
||||
if (isset($data['categories'])) {
|
||||
$product->categories()->sync($data['categories']);
|
||||
}
|
||||
|
||||
$previousVariantIds = $product->variants->pluck('id');
|
||||
|
||||
if (isset($data['variants'])) {
|
||||
foreach ($data['variants'] as $variantId => $variantData) {
|
||||
if (str_contains($variantId, 'variant_')) {
|
||||
$permutation = [];
|
||||
foreach ($product->super_attributes as $superAttribute) {
|
||||
$permutation[$superAttribute->id] = $variantData[$superAttribute->code];
|
||||
if (isset($data['variants'])) {
|
||||
foreach ($data['variants'] as $variantId => $variantData) {
|
||||
if (str_contains($variantId, 'variant_')) {
|
||||
$permutation = [];
|
||||
foreach ($product->super_attributes as $superAttribute) {
|
||||
$permutation[$superAttribute->id] = $variantData[$superAttribute->code];
|
||||
}
|
||||
|
||||
$this->createVariant($product, $permutation, $variantData);
|
||||
} else {
|
||||
if (is_numeric($index = $previousVariantIds->search($variantId))) {
|
||||
$previousVariantIds->forget($index);
|
||||
}
|
||||
|
||||
$variantData['channel'] = $data['channel'];
|
||||
$variantData['locale'] = $data['locale'];
|
||||
|
||||
$this->updateVariant($variantData, $variantId);
|
||||
}
|
||||
|
||||
$this->createVariant($product, $permutation, $variantData);
|
||||
} else {
|
||||
if (is_numeric($index = $previousVariantIds->search($variantId))) {
|
||||
$previousVariantIds->forget($index);
|
||||
}
|
||||
|
||||
$variantData['channel'] = $data['channel'];
|
||||
$variantData['locale'] = $data['locale'];
|
||||
|
||||
$this->updateVariant($variantData, $variantId);
|
||||
}
|
||||
}
|
||||
|
||||
foreach ($previousVariantIds as $variantId) {
|
||||
$this->delete($variantId);
|
||||
}
|
||||
|
||||
$this->productInventory->saveInventories($data, $product);
|
||||
|
||||
$this->productImage->uploadImages($data, $product);
|
||||
}
|
||||
|
||||
foreach ($previousVariantIds as $variantId) {
|
||||
$this->delete($variantId);
|
||||
}
|
||||
|
||||
$this->productInventory->saveInventories($data, $product);
|
||||
|
||||
$this->productImage->uploadImages($data, $product);
|
||||
|
||||
Event::fire('catalog.product.update.after', $product);
|
||||
|
||||
return $product;
|
||||
|
|
@ -385,6 +387,9 @@ class ProductRepository extends Repository
|
|||
$matchCount = 0;
|
||||
|
||||
foreach ($superAttributeCodes as $attributeCode) {
|
||||
if (! isset($data[$attributeCode]))
|
||||
return false;
|
||||
|
||||
if ($data[$attributeCode] == $variant->{$attributeCode})
|
||||
$matchCount++;
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in New Issue