我试图为产品创建一个属性,该属性必须显示日期和时间日历,并且应该仅作为日期和时间格式存储在数据库中。这是我的剧本
$ eavSetup- > addAttribute (
\ Magento \ Catalog \ Model \ Product :: ENTITY ,'xyz_start_time' ,[ 'group' => 'xyz' ,'type' => 'datetime' ,'backend' => '' ,' frontend' => '' ,'label' => '开始时间' ,'input' => '日期' ,'class' => '' ,'source' =>'' ,'全局' =>
\ Magento \ Catalog \ Model \ ResourceModel \ Eav \ Attribute :: SCOPE_GLOBAL ,'visible' => true ,'required' => false ,'user_defined' => true ,'default' => '' ,'searchable' => false ,'filterable' => false ,'comparable' => false ,'visible_on_front' => false ,'used_in_product_listing' => true ,'唯一=> 错误,
'apply_to' => '简单,可配置,虚拟,捆绑,可下载' ] );
$eavSetup->addAttribute(
\Magento\Catalog\Model\Product::ENTITY,
'xyz_end_time',
[
'group' => 'xyz',
'type' => 'datetime',
'backend' => '',
'frontend' => '',
'label' => 'End Time',
'input' => 'date',
'class' => '',
'source' => '',
'global' => \Magento\Catalog\Model\ResourceModel\Eav\Attribute::SCOPE_GLOBAL,
'visible' => true,
'required' => false,
'user_defined' => true,
'default' => '',
'searchable' => false,
'filterable' => false,
'comparable' => false,
'visible_on_front' => false,
'used_in_product_listing' => true,
'unique' => false,
'apply_to' => 'simple,configurable,virtual,bundle,downloadable'
]
);
它正在创建日期选择器,其中日期仅不显示时间。
您好Shankar,您是否创建了日期时间属性?
—
Priya Ponnusamy
请在这里查看我对类似问题的回答:magento.stackexchange.com/questions/174840/…–
—
Mageinn