當前位置: 首頁>>代碼示例>>PHP>>正文


PHP DataObjectHelper::getCustomAttributeValueByType方法代碼示例

本文整理匯總了PHP中Magento\Framework\Api\DataObjectHelper::getCustomAttributeValueByType方法的典型用法代碼示例。如果您正苦於以下問題:PHP DataObjectHelper::getCustomAttributeValueByType方法的具體用法?PHP DataObjectHelper::getCustomAttributeValueByType怎麽用?PHP DataObjectHelper::getCustomAttributeValueByType使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在Magento\Framework\Api\DataObjectHelper的用法示例。


在下文中一共展示了DataObjectHelper::getCustomAttributeValueByType方法的1個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的PHP代碼示例。

示例1: save

 /**
  * {@inheritdoc}
  */
 public function save(CustomAttributesDataInterface $dataObjectWithCustomAttributes, $entityType, CustomAttributesDataInterface $previousCustomerData = null)
 {
     //Get all Image related custom attributes
     $imageDataObjects = $this->dataObjectHelper->getCustomAttributeValueByType($dataObjectWithCustomAttributes->getCustomAttributes(), '\\Magento\\Framework\\Api\\Data\\ImageContentInterface');
     // Return if no images to process
     if (empty($imageDataObjects)) {
         return $dataObjectWithCustomAttributes;
     }
     // For every image, save it and replace it with corresponding Eav data object
     /** @var $imageDataObject \Magento\Framework\Api\AttributeValue */
     foreach ($imageDataObjects as $imageDataObject) {
         /** @var $imageContent \Magento\Framework\Api\Data\ImageContentInterface */
         $imageContent = $imageDataObject->getValue();
         $filename = $this->processImageContent($entityType, $imageContent);
         //Set filename from static media location into data object
         $dataObjectWithCustomAttributes->setCustomAttribute($imageDataObject->getAttributeCode(), $filename);
         //Delete previously saved image if it exists
         if ($previousCustomerData) {
             $previousImageAttribute = $previousCustomerData->getCustomAttribute($imageDataObject->getAttributeCode());
             if ($previousImageAttribute) {
                 $previousImagePath = $previousImageAttribute->getValue();
                 if (!empty($previousImagePath)) {
                     @unlink($this->mediaDirectory->getAbsolutePath() . $entityType . $previousImagePath);
                 }
             }
         }
     }
     return $dataObjectWithCustomAttributes;
 }
開發者ID:pradeep-wagento,項目名稱:magento2,代碼行數:32,代碼來源:ImageProcessor.php


注:本文中的Magento\Framework\Api\DataObjectHelper::getCustomAttributeValueByType方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。