2000 Posts in 532 Topics by 435 members
E-Commerce Modules
SilverStripe Forums » E-Commerce Modules » How to add a new field to the product.php file?
Discuss about the various e-commerce modules available:
Ecommerce, SS Shop, SilverCart and SwipeStripe
Alternatively, have a look the shared mailinglist.
Moderators: martimiz, Nicolaas, Howard, Sean, Ryan M., biapar, Willr, Ingo, Jedateach, swaiba, simon_w
|
Page:
1
|
Go to End | |
| Author | Topic: | 1616 Views |
-
How to add a new field to the product.php file?

16 February 2009 at 3:41pm
After I added a new field in the product page, I got a problem to save the content. I got the Content Save Error.
I tried to change some .SS files but still the same error.
What else i should chage?
$fields->addFieldToTab("Root.Content.Main", new TextField("Weight", "Weight (kg)", "", 12));
$fields->addFieldToTab("Root.Content.Main", new TextField("Price", "Price", "", 12));
$fields->addFieldToTab("Root.Content.Main", new TextField("Model", "Author", "", 50));
$fields->addFieldToTab("Root.Content.Main", new TextField("Workshop", "Speaker", "", 50)); -
Re: How to add a new field to the product.php file?

15 August 2009 at 7:14am
I would also like to know how to do this.
I've added extra fields, and after doing db/build, I don't get any errors after saving and publishing. However, the new fields won't show up on the product page.
Anyone?
Thanks
Jay -
Re: How to add a new field to the product.php file?

18 August 2009 at 3:15pm
you need to make sure the fields are added in the model as well.
EG:static $db = array(
'Price' => 'Currency',
'Weight' => 'Decimal(9,2)',
'Model' => 'Varchar',
'FeaturedProduct' => 'Boolean',
'AllowPurchase' => 'Boolean',
"InternalItemID" => "Varchar(30)",
);That way SilverStripe will know where to save the data.
-
Re: How to add a new field to the product.php file?

19 August 2009 at 1:29am
Hey Bennett, thanks for your reply. I have done this already.. I added the following line to that array.
'Year' => 'Varchar',
And the following line to the getCMSFields function.
$fields->addFieldToTab("Root.Content.Main", new TextField("Year", "Year", "", 50));
I can see the field when I want to create a new product, I can type in the YEAR, I can save it and publish it, but when I go to the product page, "Year" is not displayed.
Do you know why this is happening?
Thank you
Jay! -
Re: How to add a new field to the product.php file?

19 August 2009 at 7:58am
Hi Jay Dee,
Try (something like) this in your template
<div class="year">
Year: $Year
</div>$Year will / should display the year data.
Paul
| 1616 Views | ||
|
Page:
1
|
Go to Top |



