Skip to content

Commit

Permalink
Fix ID compatibility with DC_Multilingual 4
Browse files Browse the repository at this point in the history
  • Loading branch information
aschempp committed Feb 10, 2021
1 parent d8fe238 commit feff2d9
Show file tree
Hide file tree
Showing 3 changed files with 17 additions and 4 deletions.
2 changes: 1 addition & 1 deletion system/modules/isotope/library/Isotope/Frontend.php
Original file line number Diff line number Diff line change
Expand Up @@ -719,7 +719,7 @@ public function addOptionsPrice($fltPrice, $objSource, $strField, $intTaxClass,

/** @var AttributeOption $objOption */
foreach ($objOptions as $objOption) {
if (\in_array($objOption->id, $value)) {
if (\in_array($objOption->getLanguageId(), $value)) {
$amount = $objOption->getAmount($fltPrice, 0);
$objTax = $objSource->getRelated('tax_class');

Expand Down
4 changes: 2 additions & 2 deletions system/modules/isotope/library/Isotope/Model/Attribute.php
Original file line number Diff line number Diff line change
Expand Up @@ -259,7 +259,7 @@ public function saveToDCA(array &$arrData)
$arrOptions = [];
foreach (AttributeOption::findByAttribute($this, ['order' => AttributeOption::getTable().'.label']) as $model) {
$arrOptions[] = [
'value' => $model->id,
'value' => $model->getLanguageId(),
'label' => $model->label,
];
}
Expand All @@ -269,7 +269,7 @@ public function saveToDCA(array &$arrData)
$arrOptions = [];
foreach (AttributeOption::findByProducts($this, ['order' => AttributeOption::getTable().'.label']) as $model) {
$arrOptions[] = [
'value' => $model->id,
'value' => $model->getLanguageId(),
'label' => $model->label,
];
}
Expand Down
15 changes: 14 additions & 1 deletion system/modules/isotope/library/Isotope/Model/AttributeOption.php
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,19 @@ class AttributeOption extends \MultilingualModel
*/
protected static $strTable = 'tl_iso_attribute_option';

/**
* Backwards compatibility with DC_Multi
* @return int
*/
public function getLanguageId()
{
if ($this instanceof Terminal42\DcMultilingualBundle\Model\MultilingualTrait) {
return parent::getLanguageId();
}

return $this->id;
}

/**
* Get array representation of the attribute option
*
Expand All @@ -57,7 +70,7 @@ class AttributeOption extends \MultilingualModel
public function getAsArray(IsotopeProduct $objProduct = null, $blnPriceInLabel = true)
{
return array(
'value' => \method_exists($this, 'getLanguageId') ? $this->getLanguageId() : $this->id,
'value' => $this->getLanguageId(),
'label' => $blnPriceInLabel ? $this->getLabel($objProduct) : $this->label,
'group' => 'group' === $this->type ? '1' : '',
'default' => $this->isDefault ? '1' : '',
Expand Down

0 comments on commit feff2d9

Please sign in to comment.