Saturday, 7 July 2018

Enabling SEO in Endeca

Hi All,

I wanted to discuss SEO in Endeca, as we all know the Search Engine Optimization plays an important role in any E-commerce Site. The Url we are navigating should be simpler and user-friendly so it will get more rank in the search engines. This is the main concept behind it, In Endeca as we all know it works only on the guided Navigation we have to apply the filter, these filters are nothing but the dimensions, it is evident that the Url is getting increased like anything with this long Ids. Endeca has SEO mechanism where we can hide/encrypt these dimensionIds for better viewing and simple Urls.

There are two ways you can achieve this .

1. Spring injection.
2. Defineing in the class and property file.

I am going to discuss about the first approach. That is implementing using injecting the Spring.

You can follow the below steps to achieve it. you can also refer the CRS for implementation, we are also going to take this as the base for our implementation.

1. Copy all the Jars from the folder \CommerceReferenceStore\Store\Storefront\j2ee-apps\Storefront\store.war\WEB-INF\lib

2. Next steps are to create the following files.

endeca-seo-url-config.xml

you can find this file from CommerceReferenceStore\Store\Storefront\j2ee-apps\Storefront\store.war\WEB-INF

spring-context.xml

you can find this file from CommerceReferenceStore\Store\Storefront\j2ee-apps\Storefront\store.war\WEB-INF

3.Create a reference for these files from the web.xml as like below.

 <context-param>
    <param-name>contextConfigLocation</param-name>
    <param-value>/WEB-INF/spring-context.xml</param-value>
  </context-param>

  Once you define the context here then by default spring injection is happened through here.

4. Congratulations SEO is enabled. Now you have to define the navigation state to use this SEO URL with the property

urlFormatter=/atg/spring/FromSpring/seoUrlFormatter

5. Restart the servers Now you will start seeing the SEO URLs for all of the navigation state.

6.Whats there in endeca-seo-url-config. SeoUrlFormatter is the class where you can write a logic to parse input required, this will get called for each handler defined .parsePathInfo can be utilised for the parsing it, by the way, we write to read the request parameters.

7. Hence Extend the class SeoUrlFormatter and create your custom logic, and override the method

8. Adding descriptors.

you have define the following formatter for the dimension which you need to enable the SEO. you really have the control overSEO from here.

appendAncestors=will append the ancestors.
appendDescriptor=will append the descriptors.
appendRoot=will append the root.

you can also define the separator here.

<bean id="categoryFormatter"
        class="com.endeca.soleng.urlformatter.seo.SeoDimLocationFormatter">

    <property name="key">
      <value>product.category</value>
    </property>

    <property name="appendRoot">
      <value>false</value>
    </property>

    <property name="appendAncestors">
      <value>true</value>
    </property>

    <property name="appendDescriptor">
      <value>true</value>
    </property>

    <property name="separator">
      <value>-</value>
    </property>

    <property name="rootStringFormatter">

      <bean class="com.endeca.soleng.urlformatter.seo.StringFormatterChain">
        <property name="stringFormatters">
          <list>
            <!-- replace 'product.category' with 'Category' -->
            <bean class="com.endeca.soleng.urlformatter.seo.RegexStringFormatter">
              <property name="pattern">
                <value>product.category</value>
              </property>

              <property name="replacement">
                <value>Category</value>
              </property>

              <property name="replaceAll">
                <value>false</value>
              </property>
            </bean>

            <!-- Execute the default string formatter chain -->
            <ref bean="defaultStringFormatterChain"/>
          </list>
        </property>
      </bean>
    </property>

    <property name="dimValStringFormatter">
      <ref bean="defaultStringFormatterChain"/>
    </property>

  </bean>

9. These are the steps for the SEO Happy Learning !!!!

No comments:
Write comments