本文整理汇总了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;
}
示例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;
}
示例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;
}
示例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;
}
示例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
}
}
示例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);
}
}