Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- $attributes['custom_country'] = [
- 'group' => 'General',
- 'type' => 'int',
- 'label' => 'Country',
- 'input' => 'select',
- 'source' => VendorModuleModelResourceModelAttributeSourceCountry::class,
- 'global' => ScopedAttributeInterface::SCOPE_STORE,
- 'required' => '0',
- 'user_defined' => false,
- 'default' => '',
- 'unique' => false,
- 'position' => '50',
- 'note' => '',
- 'visible' => '1',
- 'wysiwyg_enabled' => '0',
- ];
- <?php
- /**
- * Copyright © Magento, Inc. All rights reserved.
- * See COPYING.txt for license details.
- */
- namespace VendorModuleModelResourceModelAttributeSource;
- class Custom extends MagentoEavModelEntityAttributeSourceTable {
- /**
- * @var MagentoEavModelConfig
- */
- protected $eavConfig;
- /**
- * [__construct description]
- * @param MagentoEavModelResourceModelEntityAttributeOptionCollectionFactory $attrOptionCollectionFactory [description]
- * @param MagentoEavModelResourceModelEntityAttributeOptionFactory $attrOptionFactory [description]
- * @param MagentoEavModelConfig $eavConfig [description]
- */
- public function __construct(
- MagentoEavModelResourceModelEntityAttributeOptionCollectionFactory $attrOptionCollectionFactory,
- MagentoEavModelResourceModelEntityAttributeOptionFactory $attrOptionFactory,
- MagentoEavModelConfig $eavConfig
- ) {
- $this->eavConfig = $eavConfig;
- parent::__construct($attrOptionCollectionFactory, $attrOptionFactory);
- }
- public function getAllOptions($withEmpty = true, $defaultValues = false) {
- $attribute = $this->eavConfig->getAttribute('custom_eav_entity', 'attr_code');
- return $attribute->getSource()->getAllOptions($withEmpty,$defaultValues); // here returns error
- }
- public function getOptionsArray($withEmpty = true) {
- $options = [];
- foreach ($this->getAllOptions($withEmpty) as $option) {
- $options[$option['value']] = $option['label'];
- }
- return $options;
- }
- }
- ?>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement