当前位置: 首页>>代码示例>>PHP>>正文


PHP ProductInterface::isAttributeEditable方法代码示例

本文整理汇总了PHP中Pim\Component\Catalog\Model\ProductInterface::isAttributeEditable方法的典型用法代码示例。如果您正苦于以下问题:PHP ProductInterface::isAttributeEditable方法的具体用法?PHP ProductInterface::isAttributeEditable怎么用?PHP ProductInterface::isAttributeEditable使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在Pim\Component\Catalog\Model\ProductInterface的用法示例。


在下文中一共展示了ProductInterface::isAttributeEditable方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: prepareProductValues

 /**
  * Prepare product values
  *
  * @param ProductInterface $product
  * @param array            $actions
  *
  * @return array
  */
 protected function prepareProductValues(ProductInterface $product, array $actions)
 {
     $normalizedValues = json_decode($actions['normalized_values'], true);
     $filteredValues = [];
     foreach ($normalizedValues as $attributeCode => $values) {
         $attribute = $this->attributeRepository->findOneByIdentifier($attributeCode);
         if ($product->isAttributeEditable($attribute)) {
             $filteredValues[$attributeCode] = $values;
         }
     }
     return $filteredValues;
 }
开发者ID:SamirBoulil,项目名称:pim-community-dev,代码行数:20,代码来源:EditCommonAttributesProcessor.php

示例2: prepareProductValues

 /**
  * Prepare product values
  *
  * @param ProductInterface $product
  * @param array            $actions
  *
  * @return array
  */
 protected function prepareProductValues(ProductInterface $product, array $actions)
 {
     $normalizedValues = json_decode($actions['normalized_values'], true);
     $attributeLocale = $actions['attribute_locale'];
     $filteredValues = [];
     foreach ($normalizedValues as $attributeCode => $values) {
         $attribute = $this->attributeRepository->findOneByIdentifier($attributeCode);
         if ($product->isAttributeEditable($attribute)) {
             $values = array_filter($values, function ($value) use($attributeLocale) {
                 return $attributeLocale === $value['locale'] || null === $value['locale'];
             });
             $localizer = $this->localizerRegistry->getLocalizer($attribute->getAttributeType());
             if (null !== $localizer) {
                 $locale = $actions['ui_locale'];
                 $values = array_map(function ($value) use($localizer, $locale) {
                     $value['data'] = $localizer->delocalize($value['data'], ['locale' => $locale]);
                     return $value;
                 }, $values);
             }
             $filteredValues[$attributeCode] = $values;
         }
     }
     return $filteredValues;
 }
开发者ID:mm999,项目名称:pim-community-dev,代码行数:32,代码来源:EditCommonAttributesProcessor.php

示例3: updateProduct

 /**
  * Set data from $actions to the given $product
  *
  * Actions should looks like that
  *
  * $actions =
  * [
  *     [
  *          'field'   => 'group',
  *          'value'   => 'summer_clothes',
  *          'options' => null
  *      ],
  *      [
  *          'field'   => 'category',
  *          'value'   => 'catalog_2013,catalog_2014',
  *          'options' => null
  *      ],
  * ]
  *
  * @param ProductInterface $product
  * @param array            $configuration
  *
  * @throws \LogicException
  *
  * @return ProductInterface $product
  */
 protected function updateProduct(ProductInterface $product, array $configuration)
 {
     $modifiedAttributesNb = 0;
     foreach ($configuration['actions'] as $action) {
         $attribute = $this->attributeRepository->findOneBy(['code' => $action['field']]);
         if (null === $attribute) {
             throw new \LogicException(sprintf('Attribute with code %s does not exist'), $action['field']);
         }
         if ($product->isAttributeEditable($attribute)) {
             $localizer = $this->localizerRegistry->getLocalizer($attribute->getAttributeType());
             if (null !== $localizer) {
                 $action['value'] = $localizer->delocalize($action['value'], ['locale' => $configuration['locale']]);
             }
             $this->propertySetter->setData($product, $action['field'], $action['value'], $action['options']);
             $modifiedAttributesNb++;
         }
     }
     if (0 === $modifiedAttributesNb) {
         $this->stepExecution->incrementSummaryInfo('skipped_products');
         $this->stepExecution->addWarning($this->getName(), 'pim_enrich.mass_edit_action.edit-common-attributes.message.no_valid_attribute', [], $product);
         return null;
     }
     return $product;
 }
开发者ID:abdeldayem,项目名称:pim-community-dev,代码行数:50,代码来源:EditCommonAttributesProcessor.php


注:本文中的Pim\Component\Catalog\Model\ProductInterface::isAttributeEditable方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。