本文整理汇总了PHP中Magento\Catalog\Model\Product\Type类的典型用法代码示例。如果您正苦于以下问题:PHP Type类的具体用法?PHP Type怎么用?PHP Type使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了Type类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的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);
}
开发者ID:Doability,项目名称:magento2dev,代码行数:7,代码来源:GroupedTest.php
示例2: toOptionArray
/**
* Return options.
*
* @return mixed
*/
public function toOptionArray()
{
$options = $this->productType->getAllOptions();
//Add default option to first key of array. First key has empty value and empty label.
$options[0]['value'] = '0';
$options[0]['label'] = '---- Default Option ----';
return $options;
}
开发者ID:dotmailer,项目名称:dotmailer-magento2-extension,代码行数:13,代码来源:Catalogtype.php
示例3: 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
示例4: _prepareColumns
/**
* @return $this
*/
protected function _prepareColumns()
{
$this->addColumn('entity_id', array('header' => __('ID'), 'type' => 'number', 'index' => 'entity_id', 'header_css_class' => 'col-id', 'column_css_class' => 'col-id'));
$this->addColumn('name', array('header' => __('Name'), 'index' => 'name', 'class' => 'xxx'));
$store = $this->_getStore();
if ($store->getId()) {
$this->addColumn('custom_name', array('header' => __('Name in %1', $store->getName()), 'index' => 'custom_name', 'header_css_class' => 'col-name', 'column_css_class' => 'col-name'));
}
$this->addColumn('type', array('header' => __('Type'), 'index' => 'type_id', 'type' => 'options', 'options' => $this->_type->getOptionArray()));
$sets = $this->_setsFactory->create()->setEntityTypeFilter($this->_productFactory->create()->getResource()->getTypeId())->load()->toOptionHash();
$this->addColumn('set_name', array('header' => __('Attribute Set'), 'index' => 'attribute_set_id', 'type' => 'options', 'options' => $sets, 'header_css_class' => 'col-attr-name', 'column_css_class' => 'col-attr-name'));
$this->addColumn('sku', array('header' => __('SKU'), 'index' => 'sku'));
$store = $this->_getStore();
$this->addColumn('price', array('header' => __('Price'), 'type' => 'price', 'currency_code' => $store->getBaseCurrency()->getCode(), 'index' => 'price', 'header_css_class' => 'col-price', 'column_css_class' => 'col-price'));
if ($this->_catalogData->isModuleEnabled('Magento_CatalogInventory')) {
$this->addColumn('qty', array('header' => __('Quantity'), 'type' => 'number', 'index' => 'qty'));
}
$this->addColumn('visibility', array('header' => __('Visibility'), 'index' => 'visibility', 'type' => 'options', 'options' => $this->_visibility->getOptionArray(), 'header_css_class' => 'col-visibility', 'column_css_class' => 'col-visibility'));
$this->addColumn('status', array('header' => __('Status'), 'index' => 'status', 'type' => 'options', 'options' => $this->_status->getOptionArray()));
if (!$this->_storeManager->isSingleStoreMode()) {
$this->addColumn('websites', array('header' => __('Websites'), 'sortable' => false, 'index' => 'websites', 'type' => 'options', 'options' => $this->_websiteFactory->create()->getCollection()->toOptionHash(), 'header_css_class' => 'col-websites', 'column_css_class' => 'col-websites'));
}
$this->addColumn('edit', array('header' => __('Edit'), 'type' => 'action', 'getter' => 'getId', 'actions' => array(array('caption' => __('Edit'), 'url' => array('base' => '*/*/edit', 'params' => array('store' => $this->getRequest()->getParam('store'))), 'field' => 'id')), 'filter' => false, 'sortable' => false, 'index' => 'stores', 'header_css_class' => 'col-action', 'column_css_class' => 'col-action'));
if ($this->_catalogData->isModuleEnabled('Magento_Rss')) {
$this->addRssList('rss/catalog/notifystock', __('Notify Low Stock RSS'));
}
return parent::_prepareColumns();
}
开发者ID:aiesh,项目名称:magento2,代码行数:31,代码来源:Grid.php
示例5: _prepareColumns
/**
* @return $this
* @SuppressWarnings(PHPMD.ExcessiveMethodLength)
*/
protected function _prepareColumns()
{
$this->addColumn('entity_id', ['header' => __('ID'), 'type' => 'number', 'index' => 'entity_id', 'header_css_class' => 'col-id', 'column_css_class' => 'col-id']);
$this->addColumn('name', ['header' => __('Name'), 'index' => 'name', 'class' => 'xxx']);
$store = $this->_getStore();
if ($store->getId()) {
$this->addColumn('custom_name', ['header' => __('Name in %1', $store->getName()), 'index' => 'custom_name', 'header_css_class' => 'col-name', 'column_css_class' => 'col-name']);
}
$this->addColumn('type', ['header' => __('Type'), 'index' => 'type_id', 'type' => 'options', 'options' => $this->_type->getOptionArray()]);
$sets = $this->_setsFactory->create()->setEntityTypeFilter($this->_productFactory->create()->getResource()->getTypeId())->load()->toOptionHash();
$this->addColumn('set_name', ['header' => __('Product Template'), 'index' => 'attribute_set_id', 'type' => 'options', 'options' => $sets, 'header_css_class' => 'col-attr-name', 'column_css_class' => 'col-attr-name']);
$this->addColumn('sku', ['header' => __('SKU'), 'index' => 'sku']);
$store = $this->_getStore();
$this->addColumn('price', ['header' => __('Price'), 'type' => 'price', 'currency_code' => $store->getBaseCurrency()->getCode(), 'index' => 'price', 'header_css_class' => 'col-price', 'column_css_class' => 'col-price']);
if ($this->moduleManager->isEnabled('Magento_CatalogInventory')) {
$this->addColumn('qty', ['header' => __('Quantity'), 'type' => 'number', 'index' => 'qty']);
}
$this->addColumn('visibility', ['header' => __('Visibility'), 'index' => 'visibility', 'type' => 'options', 'options' => $this->_visibility->getOptionArray(), 'header_css_class' => 'col-visibility', 'column_css_class' => 'col-visibility']);
$this->addColumn('status', ['header' => __('Status'), 'index' => 'status', 'type' => 'options', 'options' => $this->_status->getOptionArray()]);
if (!$this->_storeManager->isSingleStoreMode()) {
$this->addColumn('websites', ['header' => __('Websites'), 'sortable' => false, 'index' => 'websites', 'type' => 'options', 'options' => $this->_websiteFactory->create()->getCollection()->toOptionHash(), 'header_css_class' => 'col-websites', 'column_css_class' => 'col-websites']);
}
$this->addColumn('edit', ['header' => __('Edit'), 'type' => 'action', 'getter' => 'getId', 'actions' => [['caption' => __('Edit'), 'url' => ['base' => '*/*/edit', 'params' => ['store' => $this->getRequest()->getParam('store')]], 'field' => 'id']], 'filter' => false, 'sortable' => false, 'index' => 'stores', 'header_css_class' => 'col-action', 'column_css_class' => 'col-action']);
$block = $this->getLayout()->getBlock('grid.bottom.links');
if ($block) {
$this->setChild('grid.bottom.links', $block);
}
return parent::_prepareColumns();
}
开发者ID:whoople,项目名称:magento2-testing,代码行数:33,代码来源:Grid.php
示例6: testGetTypeId
public function testGetTypeId()
{
$productType = $this->getMockBuilder('Magento\\Catalog\\Model\\Product\\Type\\Virtual')->disableOriginalConstructor()->getMockForAbstractClass();
$this->productTypeInstanceMock->expects($this->exactly(2))->method('factory')->will($this->returnValue($productType));
$this->model->getTypeInstance();
$this->model->setTypeId('typeId');
$this->model->getTypeInstance();
}
开发者ID:hientruong90,项目名称:magento2_installer,代码行数:8,代码来源:ProductTest.php
示例7: 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];
}
开发者ID:shabbirvividads,项目名称:magento2,代码行数:14,代码来源:Full.php
示例8: getOptionArray
/**
* {@inheritdoc}
*/
public function getOptionArray()
{
$pluginInfo = $this->pluginList->getNext($this->subjectType, 'getOptionArray');
if (!$pluginInfo) {
return parent::getOptionArray();
} else {
return $this->___callPlugins('getOptionArray', func_get_args(), $pluginInfo);
}
}
开发者ID:andrewhowdencom,项目名称:m2onk8s,代码行数:12,代码来源:Interceptor.php
示例9: configureSaveTest
/**
* Configure environment for `testSave` and `testSaveAndDuplicate` methods
* @return array
*/
protected function configureSaveTest()
{
$productTypeMock = $this->getMockBuilder('Magento\\Catalog\\Model\\Product\\Type\\Simple')->disableOriginalConstructor()->setMethods(['beforeSave', 'save'])->getMock();
$productTypeMock->expects($this->once())->method('beforeSave')->will($this->returnSelf());
$productTypeMock->expects($this->once())->method('save')->will($this->returnSelf());
$this->productTypeInstanceMock->expects($this->once())->method('factory')->with($this->model)->will($this->returnValue($productTypeMock));
$this->model->getResource()->expects($this->any())->method('addCommitCallback')->will($this->returnSelf());
$this->model->getResource()->expects($this->any())->method('commit')->will($this->returnSelf());
}
开发者ID:shabbirvividads,项目名称:magento2,代码行数:13,代码来源:ProductTest.php
示例10: testGetFinalPricePreset
public function testGetFinalPricePreset()
{
$finalPrice = 9.99;
$qty = 1;
$this->model->setQty($qty);
$this->model->setFinalPrice($finalPrice);
$this->productTypeInstanceMock->expects($this->never())->method('priceFactory');
$this->assertEquals($finalPrice, $this->model->getFinalPrice($qty));
}
开发者ID:nja78,项目名称:magento2,代码行数:9,代码来源:ProductTest.php
示例11: 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
示例12: 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
示例13: execute
/**
* Automaticaly assign backend model to weee attributes
*
* @param \Magento\Framework\Event\Observer $observer
* @return $this
*/
public function execute(\Magento\Framework\Event\Observer $observer)
{
$backendModel = \Magento\Weee\Model\Attribute\Backend\Weee\Tax::getBackendModelName();
/** @var $object \Magento\Eav\Model\Entity\Attribute\AbstractAttribute */
$object = $observer->getEvent()->getAttribute();
if ($object->getFrontendInput() == 'weee') {
$object->setBackendModel($backendModel);
if (!$object->getApplyTo()) {
$applyTo = [];
foreach ($this->productType->getOptions() as $option) {
if ($this->productTypeConfig->isProductSet($option['value'])) {
continue;
}
$applyTo[] = $option['value'];
}
$object->setApplyTo($applyTo);
}
}
return $this;
}
开发者ID:tingyeeh,项目名称:magento2,代码行数:26,代码来源:AssignBackendModelToAttributeObserver.php
示例14: _prepareColumns
/**
* Prepare grid columns
*
* @return $this
*/
protected function _prepareColumns()
{
$this->addColumn('id', ['header' => __('ID'), 'sortable' => true, 'width' => '60px', 'index' => 'entity_id']);
$this->addColumn('name', ['header' => __('Product'), 'index' => 'name', 'column_css_class' => 'name']);
$sets = $this->_eavCollectionFactory->create()->setEntityTypeFilter($this->_productFactory->create()->getResource()->getTypeId())->load()->toOptionHash();
$this->addColumn('type', ['header' => __('Type'), 'width' => '60px', 'index' => 'type_id', 'type' => 'options', 'options' => $this->_productType->getOptionArray()]);
$this->addColumn('set_name', ['header' => __('Attribute Set'), 'width' => '100px', 'index' => 'attribute_set_id', 'type' => 'options', 'options' => $sets]);
$this->addColumn('sku', ['header' => __('SKU'), 'width' => '80px', 'index' => 'sku', 'column_css_class' => 'sku']);
$this->addColumn('price', ['header' => __('Price'), 'align' => 'center', 'type' => 'currency', 'currency_code' => $this->_getStore()->getDefaultCurrencyCode(), 'rate' => $this->_getStore()->getBaseCurrency()->getRate($this->_getStore()->getDefaultCurrencyCode()), 'index' => 'price']);
return parent::_prepareColumns();
}
开发者ID:shabbirvividads,项目名称:magento2,代码行数:16,代码来源:Product.php
示例15: testGetGalleryAttributeBackend
public function testGetGalleryAttributeBackend()
{
$productType = $this->getMockBuilder('Magento\\Catalog\\Model\\Product\\Type\\AbstractType')->setMethods(['getEditableAttributes'])->disableOriginalConstructor()->getMockForAbstractClass();
$this->productTypeInstanceMock->expects($this->any())->method('factory')->will($this->returnValue($productType));
$attributeMediaGallery = $this->getMockBuilder('\\Magento\\Eav\\Model\\Entity\\Attribute\\AbstractAttribute')->setMethods(['__wakeup', 'getAttributeCode', 'getBackend'])->disableOriginalConstructor()->getMockForAbstractClass();
$attributeMediaGallery->expects($this->any())->method('getAttributeCode')->willReturn('media_gallery');
$expectedValue = 'expected';
$attributeMediaGallery->expects($this->once())->method('getBackend')->willReturn($expectedValue);
$productType->expects($this->once())->method('getEditableAttributes')->willReturn(['media_gallery' => $attributeMediaGallery]);
$this->assertEquals($expectedValue, $this->model->getGalleryAttributeBackend());
}
开发者ID:opexsw,项目名称:magento2,代码行数:11,代码来源:ProductTest.php
示例16: _prepareColumns
/**
* Define Cooser Grid Columns and filters
*
* @return $this
*/
protected function _prepareColumns()
{
$this->addColumn('in_products', array('header_css_class' => 'a-center', 'type' => 'checkbox', 'name' => 'in_products', 'values' => $this->_getSelectedProducts(), 'align' => 'center', 'index' => 'sku', 'use_index' => true));
$this->addColumn('entity_id', array('header' => __('ID'), 'sortable' => true, 'width' => '60px', 'index' => 'entity_id'));
$this->addColumn('type', array('header' => __('Type'), 'width' => '60px', 'index' => 'type_id', 'type' => 'options', 'options' => $this->_catalogType->getOptionArray()));
$sets = $this->_eavAttSetCollection->create()->setEntityTypeFilter($this->_catalogProduct->create()->getResource()->getTypeId())->load()->toOptionHash();
$this->addColumn('set_name', array('header' => __('Attribute Set'), 'width' => '100px', 'index' => 'attribute_set_id', 'type' => 'options', 'options' => $sets));
$this->addColumn('chooser_sku', array('header' => __('SKU'), 'name' => 'chooser_sku', 'width' => '80px', 'index' => 'sku'));
$this->addColumn('chooser_name', array('header' => __('Product'), 'name' => 'chooser_name', 'index' => 'name'));
return parent::_prepareColumns();
}
开发者ID:aiesh,项目名称:magento2,代码行数:16,代码来源:Sku.php
示例17: _getTypeIndexers
/**
* Retrieve Stock Indexer Models per Product Type
*
* @return \Magento\CatalogInventory\Model\ResourceModel\Indexer\Stock\StockInterface[]
*/
protected function _getTypeIndexers()
{
if (empty($this->_indexers)) {
foreach ($this->_catalogProductType->getTypesByPriority() as $typeId => $typeInfo) {
$indexerClassName = isset($typeInfo['stock_indexer']) ? $typeInfo['stock_indexer'] : '';
$indexer = $this->_indexerFactory->create($indexerClassName)->setTypeId($typeId)->setIsComposite(!empty($typeInfo['composite']));
$this->_indexers[$typeId] = $indexer;
}
}
return $this->_indexers;
}
开发者ID:pradeep-wagento,项目名称:magento2,代码行数:16,代码来源:AbstractAction.php
示例18: _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
示例19: addOrderedQty
/**
* Add ordered qty's
*
* @param string $from
* @param string $to
* @return $this
*/
public function addOrderedQty($from = '', $to = '')
{
$adapter = $this->getConnection();
$compositeTypeIds = $this->_productType->getCompositeTypes();
$orderTableAliasName = $adapter->quoteIdentifier('order');
$orderJoinCondition = array($orderTableAliasName . '.entity_id = order_items.order_id', $adapter->quoteInto("{$orderTableAliasName}.state <> ?", \Magento\Sales\Model\Order::STATE_CANCELED));
$productJoinCondition = array($adapter->quoteInto('(e.type_id NOT IN (?))', $compositeTypeIds), 'e.entity_id = order_items.product_id', $adapter->quoteInto('e.entity_type_id = ?', $this->getProductEntityTypeId()));
if ($from != '' && $to != '') {
$fieldName = $orderTableAliasName . '.created_at';
$orderJoinCondition[] = $this->_prepareBetweenSql($fieldName, $from, $to);
}
$this->getSelect()->reset()->from(array('order_items' => $this->getTable('sales_flat_order_item')), array('ordered_qty' => 'SUM(order_items.qty_ordered)', 'order_items_name' => 'order_items.name'))->joinInner(array('order' => $this->getTable('sales_flat_order')), implode(' AND ', $orderJoinCondition), array())->joinLeft(array('e' => $this->getProductEntityTableName()), implode(' AND ', $productJoinCondition), array('entity_id' => 'order_items.product_id', 'entity_type_id' => 'e.entity_type_id', 'attribute_set_id' => 'e.attribute_set_id', 'type_id' => 'e.type_id', 'sku' => 'e.sku', 'has_options' => 'e.has_options', 'required_options' => 'e.required_options', 'created_at' => 'e.created_at', 'updated_at' => 'e.updated_at'))->where('parent_item_id IS NULL')->group('order_items.product_id')->having('SUM(order_items.qty_ordered) > ?', 0);
return $this;
}
开发者ID:zhangjiachao,项目名称:magento2,代码行数:21,代码来源:Collection.php
示例20: getTypeIndexers
/**
* Retrieve price indexers per product type
*
* @return \Magento\Catalog\Model\ResourceModel\Product\Indexer\Price\PriceInterface[]
*/
public function getTypeIndexers()
{
if ($this->_indexers === null) {
$this->_indexers = [];
$types = $this->_catalogProductType->getTypesByPriority();
foreach ($types as $typeId => $typeInfo) {
$modelName = isset($typeInfo['price_indexer']) ? $typeInfo['price_indexer'] : get_class($this->_defaultIndexerResource);
$isComposite = !empty($typeInfo['composite']);
$indexer = $this->_indexerPriceFactory->create($modelName)->setTypeId($typeId)->setIsComposite($isComposite);
$this->_indexers[$typeId] = $indexer;
}
}
return $this->_indexers;
}
开发者ID:Doability,项目名称:magento2dev,代码行数:19,代码来源:AbstractAction.php
注:本文中的Magento\Catalog\Model\Product\Type类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论