ড্রপডাউন সহ বিভাগের কাস্টম বৈশিষ্ট্য যুক্ত করুন


10

আমাকে কাস্টম এন্ট্রিবিট বিভাগে যুক্ত করতে হবে, 2 টি মান সহ একটি নির্বাচন করুন:

  • 0 - "না"
  • 1 - "হ্যাঁ"

আমি একটি মডিউল তৈরি করেছি এবং ইনস্টলেশন ফাইলটিতে এই কোডটি ব্যবহার করেছি:

$this->startSetup();
$this->addAttribute('catalog_category', 'top_brand', array(
    'group'                => 'General',
    'type'              => 'int',//can be int, varchar, decimal, text, datetime
    'backend'           => '',
    'frontend_input'    => '',
    'frontend'          => '',
    'label'             => 'Top Hersteller',
    'input'             => 'select', //text, textarea, select, file, image, multilselect
    'option' => array(
        'value' => array(

            'optionone'=> array(
                0 =>'No'),
            'optiontwo'=> array(
                0 =>'Yes')
        ),

    ),
    'default' => array(0),
    'class'             => '',
    // 'source'            => '',//this is necessary for select and multilelect, for the rest leave it blank
    'global'             => Mage_Catalog_Model_Resource_Eav_Attribute::SCOPE_GLOBAL,//scope can be SCOPE_STORE or SCOPE_GLOBAL or SCOPE_WEBSITE
    'visible'           => true,
    'frontend_class'     => '',
    'required'          => false,//or true
    'user_defined'      => true,
    'default'           => '',
    'position'            => 100,//any number will do
));
$this->endSetup();

বৈশিষ্ট্য অ্যাডমিনিস্ট্রেশন প্যানেলে উপস্থিত হয় তবে "না" এর জন্য নির্বাচনের ক্ষেত্রে মানটি 3 হয় এবং "হ্যাঁ" 4 হয়। মান 0 এবং 1 কীভাবে করা যায়?


@ ব্যবহারকারী4157: আমি এই বিষয়ে যেখানে যুক্ত করতে পারি,
মণি

উত্তর:


11

এটা চেষ্টা কর:

$this->startSetup();
$this->addAttribute('catalog_category', 'top_brand', array(
    'group'                => 'General',
    'type'              => 'int',//can be int, varchar, decimal, text, datetime
    'backend'           => '',
    'frontend_input'    => '',
    'frontend'          => '',
    'label'             => 'Top Hersteller',
    'input'             => 'select', //text, textarea, select, file, image, multilselect
    'default' => array(0),
    'class'             => '',
    'source'            => 'eav/entity_attribute_source_boolean',//this is necessary for select and multilelect, for the rest leave it blank
    'global'             => Mage_Catalog_Model_Resource_Eav_Attribute::SCOPE_GLOBAL,//scope can be SCOPE_STORE or SCOPE_GLOBAL or SCOPE_WEBSITE
    'visible'           => true,
    'frontend_class'     => '',
    'required'          => false,//or true
    'user_defined'      => true,
    'default'           => '',
    'position'            => 100,//any number will do
));
$this->endSetup();

আমি আপনার বৈশিষ্ট্য eav/entity_attribute_source_booleanহিসাবে যোগ করা sourceহয়েছে।


@ মৌরিয়াস উত্তরের জন্য ধন্যবাদ। তবে সোর্স মডেলটি কীভাবে eav/entity_attribute_source_booleanবহুবিধ বিকল্পের জন্য কাজ করবে?
স্লিমশাদ্দেদী

2
@ ভিকরাম আপনি যদি কোনও উত্সের জন্য সেই উত্স মডেলটি ব্যবহার করেন তবে আপনি 2 টি বিকল্পযুক্ত একটি মাল্টিলেসলেট দেখতে পাবেন। Yes/No
Marius

@ মারিয়াস আমি হ্যাঁ বা কোনও বৈশিষ্ট্যে যেতে চাই যেখানে আমাকে ফাইল যুক্ত করতে হবে বা এর জন্য নতুন মডিউল তৈরি করতে হবে
ম্যাজেন্টো 2

2

বিভাগে শীর্ষ_ব্রান্ড বৈশিষ্ট্য তৈরি করতে নীচের কোডটি ব্যবহার করার চেষ্টা করুন:

   $this->addAttribute( 'catalog_category', 'top_brand', array(
                'group' => 'General',
                'type' => 'tinyint',
                'backend' => '',
                'frontend' => '',
                'label' => 'Top Hersteller',
                'input' => 'boolean',
                'source' => 'eav/entity_attribute_source_boolean',
                'global' => Mage_Catalog_Model_Resource_Eav_Attribute::SCOPE_GLOBAL,
                'visible' => true,
                'required' => false,
                'user_defined' => true,
                'default' => '', 
                'unique' => false, 
            ) );

1

বিভাগ বিভাগে কাস্টম হ্যাঁ / কোনও বৈশিষ্ট্য যুক্ত করার জন্য দয়া করে মডিউলটি তৈরি করুন এবং নিম্নলিখিত কোডটি প্রবেশ করুন।

 <?php
$this->startSetup();
$this->addAttribute(Mage_Catalog_Model_Category::ENTITY, 'featured_product', array(
    'group'         => 'General Information',
    'input'         => 'select',
    'type'          => 'text',
    'label'         => 'Featured Product',
    'backend'       => '',
    'visible'       => true,
    'required'      => false,
    'visible_on_front' => true,
    'global'        => Mage_Catalog_Model_Resource_Eav_Attribute::SCOPE_GLOBAL,
    'source' => 'eav/entity_attribute_source_boolean',
));

$this->endSetup();`

দয়া করে আমার টিউটোরিয়ালটিও দেখুন।

http://www.pearlbells.co.uk/how-to-add-custom-attribute-dropdown-to-category-section-magento/ (হ্যাঁ / না) অ্যাট্রিবিউট

http://www.pearlbells.co.uk/how-to-add-custom-dropdown-attribute-to-magento-category-section/ (কাস্টম অপশন)

আমাদের সাইট ব্যবহার করে, আপনি স্বীকার করেছেন যে আপনি আমাদের কুকি নীতি এবং গোপনীয়তা নীতিটি পড়েছেন এবং বুঝতে পেরেছেন ।
Licensed under cc by-sa 3.0 with attribution required.