Retrieving one product template details into other template

For general questions and discussions specific to the AbleCommerce 7.0 Asp.Net product.
Post Reply
Carolharry
Commander (CMDR)
Commander (CMDR)
Posts: 121
Joined: Wed Dec 17, 2008 9:13 am

Retrieving one product template details into other template

Post by Carolharry » Mon Jan 19, 2009 8:24 am

I have create a template "Distribution Types" with a list box in customer filed having 3 choices.

Now I want to pull that product template details(the list box choices) into a new product template "Tests"

So basically Tests will have already configured "DistributionTypes" for customers and other fileds if I want to add some more.

Does anyone have idea how to accomplish this. Any hints?

Thanks alot advance.
Carol

User avatar
mazhar
Master Yoda
Master Yoda
Posts: 5084
Joined: Wed Jul 09, 2008 8:21 am
Contact:

Re: Retrieving one product template details into other template

Post by mazhar » Wed Jan 21, 2009 8:14 am

Please explain the question. I am not clear. If you want to create the clone of a product template, then try this.

Load the desired product template.
Change its name
change its id to 0
call save method.

Code: Select all

ProductTemplateCollection productTemplates = ProductTemplateDataSource.LoadForCriteria("Name = 'Distribution Types' ");
        if (productTemplates != null && productTemplates.Count > 0)
        {
            ProductTemplate productTemplate = productTemplates[0];
            productTemplate.Name = "Tests";
            productTemplate.ProductTemplateId = 0;
            productTemplate.Save();
        }

Carolharry
Commander (CMDR)
Commander (CMDR)
Posts: 121
Joined: Wed Dec 17, 2008 9:13 am

Re: Retrieving one product template details into other template

Post by Carolharry » Thu Jan 22, 2009 3:12 pm

Hi Mazhar,

I attached a file with screen shots. Hope you will get better understanding of my requirement.


Thanks alot,
Carol

User avatar
mazhar
Master Yoda
Master Yoda
Posts: 5084
Joined: Wed Jul 09, 2008 8:21 am
Contact:

Re: Retrieving one product template details into other template

Post by mazhar » Fri Jan 23, 2009 11:34 am

I don't think so that this would be any easy job to make product templates work as you desired and may take a significant amount of customization time. I think it would be more helpful and will make the things easy if you put that common information some where else and customize the display pages to show that information. You can keep other product specific information in its product template. For example you said that you will only make use of the admin fields, it means customer will always see the read only information for product.

So you can create some store settings for the name of these fields. Then you can customize edit product page in some way that it should ask for that common information for all products and save it for example in ac_CustomFields.
Then you need to customize the product details page and put some code to render that common information.

Carolharry
Commander (CMDR)
Commander (CMDR)
Posts: 121
Joined: Wed Dec 17, 2008 9:13 am

Re: Retrieving one product template details into other template

Post by Carolharry » Thu Jan 29, 2009 8:00 am

Hi Mazhar,

I managed adding master template fields(distribution types) to every new product template added by writing following code under add method of product template

protected void AddButton_Click(object sender, EventArgs e)
{
if (Page.IsValid)
{
ProductTemplate pt = new ProductTemplate();
pt.Name = AddName.Text;
pt.Save();


InputFieldCollection _KinputFields;
_KinputFields = InputFieldDataSource.LoadForProductTemplate(5, InputFieldDataSource.InputFieldScope.Merchant);
foreach (InputField _KinputField in _KinputFields)
{
InputField Kcopy;
Kcopy = InputField.Copy(_KinputField.InputFieldId, true);
Kcopy.ProductTemplateId = pt.productTemplateid
_Kproducttemplate.InputFields.Add(Kcopy);
_Kproducttemplate.InputFields.Save();
}

Response.Redirect("EditProductTemplate.aspx?ProductTemplateId=" + pt.ProductTemplateId.ToString());
}
}

Now whenever new template is added, the fields in product template with Id 5 will be added to it. At the same time I will write code to maintain synchronization of when a choice is delete from master template, I will delete input fields from all product template which has that choice. Same goes for when a choice is added.

But can you please tell me where these relations are stored like, for particular product template Merchant field choices is in checkboxlist type and has so and so input fields present.
Where is commercebuilder API retrieving from. I don't see such data tables in ablecommerce database.

Thanks alot,
Carol

User avatar
mazhar
Master Yoda
Master Yoda
Posts: 5084
Joined: Wed Jul 09, 2008 8:21 am
Contact:

Re: Retrieving one product template details into other template

Post by mazhar » Thu Jan 29, 2009 8:07 am

Check the ac_InputChoices, ac_InputFields, ac_ProductTemplateFields tables.

Post Reply