Localized Fields in Object Bricks

Hello,

I’m trying to figure out how to access localizedfields in object bricks, please see below the object brick structure (error_log):

Pimcore\Model\DataObject\Objectbrick\Data\BrcSales Object
(
    [type] => brcSales
    [localizedfields] => Pimcore\Model\DataObject\Localizedfield Object
        (
            [items] => Array
                (
                    [de] => Array
                        (
                            [Area] => Deutschland
                        )

                    [en] => Array
                        (
                            [Area] => Germany
                        )
                )
            [object] => ...

In the past localizedfields in objectbricks weren’t possible, but since 5.3. it should be, please give me a hint how to access the locallized fields.

Thanks in advance.

Hi,
same as all other fields in object bricks … just call getter of fieldname, e.g. $object->getBricksField()->getBrcSales()->getItems() … optionally use language as getter parameter.

BR
Christian

Ok. That’s what I thought too, but I get
Call to undefined method getArea in class Pimcore\Model\DataObject\Objectbrick\Data\BrcSales

I’m on 5.7.3.

Found the issue, the getter functions aren’t created in the BrcSales.php, like (simplified)

public function getArea3 ($language = null) {
	$data = $this->getLocalizedfields()->getLocalizedValue("Area3", $language);

	 return $data;
}

It seems to me that for object bricks the piece of code won’t be generated?

PR: https://github.com/pimcore/pimcore/pull/4463