From dc2960266e7e44e73cdb02cbb564777cd5460830 Mon Sep 17 00:00:00 2001 From: Dominik Pfaffenbauer Date: Thu, 30 Apr 2020 12:10:35 +0200 Subject: [PATCH] [CoreBundle] only show restore-inheritance when actually inheritable --- .../Bundle/CoreBundle/CoreExtension/StoreValues.php | 12 +++++++++++- .../js/coreExtension/tags/coreShopStoreValues.js | 2 +- 2 files changed, 12 insertions(+), 2 deletions(-) diff --git a/src/CoreShop/Bundle/CoreBundle/CoreExtension/StoreValues.php b/src/CoreShop/Bundle/CoreBundle/CoreExtension/StoreValues.php index dc9e759f50..3aa7bcdeab 100644 --- a/src/CoreShop/Bundle/CoreBundle/CoreExtension/StoreValues.php +++ b/src/CoreShop/Bundle/CoreBundle/CoreExtension/StoreValues.php @@ -512,6 +512,14 @@ public function getDataForEditmode($data, $object = null, $params = []) return $storeData; } + $class = Model\DataObject\ClassDefinition::getById($object->getClassId()); + + if (!$class instanceof Model\DataObject\ClassDefinition) { + return $storeData; + } + + $inheritable = $class->getAllowInherit() && $object->getParent() instanceof $object; + foreach ($data as $storeValuesEntity) { $context = SerializationContext::create(); $context->setSerializeNull(true); @@ -522,7 +530,8 @@ public function getDataForEditmode($data, $object = null, $params = []) 'name' => $storeValuesEntity->getStore()->getName(), 'currencySymbol' => $storeValuesEntity->getStore()->getCurrency()->getSymbol(), 'values' => $values, - 'inherited' => false + 'inherited' => false, + 'inheritable' => $inheritable ]; } @@ -539,6 +548,7 @@ public function getDataForEditmode($data, $object = null, $params = []) 'name' => $store->getName(), 'currencySymbol' => $store->getCurrency()->getSymbol(), 'values' => ['price' => 0], + 'inheritable' => $inheritable ]; } diff --git a/src/CoreShop/Bundle/CoreBundle/Resources/public/pimcore/js/coreExtension/tags/coreShopStoreValues.js b/src/CoreShop/Bundle/CoreBundle/Resources/public/pimcore/js/coreExtension/tags/coreShopStoreValues.js index 83f8f158a9..f7a6c15a18 100755 --- a/src/CoreShop/Bundle/CoreBundle/Resources/public/pimcore/js/coreExtension/tags/coreShopStoreValues.js +++ b/src/CoreShop/Bundle/CoreBundle/Resources/public/pimcore/js/coreExtension/tags/coreShopStoreValues.js @@ -208,7 +208,7 @@ pimcore.object.tags.coreShopStoreValues = Class.create(pimcore.object.tags.abstr data = this.data.hasOwnProperty(store.getId()) ? this.data[store.getId()] : null; valuesBuilder = new coreshop.product.storeValues.builder(this.fieldConfig, store, data, this.productUnitDefinitionsStore, this.object.id); - if (data && data.hasOwnProperty('inherited') && !data.inherited) { + if (data && data.hasOwnProperty('inherited') && !data.inherited && data.inheritable) { formPanel.add({ xtype: 'button', text: t('coreshop_restore_inheritance'),