Esempio n. 1
0
 /**
  * Retrieve data
  *
  * @param string $key
  * @param mixed $index
  * @return mixed
  */
 public function getData($key = '', $index = null)
 {
     if ('cc_number' === $key) {
         if (empty($this->_data['cc_number']) && !empty($this->_data['cc_number_enc'])) {
             $this->_data['cc_number'] = $this->decrypt($this->getCcNumberEnc());
         }
     }
     if ('cc_cid' === $key) {
         if (empty($this->_data['cc_cid']) && !empty($this->_data['cc_cid_enc'])) {
             $this->_data['cc_cid'] = $this->decrypt($this->getCcCidEnc());
         }
     }
     return parent::getData($key, $index);
 }
 /**
  * @param string[] $attributesAsArray
  * @param \Magento\Framework\Model\AbstractExtensibleModel $model
  * @return \Magento\Framework\Api\AttributeInterface[]
  */
 protected function addCustomAttributesToModel($attributesAsArray, $model)
 {
     $addedAttributes = [];
     foreach ($attributesAsArray as $attributeCode => $attributeValue) {
         $addedAttributes[$attributeCode] = new AttributeValue([AttributeValue::ATTRIBUTE_CODE => $attributeCode, AttributeValue::VALUE => $attributeValue]);
     }
     $model->setData(array_merge($model->getData(), [\Magento\Framework\Api\CustomAttributesDataInterface::CUSTOM_ATTRIBUTES => $addedAttributes]));
     return $addedAttributes;
 }
Esempio n. 3
0
 /**
  * @param string[] $attributesAsArray
  * @param \Magento\Framework\Model\AbstractExtensibleModel $model
  * @return \Magento\Framework\Api\AttributeInterface[]
  */
 protected function addCustomAttributesToModel($attributesAsArray, $model)
 {
     $objectManager = new ObjectManagerHelper($this);
     /** @var \Magento\Framework\Api\AttributeDataBuilder $attributeValueBuilder */
     $attributeValueBuilder = $objectManager->getObject('Magento\\Framework\\Api\\AttributeDataBuilder');
     $addedAttributes = [];
     foreach ($attributesAsArray as $attributeCode => $attributeValue) {
         $addedAttributes[$attributeCode] = $attributeValueBuilder->setAttributeCode($attributeCode)->setValue($attributeValue)->create();
     }
     $model->setData(array_merge($model->getData(), [\Magento\Framework\Api\ExtensibleDataInterface::CUSTOM_ATTRIBUTES => $addedAttributes]));
     return $addedAttributes;
 }