Skip to content

Commit

Permalink
Merge branch 'next-38760/auto-imported-from-github' into 'trunk'
Browse files Browse the repository at this point in the history
NEXT-13637 - Add cross selling tab to variants

See merge request shopware/6/product/platform!14959
  • Loading branch information
tuanngo1993 committed Oct 23, 2024
2 parents 0cf4472 + 2817db8 commit a760722
Show file tree
Hide file tree
Showing 9 changed files with 389 additions and 51 deletions.
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
---
title: Add cross selling tab to variants
issue: NEXT-13637
author: Elias Lackner
author_email: [email protected]
author_github: @lacknere
---
# Administration
* Changed `sw-product-detail.html.twig` to show cross selling tab for variants.
* Added `isInherited` and its corresponding watcher and methods to `sw-product-detail-cross-selling` component to add inheritance functionality.
* Deprecated block `sw_product_detail_empty_state` in `sw-product-detail-cross-selling.html.twig`. Use `sw_product_detail_cross_selling_empty_state_card` instead.
* Deprecated block `sw_product_detail_empty_state_cross_selling_add` in `sw-product-detail-cross-selling.html.twig`. Use `sw_product_detail_cross_selling_empty_state_actions` instead.
* Added missing blocks to `sw-product-detail-cross-selling.html.twig`:
- `sw_product_detail_cross_selling_empty_state`
- `sw_product_detail_cross_selling_empty_state_icon`
- `sw_product_detail_cross_selling_empty_state_actions_add`
* Added new blocks to `sw-product-detail-cross-selling.html.twig`:
- `sw_product_detail_cross_selling_restore_inheritance`
- `sw_product_detail_cross_selling_empty_state_content`
- `sw_product_detail_cross_selling_empty_state_content_child`
- `sw_product_detail_cross_selling_empty_state_content_child_inherited`
- `sw_product_detail_cross_selling_empty_state_content_child_inherited_link`
- `sw_product_detail_cross_selling_empty_state_content_child_not_inherited`
- `sw_product_detail_cross_selling_empty_state_content_empty`
- `sw_product_detail_cross_selling_empty_state_inherit_switch`
- `sw_product_detail_cross_selling_modal_restore_inheritance`
- `sw_product_detail_cross_selling_modal_restore_inheritance_text`
- `sw_product_detail_cross_selling_modal_restore_inheritance_footer`
- `sw_product_detail_cross_selling_modal_restore_inheritance_action_cancel`
- `sw_product_detail_cross_selling_modal_restore_inheritance_action_restore`
* Added new and removed unused styles in `sw-product-detail-cross-selling.scss`.
Original file line number Diff line number Diff line change
Expand Up @@ -234,7 +234,7 @@
<!-- eslint-disable-next-line sw-deprecation-rules/no-twigjs-blocks -->
{% block sw_product_detail_content_tabs_cross_selling %}
<sw-tabs-item
v-show="!isChild && showModeSetting"
v-show="showModeSetting"
class="sw-product-detail__tab-cross-selling"
:route="{ name: 'sw.product.detail.crossSelling', params: { id: $route.params.id } }"
:has-error="swProductDetailCrossSellingError"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -253,13 +253,13 @@ describe('module/sw-product/page/sw-product-detail', () => {

const visibleTabItem = [
'.sw-product-detail__tab-seo',
'.sw-product-detail__tab-cross-selling',
'.sw-product-detail__tab-reviews',
];

const invisibleTabItem = [
'.sw-product-detail__tab-variants',
'.sw-product-detail__tab-layout',
'.sw-product-detail__tab-cross-selling',
];

visibleTabItem.forEach((item) => {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -479,8 +479,17 @@
"deleteButtonDelete": "Löschen",
"linkOpenStreamPreview": "Vorschau öffnen",
"emptyStateDescription": "Für dieses Produkt existiert noch keine Cross-Selling-Konfiguration.",
"inheritedEmptyStateDescription": "Dieses Produkt hat vererbte Cross Sellings vom Hauptprodukt.",
"notInheritedEmptyStateDescription": "Du kannst jetzt benutzerdefinierte Cross-Selling-Konfigurationen für diese Variante verwenden.",
"assignEmptyStateDescription": "Das Cross Selling muss zunächst gespeichert werden, bevor Du Produkte hinzufügen kannst.",
"assignPlaceholder": "Durchsuche Produkte ..."
"assignPlaceholder": "Durchsuche Produkte ...",
"linkCrossSellingsOfParent": "Zeige die Cross Sellings des Hauptprodukts",
"inheritSwitchLabel": "Nutze die Cross Sellings des Hauptprodukts",
"buttonRestoreCrossSellingInheritance": "Vererbung wiederherstellen",
"restoreInheritanceConfirmTitle": "Cross Selling Vererbung wiederherstellen",
"restoreInheritanceConfirmText": "Möchtest Du die Cross-Selling-Vererbung wirklich wiederherstellen? Alle Cross-Selling-Konfigurationen dieser Variante werden dabei gelöscht.",
"restoreInheritanceButtonCancel": "Zurück",
"restoreInheritanceButtonRestore": "Vererbung wiederherstellen"
},
"featureSets": {
"cardTitle": "Wesentliche Merkmale",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -479,8 +479,17 @@
"deleteButtonDelete": "Delete",
"linkOpenStreamPreview": "Open preview",
"emptyStateDescription": "There is no Cross Selling configured for this product, yet.",
"inheritedEmptyStateDescription": "This product has inherited cross sellings from its parent.",
"notInheritedEmptyStateDescription": "You can now use custom Cross Selling configurations for this variant.",
"assignEmptyStateDescription": "Save the Cross Selling in order to add products to it.",
"assignPlaceholder": "Search products..."
"assignPlaceholder": "Search products...",
"linkCrossSellingsOfParent": "Show cross sellings of parent product",
"inheritSwitchLabel": "Use cross sellings from parent product",
"buttonRestoreCrossSellingInheritance": "Restore inheritance",
"restoreInheritanceConfirmTitle": "Restore Cross Selling inheritance",
"restoreInheritanceConfirmText": "Are you sure you want to restore the Cross Selling inheritance? All Cross Selling configurations of this variant will be deleted.",
"restoreInheritanceButtonCancel": "Cancel",
"restoreInheritanceButtonRestore": "Restore inheritance"
},
"featureSets": {
"cardTitle": "Essential Characteristics",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
import template from './sw-product-detail-cross-selling.html.twig';
import './sw-product-detail-cross-selling.scss';

const { Criteria } = Shopware.Data;
const { Criteria, EntityCollection } = Shopware.Data;
const { mapState, mapGetters } = Shopware.Component.getComponentHelper();

// eslint-disable-next-line sw-deprecation-rules/private-feature-declarations
Expand All @@ -31,6 +31,8 @@ export default {
data() {
return {
crossSelling: null,
isInherited: false,
showRestoreInheritanceModal: false,
};
},

Expand All @@ -41,6 +43,7 @@ export default {

...mapGetters('swProductDetail', [
'isLoading',
'isChild',
]),

...mapGetters('context', [
Expand All @@ -62,6 +65,10 @@ export default {
assetFilter() {
return Shopware.Filter.getByName('asset');
},

crossSellingRepository() {
return this.repositoryFactory.create(this.product.crossSellings.entity, this.product.crossSellings.source);
},
},

watch: {
Expand All @@ -74,9 +81,28 @@ export default {
this.loadAssignedProducts(item);
});
},

'product.crossSellings': {
handler(value) {
if (!value) {
return;
}

this.isInherited = this.isChild && !this.product.crossSellings.total;
},
immediate: true,
},
},

mounted() {
this.mountedComponent();
},

methods: {
mountedComponent() {
this.isInherited = this.isChild && !this.product.crossSellings.total;
},

loadAssignedProducts(crossSelling) {
const repository = this.repositoryFactory.create(
crossSelling.assignedProducts.entity,
Expand All @@ -102,11 +128,7 @@ export default {
},

onAddCrossSelling() {
const crossSellingRepository = this.repositoryFactory.create(
this.product.crossSellings.entity,
this.product.crossSellings.source,
);
this.crossSelling = crossSellingRepository.create();
this.crossSelling = this.crossSellingRepository.create();
this.crossSelling.productId = this.product.id;
this.crossSelling.position = this.product.crossSellings.length + 1;
this.crossSelling.type = 'productStream';
Expand All @@ -116,5 +138,35 @@ export default {

this.product.crossSellings.push(this.crossSelling);
},

restoreInheritance() {
this.isInherited = true;
},

removeInheritance() {
this.isInherited = false;
},

onShowRestoreInheritanceModal() {
this.showRestoreInheritanceModal = true;
},

onCloseRestoreInheritanceModal() {
this.showRestoreInheritanceModal = false;
},

onConfirmRestoreInheritance() {
this.onCloseRestoreInheritanceModal();

this.$nextTick(() => {
this.product.crossSellings = new EntityCollection(
this.crossSellingRepository.route,
this.product.crossSellings.entity,
Shopware.Context.api,
);

this.restoreInheritance();
});
},
},
};
Loading

0 comments on commit a760722

Please sign in to comment.