コード例 #1
0
        public XElement CreateSEOInfoElement(Entity entity)
        {
            XElement seoInfo = new XElement("SeoInfo");

            foreach (KeyValuePair <CultureInfo, CultureInfo> culturePair in _config.LanguageMapping)
            {
                string uri         = _pimFieldAdapter.GetFieldValue(entity, "seouri", culturePair.Value);
                string title       = _pimFieldAdapter.GetFieldValue(entity, "seotitle", culturePair.Value);
                string description = _pimFieldAdapter.GetFieldValue(entity, "seodescription", culturePair.Value);
                string keywords    = _pimFieldAdapter.GetFieldValue(entity, "seokeywords", culturePair.Value);
                string urisegment  = _pimFieldAdapter.GetFieldValue(entity, "seourisegment", culturePair.Value);

                if (string.IsNullOrEmpty(uri) &&
                    string.IsNullOrEmpty(title) &&
                    string.IsNullOrEmpty(description) &&
                    string.IsNullOrEmpty(keywords) &&
                    string.IsNullOrEmpty(urisegment))
                {
                    continue;
                }

                seoInfo.Add(
                    new XElement("Seo",
                                 new XElement("LanguageCode", culturePair.Key.Name.ToLower()),
                                 new XElement("Uri", uri),
                                 new XElement("Title", title),
                                 new XElement("Description", description),
                                 new XElement("Keywords", keywords),
                                 new XElement("UriSegment", urisegment)));
            }

            return(seoInfo);
        }