Child pages
  • Módulos, Reemplazo, Servicio Web
Skip to end of metadata
Go to start of metadata

You are viewing an old version of this page. View the current version.

Compare with Current View Page History

Version 1 Next »

Módulos, Reemplazo, Servicio Web: herramientas que necesitas para personalizar su tienda!

TEste artículo fue escrito por Damien Metzger, y fue publicado por primera vez el 4 de mayo de 2011, en el blog PrestaShop.

*Desde la creación de PrestaShop, nuestros módulos han sido la forma más fácil y potente para que los comerciantes personalicen sus tiendas. * Sin embargo, PrestaShop v1.4 lanzado dos nuevas posibilidades para su tienda y su negocio para ir más lejos, más rápido y ser más eficiente: vamos a presentar a la forma de reemplazar el núcleo y utilizar el servicio web.

Reemplazo del Núcleo

La sobrescritura permite a todos los desarrolladores, ya sean trabajadores independientes o si trabajan para una agencia web, cambiar el comportamiento de las clases que componen el núcleo de PrestaShop — ¡sin modificarlo ! De esta forma puede también extender el código de PrestaShop ya sea para reemplazarlo con su propio código, optimizarlo para satisfacer las necesidades de la tienda, por ejemplo, o simplemente para agregar instrucciones a los ya existentes.

Ahora con la versión 1.4, un desarrollador que desea modificar una clase PrestaShop ya no toca los archivos principales. En su lugar, crear un archivo en la carpeta / override que aparece en la base del software.

Ejemplo

Para agregar un mensaje como “Hello world!” cada vez que cargue un producto — que es perfectamente inútil, por supuesto — sólo tiene que colocar el archivo Product.php en la carpeta / override / clases y en el archivo debe escribir:

class Product extends ProductCore
{
  public function __construct($id_product = NULL, $full = false, $id_lang = NULL)
  {
    echo 'Hello World !';
    parent::__construct($id_product, $full, $id_lang);
  }
}

Por lo tanto, un técnico que trabaja en su tienda puede identificar inmediatamente las modificaciones realizadas. Por otra parte — ¡y esto es muy importante ! — actualizar PrestaShop a una versión futura, mejorada será considerablemente más fácil. Usted sólo tendrá que probar la compatibilidad de estas 'clases reemplazadas' en lugar de hacer un largo y tedioso diff con los archivos de la nueva versión.

Si usted no se siente cómodo con el concepto de Herencia (programación orientada a objetos) — la cual es necesaria para la creación de una clase hija — usted debe echar un vistazo a algunos datos en Wikipedia:http://es.wikipedia.org/wiki/Herencia_(informática)

Servicio Web

Los servicios Web están cada vez más presente en todas las áreas de la computación, son esenciales para la evolución continua de la web y por lo tanto esencial para el comercio electrónico .

When applied to PrestaShop, web services enable developers, whether familiar or not to developing with PrestaShop, to remotely retrieve and send information to the store without having access to the software code!

The technology that PrestaShop has chosen for its web service is REST. The principal advantage of this style of architecture is that it’s based on the XML format. The XML files exchanged between the client and the web service are made to be used intuitively, without first having to read several pages of documents specific to the application. A developer familiar with this technology can easily use the service, and a beginner will adapt very quickly.

PrestaShop offers developers a PHP library which allows them to use the web service without needing to make XML files by hand. Various example codes are also offered to better understand the different options.

A step-by-step guide on the web service is available on PrestaShop’s documentation site: http://doc.prestashop.com/

You can find out more about REST on Wikipedia: http://en.wikipedia.org/wiki/Representational_State_Transfer

How to choose?

While these three tools let everyone modify the behavior and add features to a store, they also have three very different applications. Choosing the right tool is therefore not to be taken lightly.

If you want to make specific changes to your store, which will never be used elsewhere, then in most cases choosing to overwrite the core--classes or controllers--will be the best solution. It is indeed the most natural and efficient way to make changes. You will nevertheless need to monitor its operation after an update, especially if corrections were made to the features you have overwritten, or if some of them are outdated.

What if instead of making changes to your one store, you intend to package and distribute your changes? For example, you may wish to place them on the website for PrestaShop Addons downloads. In this case, you need to choose a module. Using a module also helps keep things clean: its hook system lets us immediately and easily see what changes were made to every event started by the store. Someone looking at the code, in order to use or improve it, could immediately identify the module’s scope of action.

Last but not least, the web service is the best choice when the store must interact with external software. This technique not only allows the third party application to communicate with the store without adding code, but it can also protect confidential information by limiting rights.

  • No labels