setStoreIds() public method

Set store ids
public setStoreIds ( int[] $storeIds ) : Smile\ElasticsuiteThesaurus\Api\Data\ThesaurusInterface
$storeIds int[] the store ids
return Smile\ElasticsuiteThesaurus\Api\Data\ThesaurusInterface
Example #1
0
 /**
  * Init base fields :
  *  - thesaurus name
  *  - store id
  *
  * @param \Magento\Framework\Data\Form\Element\Fieldset     $fieldset The fieldset
  * @param \Smile\ElasticsuiteThesaurus\Model\Thesaurus|null $model    Current Thesaurus
  *
  * @throws \Magento\Framework\Exception\LocalizedException
  * @SuppressWarnings(PHPMD.ElseExpression)
  *
  * @return \Smile\ElasticsuiteThesaurus\Block\Adminhtml\Thesaurus\Edit\Form
  */
 private function initBaseFields($fieldset, $model)
 {
     $fieldset->addField('name', 'text', ['name' => 'name', 'label' => __('Thesaurus Name'), 'title' => __('Thesaurus Name'), 'required' => true]);
     $fieldset->addField('is_active', 'select', ['name' => 'is_active', 'label' => __('Active'), 'title' => __('Active'), 'values' => $this->booleanSource->toOptionArray()]);
     if (!$this->_storeManager->isSingleStoreMode()) {
         $field = $fieldset->addField('store_id', 'multiselect', ['name' => 'stores[]', 'label' => __('Store'), 'title' => __('Store'), 'values' => $this->systemStore->getStoreValuesForForm(false, true), 'required' => true]);
         $renderer = $this->getLayout()->createBlock('Magento\\Backend\\Block\\Store\\Switcher\\Form\\Renderer\\Fieldset\\Element');
         $field->setRenderer($renderer);
     } else {
         $fieldset->addField('store_id', 'hidden', ['name' => 'store_id']);
         $model->setStoreIds([$this->_storeManager->getStore(true)->getId()]);
     }
     return $this;
 }