Loading...
Close
Warning
Cookies are used on this site to provide the best user experience. If you continue, we assume that you agree to receive cookies from this site. OK

How to make CS-Cart add-on | CS-Cart import/export module.

March 25th, 2018

Here, we are going to describe the CS-Cart module creation and the method how to expand the standard import/export functionality on the e-commerce platform.

Of course, import and export aren’t perfect in CS-Cart, though CS-Cart is quite a good system for building an e-commerce website, sometimes CS-Cart import/export feature is required to be modified to reach special business aims. There are lots of features what you can be lack of in the standard base as every business is unique and clients have different demands on export/import functionality. Usually, online shop owners order or download ready-to-use modules that solve the technical issues by managing the store.

For example, some years ago we made module “Extended import” that allows fast and easy import of supplier's file where the field titles do not match with titles applied in CS-Cart.

cs-cart import

But, there is a plenty of issues for standard functionality improvement. It's a very often case when suppliers have price lists in XML or XMLX formats and they send these documents to resellers. But, CS-Cart works only with CVS formats. The shop administrator has to adapt it to CS-Cart standards manually by spending much time on this routine work. The simple CS-Cart modification can easily resolve this issue in CS-Cart export/import process. 

Or, there is another example of CS-Cart add-on that adds an extra text field in product card in the administrative panel and the data contained in this field are suitable for import/export. We took to pieces how this add-on looks like and we will know how to change the base functionality of import/export in CS-Cart store.

First of all, CS-Cart add-on is always the set of files that complete each other. There are recorded commands for CS-Cart process calls in these files. There are several folders with subfolders and files even in the simplest add-on.

The folder of Some_value addon contains (red - files, black - folders)

App 
  Addons 
      Some_value 
          Schemas 
              Exim 
                 products.post
           addon.xml

Design 
  Backend 
     Templates 
          Addons 
              some _value 
                  Hooks 
                         Products 
                                detailed_content.post 

Var 
  Langs 
     En 
       Addons 
           some_value.po 
     Ru 
       Addons 
            some_value.po 
  Theme_depository 
    Responsive 
       Templates 
           Addons 
             Some_value 
                   Hooks 
                      Products 
                          qty.pre 

As we see there are only 6 files with programme code in 3 main folders (App, Design, Var) of the add-on. This is the structure of the simplest module. This module adds the text field on the product page. Then the data from this field can be exported and imported.

There are should be any nested folders with the name app/addons/ in any module. Here are stores the base module files except for the theme files.

Certainly, you may create your own folders and files, but its names and structure should be clearly matched the accepted CS-Cart structure.

We see the folder schemas/exim in our simple add-on. Files, included in Exim folder, are responsible for import/export in CS-Cart. The file products.post that is placed in Exim folder.

This case it is a schema, that describes the set of the rules for import, that should be taken into an account by the controller while the code processing.

PHP- controller is the main PHP file. This is a link between a user, the database and the CS-Cart theme. The base functions of CS-Cart are running in controllers. No page of the online store can be displayed without controllers' work. The extension of controllers is made with the help of pre-controllers and post-controllers. Pre-controllers and post-controllers are run before and after the main code consequently. 

This case we are working with the extension .post and our code that is contained in this PHP file will be launched after the run of the main code. Let's examine the code in the file, there is the variable $schema in the code. The data is already contained in the code, but we add more data ([some value]) and return the value of the variable. In other words, we come to finish of function operation and pass the managing to the stroke where this function has been called.

Addon.xml is a file that contains the module information that is required for its installation and removal. This file is put in the app folder.

There are only 14 lines in this file and the main parameters of the additional field and the schema of this module are described in this file.

Operator Alter Table gives the ability to change the structure of the existing table in the database. In this instance, the operator adds (add) and deletes (drop column) new field with the name some_value. The data type is varchar 225 text characters long. The value of this field isn’t null by default.

Go to the design folder that is responsible for the administration panel theme. Here is the schema where the new feature of the product page is placed (The field some_value with data) in the admin panel. Here is the result we get in the admin panel.

Working with the code in file detailed_content.post

where the function include file is the connection of the file common/subheader.tpl to the code described in the image above. Further, we describe, using the HTML code, where and how the required field will be shown on the product page in the admin panel.

Go to var folder where are we have 2 folders: langs and theme_repository. Subfolders for different languages are contained in the folder lang. Here we see ru and en subfolders for Russian and English languages. If you want to translate the module into any language, you should create the folder marking with the name of your language, and place it in the folder lang. Also, copy the file some_value.po and make some changes due to the required language.

Replace the Russian translation with your own phrases and save the document. Now you have localised the module to the required language.

File in the folder themes_repository is one more schema - qty.pre that proceeds before the main code.

This schema lets displaying the value on the storefront. Exactly this code shows the value on the product page on the certain place.

All files and folders that are mentioned above, should be stored in the zip archive. Now the addon can be installed in two steps with the help of administrative panel.

As soon as you install the addon using the CS-Cart admin panel, all new and changed files and folders will appear on a server and the module will join the base code CS-Cart.

 

 

The Alt-team developers have worked creating the additional modifications and off the shelf solutions for CS-Cart and Magento since 2010. It made us one of the most successful CS-Cart developer's team in e-Commerce area.

You can always drop us a message to learn the cost of any CS-Cart modification for the online store.

It’s possible you may be interested in other eCommerce articles on our blog.

 

 

Up