Non-Public Information in each Product
-
- Commodore (COMO)
- Posts: 433
- Joined: Wed May 28, 2008 9:42 am
- Location: Concord, NC
- Contact:
Non-Public Information in each Product
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!
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
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
to
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
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)
Code: Select all
if (!string.IsNullOrEmpty(tf.InputValue) && tf.InputField.IsMerchantField && tf.InputField.Name != "EmployeeNote")
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
- rhuffman
- Lieutenant, Jr. Grade (LT JG)
- Posts: 24
- Joined: Thu May 19, 2005 6:36 pm
- Location: Dublin, OH
- Contact:
customized fields in editcategory.aspx page
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
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
Here is the sample for adding custom field on category.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
- rhuffman
- Lieutenant, Jr. Grade (LT JG)
- Posts: 24
- Joined: Thu May 19, 2005 6:36 pm
- Location: Dublin, OH
- Contact:
Re: Non-Public Information in each Product
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
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
Make sure in your code file you have
if you have only
Then update it as mentioned above.
Code: Select all
Category _Category;
private CustomField _CustomField;
Code: Select all
Category _Category;
- rhuffman
- Lieutenant, Jr. Grade (LT JG)
- Posts: 24
- Joined: Thu May 19, 2005 6:36 pm
- Location: Dublin, OH
- Contact:
Re: Non-Public Information in each Product
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
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
Actually in order to to do so you need to make use of field name column. For example in above posted sample you have
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.
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
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.
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));
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"));
Code: Select all
_CustomField.FieldName = "FirstField";
and
_CustomField.FieldName = "SecondField";
- rhuffman
- Lieutenant, Jr. Grade (LT JG)
- Posts: 24
- Joined: Thu May 19, 2005 6:36 pm
- Location: Dublin, OH
- Contact:
Re: Non-Public Information in each Product
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.
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
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
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
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;
}
hope this helps!
__________________
s_ismail
AbleCommerce Customization
Free Plugins and Add-Ons
AbleCommerce Plugins and Add-Ons
Plugables Blog
__________________
s_ismail
AbleCommerce Customization
Free Plugins and Add-Ons
AbleCommerce Plugins and Add-Ons
Plugables Blog