Page 1 of 1
Non-Public Information in each Product
Posted: Wed Oct 22, 2008 3:39 pm
by Robbie@FireFold
Hey Guys,
I need a box in each product that would not be visible to the public/customers. Something the size of the summary box where my employee's could write information such as 'changed to xxxx, not coming back, etc.'
I think this is a pretty easy one. Hopefully someone can cook something up!
Re: Non-Public Information in each Product
Posted: Thu Oct 23, 2008 4:58 am
by mazhar
First Approach
One possibility is to use the the Product Templates, create a new merchant field of type text area then update the
ConLib/ProductCustomFieldsDialog control so that it doesn't render that specific information. Need to change the following statement
Code: Select all
if (!string.IsNullOrEmpty(tf.InputValue) && tf.InputField.IsMerchantField)
to
Code: Select all
if (!string.IsNullOrEmpty(tf.InputValue) && tf.InputField.IsMerchantField && tf.InputField.Name != "EmployeeNote")
Where
EmployeeNote is the field name. With this approach obviously you need to apply the product template on all of your products.
Second Approach
The second possibility is to use CustomFields and save extra information there for each product. This modification will only change the
Admin/Products/EditProduct.aspx page. With this approach you need no extra effort like to apply product template etc. Instead of guiding where to place the code I am attaching the test sample created here. You can easily find the changes in the in the page. Just look for
_CustomField member in the code and in aspx file check the newly added textbox called
EmployeeNote. Here is the modified page
customized fields in editcategory.aspx page
Posted: Tue Jul 27, 2010 5:31 pm
by rhuffman
Mazhar:
I incorporated the above on the editproduct.aspx page and it worked perfectly! Thank you.
I attempted, using the same logic, to add the same, to the editcategory.aspx page and it kept blowing up regardless of what I did.
Would it be possbile for you to submit a similar example for the editcategory.aspx page? If we can incorporate custom fields in the editcategory.aspx we will 95% on our way to going live with Able 7.x.
Your help would be greatly appreciated.
Ray Huffman
Darby Creek Trading Co.
www.DarbyCreekTrading.com
Re: customized fields in editcategory.aspx page
Posted: Wed Jul 28, 2010 6:11 am
by mazhar
rhuffman wrote:Mazhar:
I incorporated the above on the editproduct.aspx page and it worked perfectly! Thank you.
I attempted, using the same logic, to add the same, to the editcategory.aspx page and it kept blowing up regardless of what I did.
Would it be possbile for you to submit a similar example for the editcategory.aspx page? If we can incorporate custom fields in the editcategory.aspx we will 95% on our way to going live with Able 7.x.
Your help would be greatly appreciated.
Ray Huffman
Darby Creek Trading Co.
http://www.DarbyCreekTrading.com
Here is the sample for adding custom field on category.
Re: Non-Public Information in each Product
Posted: Wed Jul 28, 2010 8:02 am
by rhuffman
Mazhar
When through both files and copied the code that was different for botth aspx and aspx.cs
When we tried to edit the category we got the following error:
Server Error in '/' Application.
--------------------------------------------------------------------------------
Compilation Error
Description: An error occurred during the compilation of a resource required to service this request. Please review the following specific error details and modify your source code appropriately.
Compiler Error Message: CS0103: The name '_CustomField' does not exist in the current context
Source Error:
Line 39: CustomFieldCollection customFields = CustomFieldDataSource.LoadForCriteria(String.Format(" StoreId = {0} AND TableName='{1}' AND ForeignKeyId={2} ", Token.Instance.Store.StoreId, "ac_Categories", _Category.CategoryId));
Line 40: if (customFields != null && customFields.Count > 0)
Line 41: _CustomField = customFields[0];
Line 42:
Line 43:
Source File: c:\AbleCommerce\Admin\Catalog\EditCategory.aspx.cs Line: 41
Any suggestions?
Thank you.
Ray Huffman
Darby Creek Trading Co.
www.DarbyCreekTrading.com
Re: Non-Public Information in each Product
Posted: Wed Jul 28, 2010 8:31 am
by mazhar
Make sure in your code file you have
Code: Select all
Category _Category;
private CustomField _CustomField;
if you have only
Then update it as mentioned above.
Re: Non-Public Information in each Product
Posted: Wed Jul 28, 2010 11:20 am
by rhuffman
Mashar:
Thank you! That worked.
Ray Huffman
Darby Creek Trading
www.DarbyCreekTrading.com
Re: Non-Public Information in each Product
Posted: Wed Jul 28, 2010 2:06 pm
by rhuffman
Mashar:
As previously stated, you solution worked. However, when I try to add an additional custom field and try to duplicate the previously code, I can either update one custom field or the other, but not both. If you could provide an example with 2 custom fields - I think my problem is in the update statement or declaration - not really sure. I just hacking my way throuht it (not very sucessfully) I would hope I could figure out with customfield3, customfield4, with you fine examples.
I really appreciate your help.
Thank you.
Ray Huffman
Darby Creek Trading Co.
www.DarbyCreekTrading.com
Re: Non-Public Information in each Product
Posted: Thu Jul 29, 2010 4:27 am
by mazhar
Actually in order to to do so you need to make use of field name column. For example in above posted sample you have
Code: Select all
CustomFieldCollection customFields = CustomFieldDataSource.LoadForCriteria(String.Format(" StoreId = {0} AND TableName='{1}' AND ForeignKeyId={2}", Token.Instance.Store.StoreId, "ac_Categories", _Category.CategoryId));
You need to update it something like this where
FirstField is name of first custom field. Similarly you could load other field for same category just by providing corresponding custom field name in query.
Code: Select all
CustomFieldCollection customFields = CustomFieldDataSource.LoadForCriteria(String.Format(" StoreId = {0} AND TableName='{1}' AND ForeignKeyId={2} AND FieldName={3}", Token.Instance.Store.StoreId, "ac_Categories", _Category.CategoryId,"FirstField"));
On the other hand when it comes to creating/saving new custom field you need to provide its name when saving custom field object. For example
Code: Select all
_CustomField.FieldName = "FirstField";
and
_CustomField.FieldName = "SecondField";
In above sample you can see CEN is used as custom field name. You are having problem when you try to add two fields because code is not taking care of field name so it always loads/updates single CEN custom field.
Re: Non-Public Information in each Product
Posted: Thu Jul 29, 2010 2:08 pm
by rhuffman
Mazhar:
I have spend several hours trying to add an additonal second custom field with no sucess.
I have used every combination of code I can think of.
Can you kindly provid a full EditCategory.aspx.cs sample with two custom fields.
Although I am not a programmer, I am an average "hack" but this one has me baffled.
Thank you.
Re: Non-Public Information in each Product
Posted: Wed Nov 24, 2010 1:24 pm
by dappy2
I know this topic is a bit old but I'm stuck.
I've successfully added a custom field to the editcategory.aspx using the above code. However, I want to pull that custom field into HTML in the code behind of the pages and I can't seem to do it. I was looking at the ProductCustomFieldsDialog file but it seems vastly different to what I need to do.
I'm trying to implement some SEO features like specifying a custom link title (<a href="someurl" title="CUSTOMFIELD"). I want to pull this in various places listed in order from most important to least:
Navigation (I'm using the simple category list that renders nexted <ul>'s) AllCategories.ascx - that's what my file is called, not sure if that's in Able or not.
CategoryDetailsPage.ascx
CategoryBreadCrumbs.ascx
I'm just thoroughly confused and eventually I'd like to add this to all the products too in order to pull SEO optimized title attributes on all links.
Thanks,
Dappy
Re: Non-Public Information in each Product
Posted: Wed Dec 01, 2010 8:52 am
by s_ismail
You can get custom fields value like this
Code: Select all
protected void Page_Load(object sender, EventArgs e)
{
string customFieldValue = GetCustomFieldValue(CategoryId, "CUSTOM_FIELD_NAME");
}
public string GetCustomFieldValue(int categoryId, string customFieldName)
{
CustomFieldCollection customFields = CustomFieldDataSource.LoadForCriteria(" TableName='ac_Categories' AND ForeignKeyId=" + categoryId);
foreach (CustomField customfield in customFields)
{
if (customfield.FieldName == customFieldName)
return customfield.FieldValue;
}
return string.Empty;
}