public function testGetLabel() { $this->assertEmpty($this->_model->getLabel()); $this->_model->setProductAttribute(new \Magento\Framework\Object(['store_label' => 'Store Label'])); $this->assertEquals('Store Label', $this->_model->getLabel()); $this->_model->setUseDefault(1)->setProductAttribute(new \Magento\Framework\Object(['store_label' => 'Other Label'])); $this->assertEquals('Other Label', $this->_model->getLabel()); }
/** * Load label for configurable attribute * * @param ConfigurableAttribute $object * @return $this */ protected function loadLabel(ConfigurableAttribute $object) { $storeId = (int) $this->_storeManager->getStore()->getId(); $connection = $this->_getReadAdapter(); $useDefaultCheck = $connection->getCheckSql('store.use_default IS NULL', 'def.use_default', 'store.use_default'); $labelCheck = $connection->getCheckSql('store.value IS NULL', 'def.value', 'store.value'); $select = $connection->select()->from(array('def' => $this->_labelTable))->joinLeft(array('store' => $this->_labelTable), $connection->quoteInto('store.product_super_attribute_id = def.product_super_attribute_id AND store.store_id = ?', $storeId), array('use_default' => $useDefaultCheck, 'label' => $labelCheck))->where('def.product_super_attribute_id = ?', $object->getId())->where('def.store_id = ?', 0); $data = $connection->fetchRow($select); $object->setLabel($data['label']); $object->setUseDefault($data['use_default']); return $this; }