convert all documents in page type to e-product

hadi tag asked on June 21, 2015 09:48

hi,

i have many documents as article page type in my cms tree. i want convert all documents to e-product. i checked "Page type represents a product type" in E-commerce menu of page type but just if i create new page type, that is a e-product. And the rest of the document is not changed.

How to do it???

Recent Answers


Brenden Kehren answered on June 22, 2015 13:38

I believe you have to set that at the Page Type level and not just the document you already have created. If you want new Articles to be products, then go to Page Types>Articles>E-Commerce and check out the 2 options there.

1 votesVote for this answer Mark as a Correct answer

hadi tag answered on June 22, 2015 21:21 (last edited on June 23, 2015 01:08)

Thanks very much for your attention

But now I have another question. I want bind document file("docFile" column of page type) to e-product file attachment How can I do this with API code???

0 votesVote for this answer Mark as a Correct answer

hadi tag answered on June 23, 2015 10:05

Set the properties, map from original custom fields, field names on right are what your custom document type fields are :

newProduct.SKUName = doc.DocumentName;
                        newProduct.SKUPrice = ValidationHelper.GetDouble(doc.GetValue("Price"), 5000);
                        newProduct.SKUDescription = ValidationHelper.GetString(doc.GetValue("Description"), string.Empty);
                        newProduct.SKUProductType = SKUProductTypeEnum.EProduct;
                        newProduct.SKUAvailableItems = 2000;
                        newProduct.SKUValidity = ValidityEnum.Days;
                        newProduct.SKUValidFor = 2;
                        newProduct. ??? (e-product file)
                        newProduct.SetValue("SKUShortDescription", ValidationHelper.GetString(doc.GetValue("Description"), string.Empty));

for set e-product file in the above code what code I should use?

please help me.

0 votesVote for this answer Mark as a Correct answer

hadi tag answered on June 23, 2015 16:28

there is no way?

i use from this code :

Guid attGuid = ValidationHelper.GetGuid(doc.GetValue("DocFile"), Guid.Empty);
                        if (attGuid != Guid.Empty)
                        {
                            AttachmentInfo ai = DocumentHelper.GetAttachment(attGuid, _tree, SiteContext.CurrentSiteName);

                            MetaFileInfo mfi = new MetaFileInfo();
                            mfi.MetaFileObjectID = 1;
                            mfi.MetaFileObjectType = "ecommerce.sku";
                            mfi.MetaFileGroupName = "E-product";
                            mfi.MetaFileName = ai.AttachmentName;
                            mfi.MetaFileExtension = ai.AttachmentExtension;
                            mfi.MetaFileSize = ai.AttachmentSize;
                            mfi.MetaFileMimeType = ai.AttachmentMimeType;
                            mfi.MetaFileGUID = ai.AttachmentGUID;
                            mfi.MetaFileLastModified = ai.AttachmentLastModified;
                            mfi.MetaFileSiteID = ai.AttachmentSiteID;

                            MetaFileInfoProvider.SetMetaFileInfo(mfi);

                            SKUFileInfo sfi = new SKUFileInfo();
                            sfi.FileGUID = Guid.NewGuid();
                            sfi.FileSKUID = newProduct.SKUID;
                            sfi.FilePath = "~/getmetafile/" + ai.AttachmentGUID + "/" + ai.AttachmentName.Substring(0, ai.AttachmentName.IndexOf(".", System.StringComparison.Ordinal)) + ".aspx";
                            sfi.FileType = "MetaFile";
                            sfi.FileLastModified = DateTime.Now;
                            sfi.FileName = ai.AttachmentName;
                            sfi.FileMetaFileGUID = mfi.MetaFileGUID;

                            SKUFileInfoProvider.SetSKUFileInfo(sfi);
                        }

but My e-product is not yet included attachments

0 votesVote for this answer Mark as a Correct answer

evan pan answered on September 24, 2015 09:18

Hi, Hadi. Thanks for your nice sharing. But I wonder how to deal with those code? I wonder have you ever worked it out? Do I need another 3rd party manual toolkit for help? When it comes to PDF conversion process, I have another question, I wonder have you ever tried to convert pdf to other image files before? As for myself, I am testing the related PDF to image converting programs these days. Do you have experience about it? Any suggestion will be appreciated. Thanks in advance.

Best regards,
Pan

0 votesVote for this answer Mark as a Correct answer

   Please, sign in to be able to submit a new answer.