Constantes y variables para Prestashop 1.7

Constantes y variables para Prestashop 1.7

Constantes y variables para Prestashop 1.7.- Si estamos deseando personalizar nuestra tienda es seguro que lleguemos a este tema de conocer que son las constantes para programas por ejemplo unas consultas SQL personalizada, conocer el prefijo de las tablas, la ruta de imágenes, etc.

Entonces debemos de conocer acerca de las contantes predefinidas que ofrece Prestashop y las variables Smarty para trabajar en los ficheros TPL.

Índice

    ¿Qué constante usar en sus controladores en Prestashop?

    Esto depende del área que estemos programado, por ejemplo, si deseamos obtener la ruta de las imágenes de nuestros productos entonces debemos de usar: la constante "_PS_IMG_DIR_"

    ¿Cuál usar _PS_ROOT_DIR_ o __PS_BASE_URI__ en Prestashop?

    Primero hay que saber qué resultado da tal constante, por ejemplo:

    • La contante _PS_ROOT_DIR_.- Es para el lenguaje PHP y muestra la ruta absoluta: /var/www/html/prestashop
    • La constante __PS_BASE_URI__ .- Muestra la base absoluta de nuestra tienda y es relativa.

    ¿Cuál elegir en las plantillas Smarty {$urls.img_dir} o {$img_dir}?

    • La primera {$urls.img_dir} muestra la ruta de imagen personalizada, porque hace uso de la URL y puede ser por ejemplo las imágenes de nuestro tema.
    • La segunda {$img_dir} es la ruta absoluta de imágenes de nuestra tienda. "/img"

    ¿Qué constante usar y qué variables están disponibles?

    Son preguntas muy comunes en el mundo de la programación en Prestashop, mi recomendación es conocer todas las constantes y que representa, además de conocer las principales variables por defecto que posee Prestashop.

    Además, recuerden que se puede crear variables Smarty personalizada.

    En este artículo le brindaremos a través de una tabla las diferentes constantes y variables de PHP, Smarty JavaScript y Twig a su disposición y las presenta con ejemplos y contextos visuales.

    Datos importantes acerca de las variables y constantes en Prestashop

    La presente guía asume que usted tiene o gestiona:

    • Una tienda similar a https://myshop.com/prefix/
    • Está alojado en su servidor en /var/www/html/prestashop/.
    • Tema: mi_tema
    • Directorio de administración: admin-dev
    • Idiomas: PHP, Smarty, JavaScript
    • Tipos de conceptos:
        • Ruta completa: ruta completa en su servidor (por ejemplo, /var/www/html/prestashop/README.md)
        • Ruta relativa: ruta relativa desde el directorio de instalación de prestashop (por ejemplo, /classes)
        • URL completa: URL completa, incluido el protocolo (http/https) (por ejemplo, http://myshop.com/prefix/)
        • URL relativa: URL relativa del directorio de instalación de prestashop (por ejemplo, /img/c)
        • Disponible en recepción
      • Acceso a frontoffice
      • Acceso a backoffice

    Constantes y variables para Prestashop 1.7 [PHP, Smarty, JavaScript, Twig]

    A continuación, utilice el buscador para encontrar sus constantes o variables:

    NombreLeng.EjemploTipoDestino
    _PS_ROOT_DIR_PHP/var/www/html/prestashopfull pathfront + back
    _PS_CORE_DIR_PHP/var/www/html/prestashopfull pathfront + back
    _PS_ADMIN_DIR_PHP/var/www/html/prestashop/admin-devfull pathback
    basename(PS_ADMIN_DIR)PHPadmin-devfolder nameback
    __PS_BASE_URI__PHP/prefix/relative url
    _PS_MODE_DEV_PHPtrueboolfront + back
    _PS_DEBUG_SQL_PHPtrueboolfront + back
    _PS_THEME_URI_PHP
    _PS_DEBUG_PROFILING_PHPtrueboolfront + back
    _PS_MODE_DEMO_PHPtrueboolfront + back
    _PS_ALL_THEMES_DIR_PHP/var/www/html/prestashop/themes/front + back
    _PS_BO_ALL_THEMES_DIR_PHP/var/www/html/prestashop/Backoffice/themes/front + back
    _PS_CACHE_DIR_PHP/var/www/html/prestashop/app/cache/dev/front + back
    _PS_CONFIG_DIR_PHP/var/www/html/prestashop/config/front + back
    _PS_CUSTOM_CONFIG_FILE_PHP/var/www/html/prestashop/config/settings_custom.inc.phpfront + back
    _PS_CLASS_DIR_PHP/var/www/html/prestashop/classes/front + back
    _PS_DOWNLOAD_DIR_PHP/var/www/html/prestashop/download/front + back
    _PS_MAIL_DIR_PHP/var/www/html/prestashop/mails/front + back
    _PS_MODULE_DIR_PHP/var/www/html/prestashop/modules/front + back
    _PS_OVERRIDE_DIR_PHP/var/www/html/prestashop/override/front + back
    _PS_PDF_DIR_PHP/var/www/html/prestashop/pdf/front + back
    _PS_TRANSLATIONS_DIR_PHP/var/www/html/prestashop/translations/front + back
    _PS_UPLOAD_DIR_PHP/var/www/html/prestashop/upload/front + back
    _PS_CONTROLLER_DIR_PHP/var/www/html/prestashop/controllers/front + back
    _PS_ADMIN_CONTROLLER_DIR_PHP/var/www/html/prestashop/controllers/admin/front + back
    _PS_FRONT_CONTROLLER_DIR_PHP/var/www/html/prestashop/controllers/front/front + back
    _PS_TOOL_DIR_PHP/var/www/html/prestashop/tools/front + back
    _PS_GEOIP_DIR_PHP/var/www/html/prestashop/app/Resources/geoip/front + back
    _PS_GEOIP_CITY_FILE_PHPGeoLite2-City.mmdbfront + back
    _PS_VENDOR_DIR_PHP/var/www/html/prestashop/vendor/front + back
    _PS_PEAR_XML_PARSER_PATH_PHP/var/www/html/prestashop/tools/pear_xml_parser/front + back
    _PS_SWIFT_DIR_PHP/var/www/html/prestashop/tools/swift/front + back
    _PS_TAASC_PATH_PHP/var/www/html/prestashop/tools/taasc/front + back
    _PS_TCPDF_PATH_PHP/var/www/html/prestashop/tools/tcpdf/front + back
    _PS_IMG_DIR_PHP/var/www/html/prestashop/img/front + back
    _PS_CORE_IMG_DIR_PHP/var/www/html/prestashop/img/front + back
    _PS_CAT_IMG_DIR_PHP/var/www/html/prestashop/img/c/front + back
    _PS_COL_IMG_DIR_PHP/var/www/html/prestashop/img/co/front + back
    _PS_EMPLOYEE_IMG_DIR_PHP/var/www/html/prestashop/img/e/front + back
    _PS_GENDERS_DIR_PHP/var/www/html/prestashop/img/genders/front + back
    _PS_LANG_IMG_DIR_PHP/var/www/html/prestashop/img/l/front + back
    _PS_MANU_IMG_DIR_PHP/var/www/html/prestashop/img/m/front + back
    _PS_ORDER_STATE_IMG_DIR_PHP/var/www/html/prestashop/img/os/front + back
    _PS_PROD_IMG_DIR_PHP/var/www/html/prestashop/img/p/front + back
    _PS_SHIP_IMG_DIR_PHP/var/www/html/prestashop/img/s/front + back
    _PS_STORE_IMG_DIR_PHP/var/www/html/prestashop/img/st/front + back
    _PS_SUPP_IMG_DIR_PHP/var/www/html/prestashop/img/su/front + back
    _PS_TMP_IMG_DIR_PHP/var/www/html/prestashop/img/tmp/front + back
    _PS_CACHEFS_DIRECTORY_PHP/var/www/html/prestashop/cache/cachefs/front + back
    _PS_JQUERY_VERSION_PHP1.11.0front + back
    _PS_CACHE_CA_CERT_FILE_PHP/var/www/html/prestashop/app/cache/dev/cacert.pemfront + back
    _PS_DEFAULT_THEME_NAME_PHPclassicfront + back
    _PS_THEME_DIR_PHP/var/www/html/prestashop/themes/my_theme/full pathfront + back
    _PS_THEME_URI_PHP/prefix/themes/my_theme/relative urlfront + back
    _PS_PARENT_THEME_DIR_PHP/var/www/html/prestashop/themes/classic/full pathfront + back
    _PS_PARENT_THEME_URI_PHP/prefix/themes/classic/relative urlfront + back
    _THEMES_DIR_PHP/prefix/themes/relative urlfront + back
    _THEME_DIR_PHP/prefix/themes/my_theme/relative urlfront + back
    _THEME_IMG_DIR_PHP/prefix/themes/my_theme/assets/img/relative urlfront + back
    _THEME_CSS_DIR_PHP/prefix/themes/my_theme/assets/css/relative urlfront + back
    _THEME_JS_DIR_PHP/prefix/themes/my_theme/assets/js/relative urlfront + back
    _PS_IMG_PHP/prefix/img/relative urlfront + back
    _PS_ADMIN_IMG_PHP/prefix/img/admin/relative urlfront + back
    _PS_TMP_IMG_PHP/prefix/img/tmp/relative urlfront + back
    _THEME_CAT_DIR_PHP/prefix/img/c/relative urlfront + back
    _THEME_PROD_DIR_PHP/prefix/img/p/relative urlfront + back
    _THEME_MANU_DIR_PHP/prefix/img/m/relative urlfront + back
    _THEME_SUP_DIR_PHP/prefix/img/su/relative urlfront + back
    _THEME_SHIP_DIR_PHP/prefix/img/s/relative urlfront + back
    _THEME_STORE_DIR_PHP/prefix/img/st/relative urlfront + back
    _THEME_LANG_DIR_PHP/prefix/img/l/relative urlfront + back
    _THEME_COL_DIR_PHP/prefix/img/co/relative urlfront + back
    _THEME_GENDERS_DIR_PHP/prefix/img/genders/relative urlfront + back
    _PS_PROD_IMG_PHP/prefix/img/p/relative urlfront + back
    _PS_JS_DIR_PHP/prefix/js/relative urlfront + back
    _PS_CSS_DIR_PHP/prefix/css/relative urlfront + back
    _THEME_PROD_PIC_DIR_PHP/prefix/upload/relative urlfront + back
    _MAIL_DIR_PHP/prefix/mails/relative urlfront + back
    _MODULE_DIR_PHP/prefix/modules/relative urlfront + back
    \Context::getContext()PHPObject of class ContextObjectfront + back
    _DB_PREFIX_PHPYour SQL table prefix
    {$baseAdminUrl}Smarty/prefix/admin-dev/relative urlback
    {$base_url}Smartyhttps://myshop.com/prefix/full urlback
    {$context_mode}Smarty
    {$logged_on_addons}Smarty
    {$can_import}Smarty
    {$table}Smartycustomersback
    {$current}Smartyindex.php?controller=AdminCustomerback
    {$token}SmartyToken used in the current URLback
    {$host_mode}Smarty
    {$stock_management}Smarty
    {$no_order_tip}Smarty
    {$no_customer_tip}Smarty
    {$no_customer_message_tip}Smarty
    {$GA_ACCOUNT_ID}Smarty
    {$displayBackOfficeHeader}Smarty
    {$displayBackOfficeTop}Smarty
    {$submit_form_ajax}Smarty
    {$breadcrumbs2}Smarty
    {$quick_access_current_link_name}Smarty
    {$quick_access_current_link_icon}Smarty
    {$navigationPipe}Smarty
    {$img_base_path}Smarty/admin-dev/back
    {$check_url_fopen}Smarty
    {$check_openssl}Smarty
    {$add_permission}Smarty
    {$addons_register_link}Smarty
    {$addons_forgot_password_link}Smarty
    {$help_link}Smarty
    {$maintenance_mode}Smarty
    {$debug_mode}Smarty
    {$lite_display}Smarty
    {$url_post}Smartyindex.php?controller=AdminCustomer&token={token}back
    {$show_page_header_toolbar}Smarty
    {$page_header_toolbar_title}Smarty
    {$title}Smarty
    {$toolbar_btn}Smarty
    {$page_header_toolbar_btn}Smarty
    {$show_new_orders}Smarty
    {$show_new_customers}Smarty
    {$show_new_messages}Smarty
    {$help_box}Smarty
    {$round_mode}Smarty
    {$brightness}Smarty
    {$bo_width}Smarty
    {$bo_color}Smarty
    {$employee}SmartyObject of class EmployeeObjectback
    {$search_type}Smarty
    {$bo_query}Smarty
    {$quick_access}Smarty
    {$multi_shop}Smarty
    {$shop_list}Smarty
    {$current_shop_name}Smarty‘My Shop’
    {$shop}SmartyObject of class ShopObjectback
    {$shop_group}SmartyObject of class ShopGroupObjectback
    {$is_multishop}Smarty
    {$multishop_context}Smarty
    {$default_tab_link}Smarty
    {$login_link}Smarty
    {$collapse_menu}Smarty
    {$img_dir}Smarty/prefix/img/back
    {$iso}Smartyfrback
    {$class_name}SmartyAdminCustomerControllerback
    {$iso_user}Smartyfrback
    {$country_iso_code}SmartyFRback
    {$version}Smarty1.7.2.4back
    {$lang_iso}Smartyfrback
    {$full_language_code}Smartyfrback
    {$full_cldr_language_code}Smartyfr-FRback
    {$link}SmartyObject of class LinkObjectback
    {$shop_name}Smarty
    {$base_url}Smarty
    {$current_parent_id}Smarty
    {$tabs}Smarty
    {$current_tab_level}Smarty
    {$install_dir_exists}Smarty
    {$pic_dir}Smarty
    {$controller_name}SmartyAdminCustomerback
    {$current}Smartyindex.php?controller=AdminCustomer
    {$currentIndex}Smartyindex.php?controller=AdminCustomer
    {$bootstrap}Smarty
    {$default_language}Smarty
    {$display_addons_connection}Smarty
    {$urls}Smarty
    {$urls.base_url}Smartyhttps://myshop.com/prefix/full urlfront
    {$urls.current_url}Smartyhttps://myshop.com/prefix/v2-manager?show-old=1full urlfront
    {$urls.shop_domain_url}Smartyhttps://myshop.com/prefixfull urlfront
    {$urls.img_ps_url}Smartyhttps://myshop.com/prefix/img/full urlfront
    {$urls.img_cat_url}Smartyhttps://myshop.com/prefix/img/c/full urlfront
    {$urls.img_lang_url}Smartyhttps://myshop.com/prefix/img/l/full urlfront
    {$urls.img_prod_url}Smartyhttps://myshop.com/prefix/img/p/full urlfront
    {$urls.img_manu_url}Smartyhttps://myshop.com/prefix/img/m/full urlfront
    {$urls.img_sup_url}Smartyhttps://myshop.com/prefix/img/su/full urlfront
    {$urls.img_ship_url}Smartyhttps://myshop.com/prefix/img/s/full urlfront
    {$urls.img_store_url}Smartyhttps://myshop.com/prefix/img/st/full urlfront
    {$urls.img_col_url}Smartyhttps://myshop.com/prefix/img/co/full urlfront
    {$urls.img_url}Smartyhttps://myshop.com/prefix/themes/my_theme/assets/img/full urlfront
    {$urls.css_url}Smartyhttps://myshop.com/prefix/themes/my_theme/assets/css/full urlfront
    {$urls.js_url}Smartyhttps://myshop.com/prefix/themes/my_theme/assets/js/full urlfront
    {$urls.pic_url}Smartyhttps://myshop.com/prefix/upload/full urlfront
    {$urls.pages.address}Smartyhttps://myshop.com/prefix/adressefull urlfront
    {$urls.pages.addresses}Smartyhttps://myshop.com/prefix/adressesfull urlfront
    {$urls.pages.authentication}Smartyhttps://myshop.com/prefix/connexionfull urlfront
    {$urls.pages.cart}Smartyhttps://myshop.com/prefix/panierfull urlfront
    {$urls.pages.category}Smartyhttps://myshop.com/prefix/index.php?controller=categoryfull urlfront
    {$urls.pages.cms}Smartyhttps://myshop.com/prefix/index.php?controller=cmsfull urlfront
    {$urls.pages.contact}Smartyhttps://myshop.com/prefix/nous-contacterfull urlfront
    {$urls.pages.discount}Smartyhttps://myshop.com/prefix/reductionfull urlfront
    {$urls.pages.guest_tracking}Smartyhttps://myshop.com/prefix/suivi-commande-invitefull urlfront
    {$urls.pages.history}Smartyhttps://myshop.com/prefix/historique-commandesfull urlfront
    {$urls.pages.identity}Smartyhttps://myshop.com/prefix/identitefull urlfront
    {$urls.pages.index}Smartyhttps://myshop.com/prefix/full urlfront
    {$urls.pages.my_account}Smartyhttps://myshop.com/prefix/mon-comptefull urlfront
    {$urls.pages.order_confirmation}Smartyhttps://myshop.com/prefix/confirmation-commandefull urlfront
    {$urls.pages.order_detail}Smartyhttps://myshop.com/prefix/index.php?controller=order-detailfull urlfront
    {$urls.pages.order_follow}Smartyhttps://myshop.com/prefix/suivi-commandefull urlfront
    {$urls.pages.order}Smartyhttps://myshop.com/prefix/commandefull urlfront
    {$urls.pages.order_return}Smartyhttps://myshop.com/prefix/index.php?controller=order-returnfull urlfront
    {$urls.pages.order_slip}Smartyhttps://myshop.com/prefix/avoirsfull urlfront
    {$urls.pages.pagenotfound}Smartyhttps://myshop.com/prefix/page-introuvablefull urlfront
    {$urls.pages.password}Smartyhttps://myshop.com/prefix/recuperation-mot-de-passefull urlfront
    {$urls.pages.pdf_invoice}Smartyhttps://myshop.com/prefix/index.php?controller=pdf-invoicefull urlfront
    {$urls.pages.pdf_order_return}Smartyhttps://myshop.com/prefix/index.php?controller=pdf-order-returnfull urlfront
    {$urls.pages.pdf_order_slip}Smartyhttps://myshop.com/prefix/index.php?controller=pdf-order-slipfull urlfront
    {$urls.pages.prices_drop}Smartyhttps://myshop.com/prefix/promotionsfull urlfront
    {$urls.pages.product}Smartyhttps://myshop.com/prefix/index.php?controller=productfull urlfront
    {$urls.pages.search}Smartyhttps://myshop.com/prefix/recherchefull urlfront
    {$urls.pages.sitemap}Smartyhttps://myshop.com/prefix/Sitemapfull urlfront
    {$urls.pages.stores}Smartyhttps://myshop.com/prefix/magasinsfull urlfront
    {$urls.pages.supplier}Smartyhttps://myshop.com/prefix/fournisseurfull urlfront
    {$urls.pages.register}Smartyhttps://myshop.com/prefix/connexion?create_account=1full urlfront
    {$urls.pages.order_login}Smartyhttps://myshop.com/prefix/commande?login=1full urlfront
    prestashop.cartJavascriptproducts: [], totals:[], subtotal:[], products_count, summary_stringfront
    prestashop.configurationJavascriptfront
    prestashop.currencyJavascriptname:’euro’, iso_code:’EUR’, iso_code_num:’978″, sign:’€’front
    currencyJavascriptname:’euro’, iso_code:’EUR’, format:’’, sign:’€’front
    prestashop.customerJavascriptlastname:'AAA', firstname:'bbb', email:’aaa@bbb.com’, …front
    prestashop.languageJavascriptname: ‘Français (French)’, iso_code: 'fr', locale: ‘fr-FR’, language_code: 'fr', is_rtl: '0',…front
    prestashop.pageJavascripttitle:'', canonical: null, meta: {}, page_name: 'index', body_classes, …front
    prestashop.shopJavascriptname: '', email: '', registration_number: false, long: false, lat: falsefront
    prestashop.urlsJavascriptbase_url:'', current_url:'', shop_domain_url:'', img_ps_url:'', img_cat_url:’’, …front
    baseAdminDirJavascript/prefix/admin-dev/back
    baseDirJavascript/prefix/back
    tokenJavascripttoken used in current URL &token={token}back
    token_admin_ordersJavascript???back
    token_admin_customersJavascript???back
    token_admin_customer_threadsJavascript???back
    _PS_VERSION_Javascript‘1.7.2.4’back
    help_class_nameJavascript‘AdminDashboard’back
    default_currencyTwig$
    root_urlTwig/prefix/
    appTwigobject of class AppVariable
    Relacionado  Variables Smarty en Plantilla Prestashop
    Relacionado  Conexión externa a Prestashop para consultas SQL

    Conclusiones y recomendaciones

    En este articulo hemos respondido algunas preguntas relacionadas a las variables y contantes en Prestashop. Además, hemos proporcionado una tabla con gran cantidad de constantes y definiciones que podemos conocer y usar.

    Relacionado  Conectar archivo PHP a Prestashop: 2 ejemplos

    Es importante conocer las constantes de este CMS para optimizar la programación para tener una interfaz dinámica y funcional.

    Nestor Tapia

    Bloggero, amante de la programación PHP, innovador y me fascina compartir información. Desde que conocí el entorno informatico y el internet me llamó la atención la programación, Por tal motivo he creado mi blog BAULPHP.COM para compartir mis experiencias con todos ustedes. ¡Gracias por leerme!.

    Entradas Relacionadas

    Deja una respuesta

    Tu dirección de correo electrónico no será publicada. Los campos obligatorios están marcados con *

    Subir