Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Make StoreValues Extension Inheritable #896

Merged
merged 1 commit into from
Mar 22, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 5 additions & 2 deletions src/CoreShop/Bundle/CoreBundle/CoreExtension/StoreValues.php
Original file line number Diff line number Diff line change
Expand Up @@ -169,7 +169,10 @@ public function getGetterCode($class)
$code .= "\t" . 'if (is_null($store)) {' . "\n";
$code .= "\t\t" . 'return $this->' . $key . ";\n";
$code .= "\t" . '}' . "\n";
$code .= "\t" . '$data = $this->' . $key . ";\n";
$code .= "\t" . '$data = $this->' . $key . ";\n\n";
$code .= "\t" . 'if (\Pimcore\Model\DataObject::doGetInheritedValues() && $this->getClass()->getFieldDefinition("' . $key . '")->isEmpty($data)) {' . "\n";
$code .= "\t\t" . 'return $this->getValueFromParent("' . $key . '", $store);' . "\n";
$code .= "\t" . '}' . "\n\n";
$code .= "\t" . 'if (is_array($data)) {' . "\n";
$code .= "\t\t" . '/** @var \CoreShop\Component\Core\Model\ProductStoreValuesInterface $storeValuesBlock */' . "\n";
$code .= "\t\t" . 'foreach ($data as $storeValuesBlock) {' . "\n";
Expand Down Expand Up @@ -577,7 +580,7 @@ public function isDiffChangeAllowed($object, $params = [])
*/
public function isEmpty($data)
{
return is_null($data);
return is_null($data) || (is_array($data) && count($data) === 0);
}

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -93,6 +93,11 @@ pimcore.object.tags.coreShopStoreValues = Class.create(pimcore.object.tags.abstr
ignoreErrors: true,
success: function (response) {

// maybe object is already gone due manual reload
if(this.component.destroyed === true) {
return;
}

this.dirty = false;

var refreshedObject = null,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,8 +24,12 @@ coreshop.product.storeValues.items.price = Class.create(coreshop.product.storeVa
value: 0
});

// do not fire dirty flag on initial data setup
priceField.suspendEvents();

if (price !== null) {
priceField.setValue(price / 100);
priceField.resetOriginalValue();
priceField.setFieldLabel(priceField.fieldLabel + ' (' + this.builder.data.currencySymbol + ')');
}

Expand All @@ -43,6 +47,8 @@ coreshop.product.storeValues.items.price = Class.create(coreshop.product.storeVa
priceField.setMaxValue(this.builder.fieldConfig.maxValue);
}

priceField.resumeEvents(true);

return priceField;
}
});