【发布时间】:2017-07-04 01:56:17
【问题描述】:
我一直在尝试扩展 ProductCatalogAdmin,因为那是保存我要导出的产品的 ModelAdmin。下面的代码在添加到核心代码时可以正常工作(我不想这样做),但在作为扩展添加时无法执行任何操作。
PHP
<?php
class ProductCatalogAdminExtension extends DataExtension {
public function getExportFields() {
return array(
'ID' => 'ID',
'InternalItemID' => 'InternalItemID',
'Model' => 'Model',
'Content' => 'Content',
'CostPrice' => 'CostPrice',
'BasePrice' => 'BasePrice',
'Weight' => 'Weight',
'Height' => 'Height',
'Width' => 'Width',
'Depth' => 'Depth',
'Featured' => 'Featured',
'AllowPurchase' => 'AllowPurchase',
'Popularity' => 'Popularity',
'PromoActive' => 'PromoActive',
'PromoDisplay' => 'PromoDisplay',
'PromoType' => 'PromoType',
'PromoAmount' => 'PromoAmount',
'PromoPercent' => 'PromoPercent',
'PromoStartDate' => 'PromoStartDate',
'PromoEndDate' => 'PromoEndDate',
'Image.URL' => 'Image',
'WholesalePrice' => 'WholesalePrice',
'ParentID' => 'ParentID',
'ProductCategory.ID' => 'AdditionalCategories'
);
}
}
YML
---
Name: mysite
After:
- 'framework/*'
- 'cms/*'
---
# YAML configuration for SilverStripe
# See http://doc.silverstripe.org/framework/en/topics/configuration
# Caution: Indentation through two spaces, not tabs
SSViewer:
theme: 'simple'
SiteConfig:
extensions:
- SiteConfigExtension
ProductCatalogAdmin:
extensions:
- ProductCatalogAdminExtension
有人告诉我,ModelAdmin 的 getExportFields() 没有 extend() 调用,所以我必须使用继承而不是扩展。但是,在 ModelAdmin 的继承下执行此操作似乎也无济于事。 有趣的是,我没有收到任何错误消息,它并没有真正失败。
【问题讨论】:
标签: php silverstripe silvershop