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


PHP Type::getTypes方法代码示例

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


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

示例1: toModel

 /**
  * @param  Product $product
  * @param  \Magento\Catalog\Model\Product $productModel
  * @return \Magento\Catalog\Model\Product
  * @throws \RuntimeException
  */
 public function toModel(Product $product, \Magento\Catalog\Model\Product $productModel = null)
 {
     /** @var \Magento\Catalog\Model\Product $productModel */
     $productModel = $productModel ?: $this->productFactory->create();
     $productModel->addData(ExtensibleDataObjectConverter::toFlatArray($product));
     if (!is_numeric($productModel->getAttributeSetId())) {
         $productModel->setAttributeSetId($productModel->getDefaultAttributeSetId());
     }
     if (!$productModel->hasTypeId()) {
         $productModel->setTypeId(\Magento\Catalog\Model\Product\Type::DEFAULT_TYPE);
     } elseif (!isset($this->productTypes->getTypes()[$productModel->getTypeId()])) {
         throw new \RuntimeException('Illegal product type');
     }
     return $productModel;
 }
开发者ID:aiesh,项目名称:magento2,代码行数:21,代码来源:ProductMapper.php

示例2: getProductTypeInstances

 /**
  * Retrieve Product Type Instances
  * as key - type code, value - instance model
  *
  * @return array
  */
 protected function getProductTypeInstances()
 {
     if (empty($this->productTypes)) {
         $productEmulator = new \Magento\Framework\DataObject();
         foreach (array_keys($this->productType->getTypes()) as $typeId) {
             $productEmulator->setTypeId($typeId);
             $this->productTypes[$typeId] = $this->productType->factory($productEmulator);
         }
     }
     return $this->productTypes;
 }
开发者ID:Doability,项目名称:magento2dev,代码行数:17,代码来源:StockIndex.php

示例3: getDisplayOnContainers

 /**
  * Generate array of parameters for every container type to create html template
  *
  * @return array
  * @SuppressWarnings(PHPMD.UnusedLocalVariable)
  */
 public function getDisplayOnContainers()
 {
     $container = [];
     $container['anchor'] = ['label' => 'Categories', 'code' => 'categories', 'name' => 'anchor_categories', 'layout_handle' => \Magento\Widget\Model\Widget\Instance::ANCHOR_CATEGORY_LAYOUT_HANDLE, 'is_anchor_only' => 1, 'product_type_id' => ''];
     $container['notanchor'] = ['label' => 'Categories', 'code' => 'categories', 'name' => 'notanchor_categories', 'layout_handle' => \Magento\Widget\Model\Widget\Instance::NOTANCHOR_CATEGORY_LAYOUT_HANDLE, 'is_anchor_only' => 0, 'product_type_id' => ''];
     $container['all_products'] = ['label' => 'Products', 'code' => 'products', 'name' => 'all_products', 'layout_handle' => \Magento\Widget\Model\Widget\Instance::PRODUCT_LAYOUT_HANDLE, 'is_anchor_only' => '', 'product_type_id' => ''];
     foreach ($this->_productType->getTypes() as $typeId => $type) {
         $container[$typeId] = ['label' => 'Products', 'code' => 'products', 'name' => $typeId . '_products', 'layout_handle' => str_replace('{{TYPE}}', $typeId, \Magento\Widget\Model\Widget\Instance::PRODUCT_TYPE_LAYOUT_HANDLE), 'is_anchor_only' => '', 'product_type_id' => $typeId];
     }
     return $container;
 }
开发者ID:kidaa30,项目名称:magento2-platformsh,代码行数:17,代码来源:Layout.php

示例4: _getProductTypeInstances

 /**
  * Retrieve Product Type Instances
  * as key - type code, value - instance model
  *
  * @return array
  */
 protected function _getProductTypeInstances()
 {
     if ($this->_productTypes === null) {
         $this->_productTypes = [];
         $productEmulator = new \Magento\Framework\Object();
         foreach (array_keys($this->_productType->getTypes()) as $typeId) {
             $productEmulator->setTypeId($typeId);
             $this->_productTypes[$typeId] = $this->_productType->factory($productEmulator);
         }
     }
     return $this->_productTypes;
 }
开发者ID:shabbirvividads,项目名称:magento2,代码行数:18,代码来源:AbstractAction.php

示例5: testGetTypes

 public function testGetTypes()
 {
     $types = $this->_productType->getTypes();
     $this->assertArrayHasKey(\Magento\Catalog\Model\Product\Type::TYPE_SIMPLE, $types);
     $this->assertArrayHasKey(\Magento\Catalog\Model\Product\Type::TYPE_VIRTUAL, $types);
     $this->assertArrayHasKey(\Magento\Catalog\Model\Product\Type::TYPE_BUNDLE, $types);
     $this->assertArrayHasKey(\Magento\Downloadable\Model\Product\Type::TYPE_DOWNLOADABLE, $types);
     foreach ($types as $type) {
         $this->assertArrayHasKey('label', $type);
         $this->assertArrayHasKey('model', $type);
         $this->assertArrayHasKey('composite', $type);
         // possible bug: index_priority is not defined for each type
     }
 }
开发者ID:kidaa30,项目名称:magento2-platformsh,代码行数:14,代码来源:TypeTest.php

示例6: getTypes

 /**
  * {@inheritdoc}
  */
 public function getTypes()
 {
     $pluginInfo = $this->pluginList->getNext($this->subjectType, 'getTypes');
     if (!$pluginInfo) {
         return parent::getTypes();
     } else {
         return $this->___callPlugins('getTypes', func_get_args(), $pluginInfo);
     }
 }
开发者ID:HaonanXu,项目名称:der-snack-backup,代码行数:12,代码来源:Interceptor.php


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