本文整理汇总了PHP中Magento\Catalog\Model\Product\Type::factory方法的典型用法代码示例。如果您正苦于以下问题:PHP Type::factory方法的具体用法?PHP Type::factory怎么用?PHP Type::factory使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Magento\Catalog\Model\Product\Type
的用法示例。
在下文中一共展示了Type::factory方法的8个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: testFactory
public function testFactory()
{
$product = new \Magento\Framework\DataObject();
$product->setTypeId(\Magento\GroupedProduct\Model\Product\Type\Grouped::TYPE_CODE);
$type = $this->_productType->factory($product);
$this->assertInstanceOf('\\Magento\\GroupedProduct\\Model\\Product\\Type\\Grouped', $type);
}
示例2: testFactoryReturnsSingleton
/**
* @param sring|null $typeId
* @dataProvider factoryReturnsSingletonDataProvider
*/
public function testFactoryReturnsSingleton($typeId)
{
$product = new \Magento\Framework\DataObject();
if ($typeId) {
$product->setTypeId($typeId);
}
$type = $this->_productType->factory($product);
$otherType = $this->_productType->factory($product);
$this->assertSame($otherType, $type);
}
示例3: getProductTypeInstance
/**
* Retrieve Product Type Instance
*
* @param string $typeId
* @return \Magento\Catalog\Model\Product\Type\AbstractType
*/
protected function getProductTypeInstance($typeId)
{
if (!isset($this->productTypes[$typeId])) {
$productEmulator = $this->getProductEmulator($typeId);
$this->productTypes[$typeId] = $this->catalogProductType->factory($productEmulator);
}
return $this->productTypes[$typeId];
}
示例4: factory
/**
* {@inheritdoc}
*/
public function factory($product)
{
$pluginInfo = $this->pluginList->getNext($this->subjectType, 'factory');
if (!$pluginInfo) {
return parent::factory($product);
} else {
return $this->___callPlugins('factory', func_get_args(), $pluginInfo);
}
}
示例5: 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;
}
示例6: _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;
}
示例7: getTypeInstance
/**
* Retrieve type instance of the product.
* Type instance implements product type depended logic and is a singleton shared by all products of the same type.
*
* @return \Magento\Catalog\Model\Product\Type\AbstractType
*/
public function getTypeInstance()
{
if ($this->_typeInstance === null) {
$this->_typeInstance = $this->_catalogProductType->factory($this);
}
return $this->_typeInstance;
}
示例8: save
/**
* Save type related data
*
* @param \Magento\Catalog\Model\Product $product
* @return $this
*/
public function save($product)
{
if ($product->dataHasChangedFor('type_id') && $product->getOrigData('type_id')) {
$oldTypeProduct = clone $product;
$oldTypeInstance = $this->_catalogProductType->factory($oldTypeProduct->setTypeId($product->getOrigData('type_id')));
$oldTypeProduct->setTypeInstance($oldTypeInstance);
$oldTypeInstance->deleteTypeSpecificData($oldTypeProduct);
}
return $this;
}