本文整理汇总了PHP中Magento\Store\Model\System\Store类的典型用法代码示例。如果您正苦于以下问题:PHP Store类的具体用法?PHP Store怎么用?PHP Store使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了Store类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的PHP代码示例。
示例1: _prepareForm
/**
* Prepare form
*
* @return $this
*/
protected function _prepareForm()
{
$model = $this->_coreRegistry->registry('cms_block');
/** @var \Magento\Framework\Data\Form $form */
$form = $this->_formFactory->create(['data' => ['id' => 'edit_form', 'action' => $this->getData('action'), 'method' => 'post']]);
$form->setHtmlIdPrefix('block_');
$fieldset = $form->addFieldset('base_fieldset', ['legend' => __('General Information'), 'class' => 'fieldset-wide']);
if ($model->getBlockId()) {
$fieldset->addField('block_id', 'hidden', ['name' => 'block_id']);
}
$fieldset->addField('title', 'text', ['name' => 'title', 'label' => __('Block Title'), 'title' => __('Block Title'), 'required' => true]);
$fieldset->addField('identifier', 'text', ['name' => 'identifier', 'label' => __('Identifier'), 'title' => __('Identifier'), 'required' => true, 'class' => 'validate-xml-identifier']);
/* Check is single store mode */
if (!$this->_storeManager->isSingleStoreMode()) {
$field = $fieldset->addField('store_id', 'multiselect', ['name' => 'stores[]', 'label' => __('Store View'), 'title' => __('Store View'), 'required' => true, 'values' => $this->_systemStore->getStoreValuesForForm(false, true)]);
$renderer = $this->getLayout()->createBlock('Magento\\Backend\\Block\\Store\\Switcher\\Form\\Renderer\\Fieldset\\Element');
$field->setRenderer($renderer);
} else {
$fieldset->addField('store_id', 'hidden', ['name' => 'stores[]', 'value' => $this->_storeManager->getStore(true)->getId()]);
$model->setStoreId($this->_storeManager->getStore(true)->getId());
}
$fieldset->addField('is_active', 'select', ['label' => __('Status'), 'title' => __('Status'), 'name' => 'is_active', 'required' => true, 'options' => ['1' => __('Enabled'), '0' => __('Disabled')]]);
if (!$model->getId()) {
$model->setData('is_active', '1');
}
$fieldset->addField('content', 'editor', ['name' => 'content', 'label' => __('Content'), 'title' => __('Content'), 'style' => 'height:36em', 'required' => true, 'config' => $this->_wysiwygConfig->getConfig()]);
$form->setValues($model->getData());
$form->setUseContainer(true);
$this->setForm($form);
return parent::_prepareForm();
}
开发者ID:pradeep-wagento,项目名称:magento2,代码行数:36,代码来源:Form.php
示例2: _prepareForm
/**
* Initialise form fields
*
* @return void
*/
protected function _prepareForm()
{
/** @var \Magento\Framework\Data\Form $form */
$form = $this->_formFactory->create();
$fieldset = $form->addFieldset('general', array('legend' => __('General Settings')));
if (!$this->_storeManager->isSingleStoreMode()) {
$field = $fieldset->addField('store_id', 'select', array('label' => __('Store'), 'title' => __('Store'), 'values' => $this->_systemStore->getStoreValuesForForm(), 'name' => 'store_id', 'required' => true));
$renderer = $this->getLayout()->createBlock('Magento\\Backend\\Block\\Store\\Switcher\\Form\\Renderer\\Fieldset\\Element');
$field->setRenderer($renderer);
} else {
$fieldset->addField('store_id', 'hidden', array('name' => 'store_id', 'value' => $this->_storeManager->getStore(true)->getId()));
}
/** @var $label \Magento\Framework\View\Design\Theme\Label */
$label = $this->_labelFactory->create();
$options = $label->getLabelsCollection(__('-- Please Select --'));
$fieldset->addField('design', 'select', array('label' => __('Custom Design'), 'title' => __('Custom Design'), 'values' => $options, 'name' => 'design', 'required' => true));
$dateFormat = $this->_localeDate->getDateFormat(\Magento\Framework\Stdlib\DateTime\TimezoneInterface::FORMAT_TYPE_SHORT);
$fieldset->addField('date_from', 'date', array('label' => __('Date From'), 'title' => __('Date From'), 'name' => 'date_from', 'image' => $this->getViewFileUrl('images/grid-cal.gif'), 'date_format' => $dateFormat));
$fieldset->addField('date_to', 'date', array('label' => __('Date To'), 'title' => __('Date To'), 'name' => 'date_to', 'image' => $this->getViewFileUrl('images/grid-cal.gif'), 'date_format' => $dateFormat));
$formData = $this->_backendSession->getDesignData(true);
if (!$formData) {
$formData = $this->_coreRegistry->registry('design')->getData();
} else {
$formData = $formData['design'];
}
$form->addValues($formData);
$form->setFieldNameSuffix('design');
$this->setForm($form);
}
开发者ID:aiesh,项目名称:magento2,代码行数:34,代码来源:General.php
示例3: _prepareForm
/**
* Prepare add review form
*
* @return void
*/
protected function _prepareForm()
{
/** @var \Magento\Framework\Data\Form $form */
$form = $this->_formFactory->create();
$fieldset = $form->addFieldset('add_review_form', array('legend' => __('Review Details')));
$fieldset->addField('product_name', 'note', array('label' => __('Product'), 'text' => 'product_name'));
$fieldset->addField('detailed_rating', 'note', array('label' => __('Product Rating'), 'required' => true, 'text' => '<div id="rating_detail">' . $this->getLayout()->createBlock('Magento\\Review\\Block\\Adminhtml\\Rating\\Detailed')->toHtml() . '</div>'));
$fieldset->addField('status_id', 'select', array('label' => __('Status'), 'required' => true, 'name' => 'status_id', 'values' => $this->_reviewData->getReviewStatusesOptionArray()));
/**
* Check is single store mode
*/
if (!$this->_storeManager->isSingleStoreMode()) {
$field = $fieldset->addField('select_stores', 'multiselect', array('label' => __('Visible In'), 'required' => true, 'name' => 'select_stores[]', 'values' => $this->_systemStore->getStoreValuesForForm()));
$renderer = $this->getLayout()->createBlock('Magento\\Backend\\Block\\Store\\Switcher\\Form\\Renderer\\Fieldset\\Element');
$field->setRenderer($renderer);
}
$fieldset->addField('nickname', 'text', array('name' => 'nickname', 'title' => __('Nickname'), 'label' => __('Nickname'), 'maxlength' => '50', 'required' => true));
$fieldset->addField('title', 'text', array('name' => 'title', 'title' => __('Summary of Review'), 'label' => __('Summary of Review'), 'maxlength' => '255', 'required' => true));
$fieldset->addField('detail', 'textarea', array('name' => 'detail', 'title' => __('Review'), 'label' => __('Review'), 'style' => 'height: 600px;', 'required' => true));
$fieldset->addField('product_id', 'hidden', array('name' => 'product_id'));
/*$gridFieldset = $form->addFieldset('add_review_grid', array('legend' => __('Please select a product')));
$gridFieldset->addField('products_grid', 'note', array(
'text' => $this->getLayout()->createBlock('Magento\Review\Block\Adminhtml\Product\Grid')->toHtml(),
));*/
$form->setMethod('post');
$form->setUseContainer(true);
$form->setId('edit_form');
$form->setAction($this->getUrl('review/product/post'));
$this->setForm($form);
}
开发者ID:aiesh,项目名称:magento2,代码行数:35,代码来源:Form.php
示例4: _prepareForm
/**
* Prepare form
*
* @return $this
*/
protected function _prepareForm()
{
/** @var $model \Magento\Cms\Model\Page */
$model = $this->_coreRegistry->registry('team');
/** @var \Magento\Framework\Data\Form $form */
$form = $this->_formFactory->create();
$form->setHtmlIdPrefix('page_');
$fieldset = $form->addFieldset('base_fieldset', ['legend' => __('Team Content')]);
$fieldset->addField('slogan', 'text', ['name' => 'slogan', 'label' => __('Team Slogan'), 'title' => __('Team Slogan'), 'required' => true]);
$fieldset->addField('team_color', 'text', ['name' => 'team_color', 'label' => __('Team Color'), 'title' => __('Team Color'), 'class' => 'jscolor {refine:false}']);
/**
* Check is single store mode
*/
if (!$this->_storeManager->isSingleStoreMode()) {
$field = $fieldset->addField('store_id', 'multiselect', ['name' => 'stores[]', 'label' => __('Store View'), 'title' => __('Store View'), 'required' => true, 'values' => $this->_systemStore->getStoreValuesForForm(false, true)]);
$renderer = $this->getLayout()->createBlock('Magento\\Backend\\Block\\Store\\Switcher\\Form\\Renderer\\Fieldset\\Element');
$field->setRenderer($renderer);
} else {
$fieldset->addField('store_id', 'hidden', ['name' => 'stores[]', 'value' => $this->_storeManager->getStore(true)->getId()]);
$model->setStoreId($this->_storeManager->getStore(true)->getId());
}
$form->setValues($model->getData());
$this->setForm($form);
return parent::_prepareForm();
}
开发者ID:vishalktpl,项目名称:CHAT,代码行数:30,代码来源:Content.php
示例5: _prepareForm
/**
* @return $this
*/
protected function _prepareForm()
{
$model = $this->_coreRegistry->registry('checkout_agreement');
/** @var \Magento\Framework\Data\Form $form */
$form = $this->_formFactory->create(array('data' => array('id' => 'edit_form', 'action' => $this->getData('action'), 'method' => 'post')));
$fieldset = $form->addFieldset('base_fieldset', array('legend' => __('Terms and Conditions Information'), 'class' => 'fieldset-wide'));
if ($model->getId()) {
$fieldset->addField('agreement_id', 'hidden', array('name' => 'agreement_id'));
}
$fieldset->addField('name', 'text', array('name' => 'name', 'label' => __('Condition Name'), 'title' => __('Condition Name'), 'required' => true));
$fieldset->addField('is_active', 'select', array('label' => __('Status'), 'title' => __('Status'), 'name' => 'is_active', 'required' => true, 'options' => array('1' => __('Enabled'), '0' => __('Disabled'))));
$fieldset->addField('is_html', 'select', array('label' => __('Show Content as'), 'title' => __('Show Content as'), 'name' => 'is_html', 'required' => true, 'options' => array(0 => __('Text'), 1 => __('HTML'))));
if (!$this->_storeManager->isSingleStoreMode()) {
$field = $fieldset->addField('store_id', 'multiselect', array('name' => 'stores[]', 'label' => __('Store View'), 'title' => __('Store View'), 'required' => true, 'values' => $this->_systemStore->getStoreValuesForForm(false, true)));
$renderer = $this->getLayout()->createBlock('Magento\\Backend\\Block\\Store\\Switcher\\Form\\Renderer\\Fieldset\\Element');
$field->setRenderer($renderer);
} else {
$fieldset->addField('store_id', 'hidden', array('name' => 'stores[]', 'value' => $this->_storeManager->getStore(true)->getId()));
$model->setStoreId($this->_storeManager->getStore(true)->getId());
}
$fieldset->addField('checkbox_text', 'editor', array('name' => 'checkbox_text', 'label' => __('Checkbox Text'), 'title' => __('Checkbox Text'), 'rows' => '5', 'cols' => '30', 'wysiwyg' => false, 'required' => true));
$fieldset->addField('content', 'editor', array('name' => 'content', 'label' => __('Content'), 'title' => __('Content'), 'style' => 'height:24em;', 'wysiwyg' => false, 'required' => true));
$fieldset->addField('content_height', 'text', array('name' => 'content_height', 'label' => __('Content Height (css)'), 'title' => __('Content Height'), 'maxlength' => 25, 'class' => 'validate-css-length'));
$form->setValues($model->getData());
$form->setUseContainer(true);
$this->setForm($form);
return parent::_prepareForm();
}
开发者ID:aiesh,项目名称:magento2,代码行数:31,代码来源:Form.php
示例6: generateCurrentOptions
/**
* Generate current options
*
* @return void
*/
protected function generateCurrentOptions()
{
$websiteCollection = $this->systemStore->getWebsiteCollection();
$groupCollection = $this->systemStore->getGroupCollection();
$storeCollection = $this->systemStore->getStoreCollection();
/** @var \Magento\Store\Model\Website $website */
foreach ($websiteCollection as $website) {
$groups = [];
/** @var \Magento\Store\Model\Group $group */
foreach ($groupCollection as $group) {
if ($group->getWebsiteId() == $website->getId()) {
$stores = [];
/** @var \Magento\Store\Model\Store $store */
foreach ($storeCollection as $store) {
if ($store->getGroupId() == $group->getId()) {
$name = $this->escaper->escapeHtml($store->getName());
$stores[$name]['label'] = str_repeat(' ', 8) . $name;
$stores[$name]['value'] = $store->getId();
}
}
if (!empty($stores)) {
$name = $this->escaper->escapeHtml($group->getName());
$groups[$name]['label'] = str_repeat(' ', 4) . $name;
$groups[$name]['value'] = array_values($stores);
}
}
}
if (!empty($groups)) {
$name = $this->escaper->escapeHtml($website->getName());
$this->currentOptions[$name]['label'] = $name;
$this->currentOptions[$name]['value'] = array_values($groups);
}
}
}
开发者ID:pradeep-wagento,项目名称:magento2,代码行数:39,代码来源:Options.php
示例7: _prepareForm
/**
* @return $this
*
* @throws \Magento\Framework\Exception\LocalizedException
*/
public function _prepareForm()
{
$model = $this->_coreRegistry->registry('current_ddg_rule');
$form = $this->_formFactory->create();
$form->setHtmlIdPrefix('rule_');
$fieldset = $form->addFieldset('base_fieldset', ['legend' => __('Rule Information')]);
if ($model->getId()) {
$fieldset->addField('id', 'hidden', ['name' => 'id']);
}
$fieldset->addField('name', 'text', ['name' => 'name', 'label' => __('Rule Name'), 'title' => __('Rule Name'), 'required' => true]);
$fieldset->addField('type', 'select', ['label' => __('Rule Type'), 'title' => __('Rule Type'), 'name' => 'type', 'required' => true, 'options' => [\Dotdigitalgroup\Email\Model\Rules::ABANDONED => 'Abandoned Cart Exclusion Rule', \Dotdigitalgroup\Email\Model\Rules::REVIEW => 'Review Email Exclusion Rule']]);
$fieldset->addField('status', 'select', ['label' => __('Status'), 'title' => __('Status'), 'name' => 'status', 'required' => true, 'options' => ['1' => __('Active'), '0' => __('Inactive')]]);
if (!$model->getId()) {
$model->setData('status', '0');
}
if ($this->_storeManager->isSingleStoreMode()) {
$websiteId = $this->_storeManager->getStore(true)->getWebsiteId();
$fieldset->addField('website_ids', 'hidden', ['name' => 'website_ids[]', 'value' => $websiteId]);
$model->setWebsiteIds($websiteId);
} else {
$field = $fieldset->addField('website_ids', 'multiselect', ['name' => 'website_ids[]', 'label' => __('Websites'), 'title' => __('Websites'), 'required' => true, 'values' => $this->systemStore->getWebsiteValuesForForm()]);
$renderer = $this->getLayout()->createBlock('Magento\\Backend\\Block\\Store\\Switcher\\Form\\Renderer\\Fieldset\\Element');
$field->setRenderer($renderer);
}
$form->setValues($model->getData());
$this->setForm($form);
return parent::_prepareForm();
}
开发者ID:dotmailer,项目名称:dotmailer-magento2-extension,代码行数:33,代码来源:Main.php
示例8: _processWebsite
/**
* Process website info
*
* @param \Magento\Store\Model\System\Store $storeModel
* @param \Magento\Store\Model\Website $website
* @param string $section
* @param string $curStore
* @param string $curWebsite
* @param array $options
* @return array
*/
protected function _processWebsite(\Magento\Store\Model\System\Store $storeModel, \Magento\Store\Model\Website $website, $section, $curStore, $curWebsite, array $options)
{
$websiteShow = false;
foreach ($storeModel->getGroupCollection() as $group) {
if ($group->getWebsiteId() != $website->getId()) {
continue;
}
$groupShow = false;
foreach ($storeModel->getStoreCollection() as $store) {
if ($store->getGroupId() != $group->getId()) {
continue;
}
if (!$websiteShow) {
$websiteShow = true;
$options['website_' . $website->getCode()] = array('label' => $website->getName(), 'url' => $this->getUrl('*/*/*', array('section' => $section, 'website' => $website->getCode())), 'selected' => !$curStore && $curWebsite == $website->getCode(), 'style' => 'padding-left:16px; background:#DDD; font-weight:bold;');
}
if (!$groupShow) {
$groupShow = true;
$options['group_' . $group->getId() . '_open'] = array('is_group' => true, 'is_close' => false, 'label' => $group->getName(), 'style' => 'padding-left:32px;');
}
$options['store_' . $store->getCode()] = array('label' => $store->getName(), 'url' => $this->getUrl('*/*/*', array('section' => $section, 'website' => $website->getCode(), 'store' => $store->getCode())), 'selected' => $curStore == $store->getCode(), 'style' => '');
}
if ($groupShow) {
$options['group_' . $group->getId() . '_close'] = array('is_group' => true, 'is_close' => true);
}
}
return $options;
}
开发者ID:aiesh,项目名称:magento2,代码行数:39,代码来源:Switcher.php
示例9: _prepareForm
/**
* Prepare form fields
*
* @return $this
*/
protected function _prepareForm()
{
$model = $this->_coreRegistry->registry('current_catalog_search');
/* @var $model \Magento\CatalogSearch\Model\Query */
/** @var \Magento\Framework\Data\Form $form */
$form = $this->_formFactory->create(array('data' => array('id' => 'edit_form', 'action' => $this->getData('action'), 'method' => 'post')));
$fieldset = $form->addFieldset('base_fieldset', array('legend' => __('General Information')));
$yesno = array(array('value' => 0, 'label' => __('No')), array('value' => 1, 'label' => __('Yes')));
if ($model->getId()) {
$fieldset->addField('query_id', 'hidden', array('name' => 'query_id'));
}
$fieldset->addField('query_text', 'text', array('name' => 'query_text', 'label' => __('Search Query'), 'title' => __('Search Query'), 'required' => true));
if (!$this->_storeManager->isSingleStoreMode()) {
$field = $fieldset->addField('store_id', 'select', array('name' => 'store_id', 'label' => __('Store'), 'title' => __('Store'), 'values' => $this->_systemStore->getStoreValuesForForm(true, false), 'required' => true));
$renderer = $this->getLayout()->createBlock('Magento\\Backend\\Block\\Store\\Switcher\\Form\\Renderer\\Fieldset\\Element');
$field->setRenderer($renderer);
} else {
$fieldset->addField('store_id', 'hidden', array('name' => 'store_id'));
$model->setStoreId($this->_storeManager->getStore(true)->getId());
}
if ($model->getId()) {
$fieldset->addField('num_results', 'text', array('name' => 'num_results', 'label' => __('Number of results'), 'title' => __('Number of results (For the last time placed)'), 'note' => __('For the last time placed.'), 'required' => true));
$fieldset->addField('popularity', 'text', array('name' => 'popularity', 'label' => __('Number of Uses'), 'title' => __('Number of Uses'), 'required' => true));
}
$fieldset->addField('synonym_for', 'text', array('name' => 'synonym_for', 'label' => __('Synonym For'), 'title' => __('Synonym For'), 'note' => __('Will make search for the query above return results for this search')));
$fieldset->addField('redirect', 'text', array('name' => 'redirect', 'label' => __('Redirect URL'), 'title' => __('Redirect URL'), 'class' => 'validate-url', 'note' => __('ex. http://domain.com')));
$fieldset->addField('display_in_terms', 'select', array('name' => 'display_in_terms', 'label' => __('Display in Suggested Terms'), 'title' => __('Display in Suggested Terms'), 'values' => $yesno));
$form->setValues($model->getData());
$form->setUseContainer(true);
$this->setForm($form);
return parent::_prepareForm();
}
开发者ID:aiesh,项目名称:magento2,代码行数:37,代码来源:Form.php
示例10: prepareItem
/**
* Get data
*
* @param array $item
* @return string
*/
protected function prepareItem(array $item)
{
$content = '';
$origStores = $item['store_id'];
if (empty($origStores)) {
return '';
}
if (!is_array($origStores)) {
$origStores = [$origStores];
}
if (in_array(0, $origStores) && count($origStores) == 1) {
return __('All Store Views');
}
$data = $this->systemStore->getStoresStructure(false, $origStores);
foreach ($data as $website) {
$content .= $website['label'] . "<br/>";
foreach ($website['children'] as $group) {
$content .= str_repeat(' ', 3) . $this->escaper->escapeHtml($group['label']) . "<br/>";
foreach ($group['children'] as $store) {
$content .= str_repeat(' ', 6) . $this->escaper->escapeHtml($store['label']) . "<br/>";
}
}
}
return $content;
}
开发者ID:nja78,项目名称:magento2,代码行数:31,代码来源:Store.php
示例11: testPrepareDataSource
public function testPrepareDataSource()
{
$dataSource = ['data' => ['items' => [['stores' => [1]]]]];
$expectedVisibility = "Test Website<br/> Test group<br/> Test store<br/>";
$expectedDataSource = ['data' => ['items' => [['stores' => [1], 'visibility' => $expectedVisibility]]]];
$this->storeMock->expects($this->once())->method('getStoresStructure')->willReturn([['label' => 'Test Website', 'children' => [['label' => 'Test group', 'children' => [['label' => 'Test store']]]]]]);
$this->assertEquals($expectedDataSource, $this->getModel()->prepareDataSource($dataSource));
}
开发者ID:Doability,项目名称:magento2dev,代码行数:8,代码来源:VisibilityTest.php
示例12: aroundSetForm
/**
* @param FrontTab $subject
* @param callable $proceed
* @param Form $form
* @return Front
* @SuppressWarnings(PHPMD.UnusedFormalParameter)
*/
public function aroundSetForm(FrontTab $subject, \Closure $proceed, Form $form)
{
$block = $proceed($form);
/** @var Fieldset $fieldset */
$fieldset = $form->getElement('front_fieldset');
$fieldset->addField('advanced_search_store_ids', 'multiselect', ['name' => 'advanced_search_store_ids[]', 'label' => __('Advanced Search Store(s)'), 'title' => __('Advanced Search Store(s)'), 'value' => 0, 'values' => $this->_systemStore->getStoreValuesForForm(false, true)], 'is_visible_in_advanced_search');
$subject->getChildBlock('form_after')->addFieldMap('advanced_search_store_ids', 'advanced_search_store_ids')->addFieldDependence('advanced_search_store_ids', 'advanced_search', '1')->addFieldDependence('advanced_search_store_ids', 'searchable', '1');
return $block;
}
开发者ID:Genmato,项目名称:M2_MultistoreSearchFields,代码行数:16,代码来源:Front.php
示例13: testPrepareDataSource
/**
* @dataProvider prepareDataSourceDataProvider
*/
public function testPrepareDataSource($dataSource, $expectedResult)
{
$website = 'website';
$group = 'group';
$store = 'store';
$storeStructure = [1 => ['value' => 1, 'label' => $website, 'children' => [1 => ['value' => 1, 'label' => $group, 'children' => [1 => ['value' => 1, 'label' => $store]]]]]];
$this->escaperMock->expects($this->any())->method('escapeHtml')->willReturnMap([[$group, null, $group], [$store, null, $store]]);
$this->systemStoreMock->expects($this->any())->method('getStoresStructure')->willReturn($storeStructure);
$this->assertEquals($this->model->prepareDataSource($dataSource), $expectedResult);
}
开发者ID:koliaGI,项目名称:magento2,代码行数:13,代码来源:StoreTest.php
示例14: getMetadataValues
/**
* Get metadata for sales rule form. It will be merged with form UI component declaration.
*
* @param Rule $rule
* @return array
* @SuppressWarnings(PHPMD.ExcessiveMethodLength)
*/
public function getMetadataValues(\Magento\SalesRule\Model\Rule $rule)
{
$customerGroups = $this->groupRepository->getList($this->searchCriteriaBuilder->create())->getItems();
$applyOptions = [['label' => __('Percent of product price discount'), 'value' => Rule::BY_PERCENT_ACTION], ['label' => __('Fixed amount discount'), 'value' => Rule::BY_FIXED_ACTION], ['label' => __('Fixed amount discount for whole cart'), 'value' => Rule::CART_FIXED_ACTION], ['label' => __('Buy X get Y free (discount amount is Y)'), 'value' => Rule::BUY_X_GET_Y_ACTION]];
$couponTypesOptions = [];
$couponTypes = $this->salesRuleFactory->create()->getCouponTypes();
foreach ($couponTypes as $key => $couponType) {
$couponTypesOptions[] = ['label' => $couponType, 'value' => $key];
}
$labels = $rule->getStoreLabels();
return ['rule_information' => ['children' => ['website_ids' => ['arguments' => ['data' => ['config' => ['options' => $this->store->getWebsiteValuesForForm()]]]], 'is_active' => ['arguments' => ['data' => ['config' => ['options' => [['label' => __('Active'), 'value' => '1'], ['label' => __('Inactive'), 'value' => '0']]]]]], 'customer_group_ids' => ['arguments' => ['data' => ['config' => ['options' => $this->objectConverter->toOptionArray($customerGroups, 'id', 'code')]]]], 'coupon_type' => ['arguments' => ['data' => ['config' => ['options' => $couponTypesOptions]]]], 'is_rss' => ['arguments' => ['data' => ['config' => ['options' => [['label' => __('Yes'), 'value' => '1'], ['label' => __('No'), 'value' => '0']]]]]]]], 'actions' => ['children' => ['simple_action' => ['arguments' => ['data' => ['config' => ['options' => $applyOptions]]]], 'discount_amount' => ['arguments' => ['data' => ['config' => ['value' => '0']]]], 'discount_qty' => ['arguments' => ['data' => ['config' => ['value' => '0']]]], 'apply_to_shipping' => ['arguments' => ['data' => ['config' => ['options' => [['label' => __('Yes'), 'value' => '1'], ['label' => __('No'), 'value' => '0']]]]]], 'stop_rules_processing' => ['arguments' => ['data' => ['config' => ['options' => [['label' => __('Yes'), 'value' => '1'], ['label' => __('No'), 'value' => '0']]]]]]]], 'labels' => ['children' => ['store_labels[0]' => ['arguments' => ['data' => ['config' => ['value' => isset($labels[0]) ? $labels[0] : '']]]]]]];
}
开发者ID:Doability,项目名称:magento2dev,代码行数:19,代码来源:ValueProvider.php
示例15: _prepareForm
/**
* Prepare rating edit form
*
* @return $this
*/
protected function _prepareForm()
{
/** @var \Magento\Framework\Data\Form $form */
$form = $this->_formFactory->create();
$this->setForm($form);
$fieldset = $form->addFieldset('rating_form', array('legend' => __('Rating Title')));
$fieldset->addField('rating_code', 'text', array('name' => 'rating_code', 'label' => __('Default Value'), 'class' => 'required-entry', 'required' => true));
foreach ($this->_systemStore->getStoreCollection() as $store) {
$fieldset->addField('rating_code_' . $store->getId(), 'text', array('label' => $store->getName(), 'name' => 'rating_codes[' . $store->getId() . ']'));
}
if ($this->_session->getRatingData()) {
$form->setValues($this->_session->getRatingData());
$data = $this->_session->getRatingData();
if (isset($data['rating_codes'])) {
$this->_setRatingCodes($data['rating_codes']);
}
$this->_session->setRatingData(null);
} elseif ($this->_coreRegistry->registry('rating_data')) {
$form->setValues($this->_coreRegistry->registry('rating_data')->getData());
if ($this->_coreRegistry->registry('rating_data')->getRatingCodes()) {
$this->_setRatingCodes($this->_coreRegistry->registry('rating_data')->getRatingCodes());
}
}
if ($this->_coreRegistry->registry('rating_data')) {
$collection = $this->_optionFactory->create()->getResourceCollection()->addRatingFilter($this->_coreRegistry->registry('rating_data')->getId())->load();
$i = 1;
foreach ($collection->getItems() as $item) {
$fieldset->addField('option_code_' . $item->getId(), 'hidden', array('required' => true, 'name' => 'option_title[' . $item->getId() . ']', 'value' => $item->getCode() ? $item->getCode() : $i));
$i++;
}
} else {
for ($i = 1; $i <= 5; $i++) {
$fieldset->addField('option_code_' . $i, 'hidden', array('required' => true, 'name' => 'option_title[add_' . $i . ']', 'value' => $i));
}
}
$fieldset = $form->addFieldset('visibility_form', array('legend' => __('Rating Visibility')));
if (!$this->_storeManager->isSingleStoreMode()) {
$field = $fieldset->addField('stores', 'multiselect', array('label' => __('Visible In'), 'name' => 'stores[]', 'values' => $this->_systemStore->getStoreValuesForForm()));
$renderer = $this->getLayout()->createBlock('Magento\\Backend\\Block\\Store\\Switcher\\Form\\Renderer\\Fieldset\\Element');
$field->setRenderer($renderer);
if ($this->_coreRegistry->registry('rating_data')) {
$form->getElement('stores')->setValue($this->_coreRegistry->registry('rating_data')->getStores());
}
}
$fieldset->addField('is_active', 'checkbox', array('label' => __('Is Active'), 'name' => 'is_active', 'value' => 1));
$fieldset->addField('position', 'text', array('label' => __('Sort Order'), 'name' => 'position'));
if ($this->_coreRegistry->registry('rating_data')) {
$form->getElement('position')->setValue($this->_coreRegistry->registry('rating_data')->getPosition());
$form->getElement('is_active')->setIsChecked($this->_coreRegistry->registry('rating_data')->getIsActive());
}
return parent::_prepareForm();
}
开发者ID:aiesh,项目名称:magento2,代码行数:57,代码来源:Form.php
示例16: _prepareForm
/**
* Prepare form for newsletter queue editing.
* Form can be run from newsletter template grid by option "Queue newsletter"
* or from newsletter queue grid by edit option.
*
* @return $this
* @SuppressWarnings(PHPMD.CyclomaticComplexity)
* @SuppressWarnings(PHPMD.NPathComplexity)
* @SuppressWarnings(PHPMD.ExcessiveMethodLength)
*/
protected function _prepareForm()
{
/* @var $queue \Magento\Newsletter\Model\Queue */
$queue = $this->getQueue();
/** @var \Magento\Framework\Data\Form $form */
$form = $this->_formFactory->create();
$fieldset = $form->addFieldset('base_fieldset', ['legend' => __('Queue Information'), 'class' => 'fieldset-wide']);
$dateFormat = $this->_localeDate->getDateFormat(\IntlDateFormatter::MEDIUM);
$timeFormat = $this->_localeDate->getTimeFormat(\IntlDateFormatter::MEDIUM);
if ($queue->getQueueStatus() == \Magento\Newsletter\Model\Queue::STATUS_NEVER) {
$fieldset->addField('date', 'date', ['name' => 'start_at', 'date_format' => $dateFormat, 'time_format' => $timeFormat, 'label' => __('Queue Date Start')]);
if (!$this->_storeManager->hasSingleStore()) {
$fieldset->addField('stores', 'multiselect', ['name' => 'stores[]', 'label' => __('Subscribers From'), 'values' => $this->_systemStore->getStoreValuesForForm(), 'value' => $queue->getStores()]);
} else {
$fieldset->addField('stores', 'hidden', ['name' => 'stores[]', 'value' => $this->_storeManager->getStore(true)->getId()]);
}
} else {
$fieldset->addField('date', 'date', ['name' => 'start_at', 'disabled' => 'true', 'style' => 'width:38%;', 'date_format' => $dateFormat, 'time_format' => $timeFormat, 'label' => __('Queue Date Start')]);
if (!$this->_storeManager->hasSingleStore()) {
$fieldset->addField('stores', 'multiselect', ['name' => 'stores[]', 'label' => __('Subscribers From'), 'required' => true, 'values' => $this->_systemStore->getStoreValuesForForm(), 'value' => $queue->getStores()]);
} else {
$fieldset->addField('stores', 'hidden', ['name' => 'stores[]', 'value' => $this->_storeManager->getStore(true)->getId()]);
}
}
if ($queue->getQueueStartAt()) {
$form->getElement('date')->setValue($this->_localeDate->date(new \DateTime($queue->getQueueStartAt())));
}
$fieldset->addField('subject', 'text', ['name' => 'subject', 'label' => __('Subject'), 'required' => true, 'value' => $queue->isNew() ? $queue->getTemplate()->getTemplateSubject() : $queue->getNewsletterSubject()]);
$fieldset->addField('sender_name', 'text', ['name' => 'sender_name', 'label' => __('Sender Name'), 'title' => __('Sender Name'), 'required' => true, 'value' => $queue->isNew() ? $queue->getTemplate()->getTemplateSenderName() : $queue->getNewsletterSenderName()]);
$fieldset->addField('sender_email', 'text', ['name' => 'sender_email', 'label' => __('Sender Email'), 'title' => __('Sender Email'), 'class' => 'validate-email', 'required' => true, 'value' => $queue->isNew() ? $queue->getTemplate()->getTemplateSenderEmail() : $queue->getNewsletterSenderEmail()]);
$widgetFilters = ['is_email_compatible' => 1];
$wysiwygConfig = $this->_wysiwygConfig->getConfig(['widget_filters' => $widgetFilters]);
if ($queue->isNew()) {
$fieldset->addField('text', 'editor', ['name' => 'text', 'label' => __('Message'), 'state' => 'html', 'required' => true, 'value' => $queue->getTemplate()->getTemplateText(), 'style' => 'height: 600px;', 'config' => $wysiwygConfig]);
$fieldset->addField('styles', 'textarea', ['name' => 'styles', 'label' => __('Newsletter Styles'), 'container_id' => 'field_newsletter_styles', 'value' => $queue->getTemplate()->getTemplateStyles()]);
} elseif (\Magento\Newsletter\Model\Queue::STATUS_NEVER != $queue->getQueueStatus()) {
$fieldset->addField('text', 'textarea', ['name' => 'text', 'label' => __('Message'), 'value' => $queue->getNewsletterText()]);
$fieldset->addField('styles', 'textarea', ['name' => 'styles', 'label' => __('Newsletter Styles'), 'value' => $queue->getNewsletterStyles()]);
$form->getElement('text')->setDisabled('true')->setRequired(false);
$form->getElement('styles')->setDisabled('true')->setRequired(false);
$form->getElement('subject')->setDisabled('true')->setRequired(false);
$form->getElement('sender_name')->setDisabled('true')->setRequired(false);
$form->getElement('sender_email')->setDisabled('true')->setRequired(false);
$form->getElement('stores')->setDisabled('true');
} else {
$fieldset->addField('text', 'editor', ['name' => 'text', 'label' => __('Message'), 'state' => 'html', 'required' => true, 'value' => $queue->getNewsletterText(), 'style' => 'height: 600px;', 'config' => $wysiwygConfig]);
$fieldset->addField('styles', 'textarea', ['name' => 'styles', 'label' => __('Newsletter Styles'), 'value' => $queue->getNewsletterStyles(), 'style' => 'height: 300px;']);
}
$this->setForm($form);
return $this;
}
开发者ID:kidaa30,项目名称:magento2-platformsh,代码行数:61,代码来源:Form.php
示例17: getAllOptions
/**
* @return array
*/
public function getAllOptions()
{
if (!$this->_options) {
$collection = $this->_createStoresCollection();
if ('store_id' == $this->getAttribute()->getAttributeCode()) {
$collection->setWithoutDefaultFilter();
}
$this->_options = $this->_store->getStoreValuesForForm();
if ('created_in' == $this->getAttribute()->getAttributeCode()) {
array_unshift($this->_options, ['value' => '0', 'label' => __('Admin')]);
}
}
return $this->_options;
}
开发者ID:pradeep-wagento,项目名称:magento2,代码行数:17,代码来源:Store.php
示例18: _prepareForm
/**
* Prepare form
*
* @return $this
*/
protected function _prepareForm()
{
//Magento\Backend\Model\Session
$form = $this->_formFactory->create(['data' => ['id' => 'edit_form', 'action' => $this->getData('action'), 'method' => 'post']]);
$form->setUseContainer(true);
$data = $this->_coreRegistry->registry('import_config')->getData();
/*
* Checking if user have permissions to save information
*/
if ($this->_authorization->isAllowed('Magefan_Blog::import')) {
$isElementDisabled = false;
} else {
$isElementDisabled = true;
}
$isElementDisabled = false;
$form->setHtmlIdPrefix('import_');
$fieldset = $form->addFieldset('base_fieldset', ['legend' => '']);
$fieldset->addField('type', 'hidden', ['name' => 'type', 'required' => true, 'disabled' => $isElementDisabled]);
$fieldset->addField('notice', 'label', ['label' => __('NOTICE'), 'name' => 'prefix', 'after_element_html' => 'When the import is completed successfully, please copy image files from WordPress <strong style="color:#bd1616;">wp-content/uploads</strong> directory to Magento <strong style="color:#105610;">pub/media/magefan_blog</strong> directory.']);
$fieldset->addField('dbname', 'text', ['name' => 'dbname', 'label' => __('Database Name'), 'title' => __('Database Name'), 'required' => true, 'disabled' => $isElementDisabled, 'after_element_html' => '<small>The name of the database you run in WP.</small>']);
$fieldset->addField('uname', 'text', ['label' => __('User Name'), 'title' => __('User Name'), 'name' => 'uname', 'required' => true, 'disabled' => $isElementDisabled, 'after_element_html' => '<small>Your WP MySQL username.</small>']);
$fieldset->addField('pwd', 'text', ['label' => __('Password'), 'title' => __('Password'), 'name' => 'pwd', 'required' => true, 'disabled' => $isElementDisab
|
请发表评论