/** * Test related method */ public function testGetSetAttributeAsLabel() { $attribute = $this->getAttributeMock(); $this->assertNull($this->family->getAttributeAsLabel()); $this->assertEntity($this->family->setAttributeAsLabel($attribute)); $this->assertEquals($attribute, $this->family->getAttributeAsLabel()); }
function it_normalizes_family($normalizer, Family $family, AbstractAttribute $sku) { $sku->getCode()->willReturn('sku'); $family->getCode()->willReturn('mongo'); $family->getAttributeAsLabel()->willReturn($sku); $normalizer->normalize($family, 'mongodb_json', [])->willReturn(['label' => 'translations']); $this->normalize($family, 'mongodb_json', [])->shouldReturn(['code' => 'mongo', 'label' => 'translations', 'attributeAsLabel' => 'sku']); }
/** * Get product label * * @param string $locale * * @return mixed|string */ public function getLabel($locale = null) { if ($this->family) { if ($attributeAsLabel = $this->family->getAttributeAsLabel()) { if ($locale) { $this->setLocale($locale); } if ($value = $this->getValue($attributeAsLabel->getCode())) { $data = $value->getData(); if (!empty($data)) { return (string) $data; } } } } return (string) $this->getIdentifier()->getData(); }
/** * {@inheritDoc} */ public function getAttributeAsLabel() { $this->__initializer__ && $this->__initializer__->__invoke($this, 'getAttributeAsLabel', array()); return parent::getAttributeAsLabel(); }