本文整理汇总了PHP中Magento\Catalog\Model\Product\Visibility::getOptionArray方法的典型用法代码示例。如果您正苦于以下问题:PHP Visibility::getOptionArray方法的具体用法?PHP Visibility::getOptionArray怎么用?PHP Visibility::getOptionArray使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Magento\Catalog\Model\Product\Visibility
的用法示例。
在下文中一共展示了Visibility::getOptionArray方法的8个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: _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();
}
示例2: _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();
}
示例3: _prepareColumns
/**
* {@inheritdoc}
*/
protected function _prepareColumns()
{
$this->addColumn('in_products', ['type' => 'checkbox', 'name' => 'in_products', 'values' => $this->getSelectedProducts(), 'align' => 'center', 'index' => 'entity_id', 'header_css_class' => 'col-select', 'column_css_class' => 'col-select']);
$this->addColumn('position', ['header' => __('Position'), 'name' => 'position', 'type' => 'number', 'validate_class' => 'validate-number', 'index' => 'position', 'editable' => true, 'is_system' => 1, 'header_css_class' => 'col-hidden', 'column_css_class' => 'col-hidden']);
$this->addColumn('id', ['header' => __('ID'), 'type' => 'number', 'index' => 'entity_id']);
$this->addColumn('name', ['header' => __('Name'), 'index' => 'name']);
$this->addColumn('sku', ['header' => __('SKU'), 'index' => 'sku']);
$this->addColumn('status', ['header' => __('Status'), 'index' => 'status', 'type' => 'options', 'options' => $this->status->getOptionArray()]);
$this->addColumn('visibility', ['header' => __('Visibility'), 'index' => 'visibility', 'type' => 'options', 'options' => $this->visibility->getOptionArray()]);
}
示例4: _prepareColumns
/**
* Add columns to grid
*
* @return $this
*/
protected function _prepareColumns()
{
if (!$this->isReadonly()) {
$this->addColumn('in_products', ['type' => 'checkbox', 'name' => 'in_products', 'values' => $this->_getSelectedProducts(), 'align' => 'center', 'index' => 'entity_id', 'header_css_class' => 'col-select', 'column_css_class' => 'col-select']);
}
$this->addColumn('entity_id', ['header' => __('ID'), 'sortable' => true, 'index' => 'entity_id', 'header_css_class' => 'col-id', 'column_css_class' => 'col-id']);
$this->addColumn('name', ['header' => __('Name'), 'index' => 'name', 'header_css_class' => 'col-name', 'column_css_class' => 'col-name']);
$this->addColumn('sku', ['header' => __('SKU'), 'index' => 'sku', 'header_css_class' => 'col-sku', 'column_css_class' => 'col-sku']);
$this->addColumn('visibility', ['header' => __('Visibility'), 'index' => 'visibility', 'type' => 'options', 'options' => $this->_visibility->getOptionArray(), 'header_css_class' => 'col-visibility', 'column_css_class' => 'col-visibility']);
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('status', ['header' => __('Status'), 'index' => 'status', 'type' => 'options', 'options' => $this->_status->getOptionArray(), 'header_css_class' => 'col-status', 'column_css_class' => 'col-status', 'frame_callback' => array($this->getLayout()->createBlock('Magefan\\Blog\\Block\\Adminhtml\\Grid\\Column\\Statuses'), 'decorateStatus')]);
return parent::_prepareColumns();
}
示例5: _prepareColumns
/**
* Add columns to grid
*
* @return $this
*/
protected function _prepareColumns()
{
if (!$this->getProduct()->getUpsellReadonly()) {
$this->addColumn('in_products', array('type' => 'checkbox', 'name' => 'in_products', 'values' => $this->_getSelectedProducts(), 'align' => 'center', 'index' => 'entity_id', 'header_css_class' => 'col-select', 'column_css_class' => 'col-select'));
}
$this->addColumn('entity_id', array('header' => __('ID'), 'sortable' => true, 'index' => 'entity_id', 'header_css_class' => 'col-id', 'column_css_class' => 'col-id'));
$this->addColumn('name', array('header' => __('Name'), 'index' => '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(), 'header_css_class' => 'col-type', 'column_css_class' => 'col-type'));
$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('status', array('header' => __('Status'), 'index' => 'status', 'type' => 'options', 'options' => $this->_status->getOptionArray(), 'header_css_class' => 'col-status', 'column_css_class' => 'col-status'));
$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('sku', array('header' => __('SKU'), 'index' => 'sku', 'header_css_class' => 'col-sku', 'column_css_class' => 'col-sku'));
$this->addColumn('price', array('header' => __('Price'), 'type' => 'currency', 'currency_code' => (string) $this->_scopeConfig->getValue(\Magento\Directory\Model\Currency::XML_PATH_CURRENCY_BASE, \Magento\Store\Model\ScopeInterface::SCOPE_STORE), 'index' => 'price', 'header_css_class' => 'col-price', 'column_css_class' => 'col-price'));
$this->addColumn('position', array('header' => __('Position'), 'name' => 'position', 'type' => 'number', 'validate_class' => 'validate-number', 'index' => 'position', 'editable' => !$this->getProduct()->getUpsellReadonly(), 'edit_only' => !$this->getProduct()->getId(), 'header_css_class' => 'col-position', 'column_css_class' => 'col-position', 'filter_condition_callback' => array($this, 'filterProductPosition')));
return parent::_prepareColumns();
}
示例6: _prepareColumns
/**
* @return $this
*/
protected function _prepareColumns()
{
$this->addColumn('in_products', ['header_css_class' => 'a-center', 'type' => 'checkbox', 'name' => 'in_products', 'values' => $this->_getSelectedProducts(), 'align' => 'center', 'index' => 'entity_id']);
$this->addColumn('entity_id', ['header' => __('ID'), 'sortable' => true, 'index' => 'entity_id', 'type' => 'number', 'header_css_class' => 'col-id', 'column_css_class' => 'col-id']);
$this->addColumn('name', ['header' => __('Name'), 'index' => 'product_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(), 'header_css_class' => 'col-type', 'column_css_class' => 'col-type']);
/** @var \Magento\Catalog\Model\Resource\Product $resource */
$resource = $this->productFactory->create()->getResource();
$sets = $this->setCollectionFactory->create()->setEntityTypeFilter($resource->getTypeId())->load()->toOptionHash();
$this->addColumn('set_name', ['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('status', ['header' => __('Status'), 'index' => 'status', 'type' => 'options', 'options' => $this->status->getOptionArray(), 'header_css_class' => 'col-status', 'column_css_class' => 'col-status']);
$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('sku', ['header' => __('SKU'), 'index' => 'sku', 'header_css_class' => 'col-sku', 'column_css_class' => 'col-sku']);
$this->addColumn('price', ['header' => __('Price'), 'type' => 'currency', 'currency_code' => (string) $this->_scopeConfig->getValue(Currency::XML_PATH_CURRENCY_BASE, ScopeInterface::SCOPE_STORE), 'index' => 'price', 'header_css_class' => 'col-price', 'column_css_class' => 'col-price']);
$this->addColumn('position', ['header' => __('Position'), 'name' => 'position', 'width' => 60, 'type' => 'number', 'validate_class' => 'validate-number', 'index' => 'position', 'editable' => true]);
return $this;
}
示例7: addProductToImport
/**
* Add product to import
*
* @param \Magento\Catalog\Model\Product $product
* @param string $storeId
* @return $this
*/
protected function addProductToImport($product, $storeId)
{
if ($product->getVisibility() == (string) Visibility::getOptionArray()[Visibility::VISIBILITY_NOT_VISIBLE]) {
return $this;
}
if (!isset($this->products[$product->getId()])) {
$this->products[$product->getId()] = [];
}
$this->products[$product->getId()][$storeId] = $product;
return $this;
}
示例8: isNeedToValidateUrlKey
/**
* @param array $rowData
* @return bool
*/
private function isNeedToValidateUrlKey($rowData)
{
return (!empty($rowData[self::URL_KEY]) || !empty($rowData[self::COL_NAME])) && (empty($rowData[self::COL_VISIBILITY]) || $rowData[self::COL_VISIBILITY] !== (string) Visibility::getOptionArray()[Visibility::VISIBILITY_NOT_VISIBLE]);
}