Jump to content

rbalva01

Members
  • Posts

    8
  • Joined

  • Last visited

Profile Information

  • First Name
    Rodrigo
  • Last Name
    Barrón

rbalva01's Achievements

Newbie

Newbie (1/14)

0

Reputation

  1. Hi! I have PS 1.6.0.14 installed in my PC, and I got stuck with the following. I want a D3 line chart in the Back Office dashboard, so far I've developed and installed a new module for this purpose which correctly displays a table with the data I want on the chart. In addition, I have coded the JS script which configures my chart, gets data to feed it and (supposedly) render the chart. The last part is the problem, the chart just won't render. I had previous errors that I've managed to solve (like bad file referencing, syntax errors) and after that, the chart will not render and I cannot see any other errors thrown in Chrome dev tools. I'll paste my code for the community to check it, hoping that you can help me with this problem: dashboardproducttest.tpl <section id="dashboardproducttest" class="panel widget loading"/> //THIS IS WHERE THE CHART SHOULD RENDER// <div id="dash_ventamuerta_chart1" class="chart with-transitions"> <svg></svg> </div> <div id="productos_block_home" class="block"> <div class="block_content"> {$lista_productos} </div> </div> </section> Getting the data in dashboardproducttest.php public function ajaxProcessGetVentaMuerta() { $sql = "SELECT vm.id_product, DATE(vm.fecha) AS fecha, COUNT(*) AS venta_muerta FROM ps014_venta_muerta AS vm GROUP BY vm.id_product, DATE(vm.fecha);"; $venta_muerta = array(); $last_product_id = ''; if ($result = Db::getInstance()->executeS($sql)) { foreach ($result as $row) { if ($row['id_product'] != $last_product_id) { if ($last_product_id != '') { $venta_muerta[$last_product_id] = json_encode($venta_muerta[$last_product_id]); } $last_product_id = $row['id_product']; $venta_muerta[$last_product_id] = array(); } array_push($venta_muerta[$row['id_product']], json_encode(array('x' => $row['fecha'], 'y' => $row['venta_muerta']))); } $venta_muerta[$last_product_id] = json_encode($venta_muerta[$last_product_id]); } return $venta_muerta; } An instance of DashboardProductTest to return data to AJAX function dashboardproducttest-ajaxCall.php $vm_ajax = new DashboardProductTest(); echo json_encode($vm_ajax->ajaxProcessGetVentaMuerta()); exit; And the JS file with the AJAX function in dashboardproducttest.js nv.addGraph(function() { var chart = nv.models.lineChart() .margin({left: 100}) //Adjust chart margins to give the x-axis some breathing room. .useInteractiveGuideline(true) //We want nice looking tooltips and a guideline! .transitionDuration(350) //how fast do you want the lines to transition? .showLegend(true) //Show the legend, allowing users to turn on/off line series. .showYAxis(true) //Show the y-axis .showXAxis(true) //Show the x-axis ; chart.xAxis //Chart x-axis settings .axisLabel('Fecha') .tickFormat(d3.format("%Y-%m-%d")); chart.yAxis //Chart y-axis settings .axisLabel('Número de unidades') .tickFormat(d3.format(',d')); var arreglo_productos = []; $(document).ready(function (){ $.ajax({ type: "POST", dataType: "json", url: '/prestashop16014/modules/dashboardproducttest/dashboardproducttest-ajaxCall.php', success: function (data){ for (product in data) { arreglo_productos.push({values: data[product], key: product, color: '0066FF'}) } }, error: function (){ console.log(""); } }); }); /* Done setting the chart up? Time to render it!*/ //var ventaMuerta_datos = extraerVentaMuerta(); //You need data... d3.select('#dash_ventamuerta_chart1 svg') //Select the <svg> element you want to render the chart in. .datum(arreglo_productos) //Populate the <svg> element with chart data... .call(chart); //Finally, render the chart! //Update the chart when window resizes. nv.utils.windowResize(chart.update); return chart; }); After getting the AJAX response and pushing the data into arreglo_productos array, I get this array of objects: 0: Object color: "0066FF" key: "16" values: "["{\"x\":\"2015-08-14\",\"y\":\"2\"}"]" 1: Object color: "0066FF" key: "17" values: "["{\"x\":\"2015-08-14\",\"y\":\"2\"}","{\"x\":\"2015-08-17\",\"y\":\"1\"}"]" 2: Object color: "0066FF" key: "18" values: "["{\"x\":\"2015-08-14\",\"y\":\"1\"}","{\"x\":\"2015-08-17\",\"y\":\"1\"}"]" The page won't display any errors but won't display the chart either, is the data I feed it incorrect? Or can any of you help telling me what could be wrong? Thank you in advance
  2. I'm not really sure if Prestashop looks for updates or something, but definitely it tries to connect somewhere on the Internet. I asked around in the company I work for and it turns out that Internet service gets through proxy servers, so that may be the reason of the long loading times or not loading at all. I'm now using PS 1.6.0.14 per our clients request and loading times are now not so long (10 seconds avg), so this problem is kind of solved.
  3. That's precisely what I thought after tweaking the Link.php class file (where the getImageLink method is defined), as I said before, there was no problem with the image loading after editing the constant values for _PS_IMG_DIR_, etc. I didn't realize, though, that I was trying to access that location as a filesystem dir, not as a URL, which led to a "Not allowed to load local resource" console alert in Chrome. Those images are going to be accessed through another web application (which is why my clients wanted to store all images in C:/ClusterStorage/Volume1/WebTiendaenLineaMexicoITK/img/ in the first place) and, therefore, it'll provide a URL as constant value instead of a filesystem directory location. I tested with links to some wikimedia commons images hardcoded into getImageLink, getMediaLink and getCatImageLink and images loaded alright, so I should not get any problems when I use the webapp URL in those methods. TL;DR: URLs good, filesystem location bad. So, yeah, I figured how the "load images" part worked, but not how the browser requested sources. Thanks for your answers, they led me into the right direction
  4. I've changed this lines in defines.inc.php and defines_uri.inc.php: defines.inc.php define('_PS_IMG_DIR_', 'C:/ClusterStorage/Volume1/WebTiendaenLineaMexicoITK/img/'); if (!defined('_PS_HOST_MODE_')) define('_PS_CORE_IMG_DIR_', 'C:/ClusterStorage/Volume1/WebTiendaenLineaMexicoITK/img/'); else define('_PS_CORE_IMG_DIR_', 'C:/ClusterStorage/Volume1/WebTiendaenLineaMexicoITK/img/'); /* define('_PS_IMG_DIR_', _PS_ROOT_DIR_.'/img/'); if (!defined('_PS_HOST_MODE_')) define('_PS_CORE_IMG_DIR_', _PS_CORE_DIR_.'/img/'); else define('_PS_CORE_IMG_DIR_', _PS_ROOT_DIR_.'/img/'); */ defines_uri.inc.php /* Image URLs */ //define('_PS_IMG_', __PS_BASE_URI__.'img/'); define('_PS_IMG_', 'C:/ClusterStorage/Volume1/WebTiendaenLineaMexicoITK/img/'); At the time I did not delete the smarty cache, I have now deleted it following the steps in this tutorial: http://www.templatemonster.com/help/prestashop-1-6-x-how-to-clear-smarty-cache.html But I'm still not able to see images in my product catalog or front office, are those edited values the right ones?
  5. For the record, with the modified configurations I've managed to make PrestaShop able to write the image files into C:/StorageFolder/ImageStorageFolder/img, but is still NOT able to read from that location.
  6. If I can't just move the directory like that, then how? It is my client's request, they need to access the img directory from another application in that specific location.
  7. Hello, I have PrestaShop 1.6.0.14 installed on a XAMPP server, for this instance I need to move the C:/xampp/htdocs/prestashop/img directory from this location to C:/StorageFolder/ImageStorageFolder/img. So far, I've tried to move the folder directly via Windows Explorer and changed the values of _PS_IMG_, _PS_IMG_DIR_ and _PS_CORE_IMG_DIR_ in defines.inc.php and defines_uri.inc.php, but PrestaShop won't load the image files from the new directory, it will try to fetch the images from the original folder. What am I doing wrong? Is there a way to change the img directory to another location to begin with? Thanks in advance.
  8. Hello dear fellow PrestaShop users/devs, I'll tell you my story: I've recently installed PrestaShop 1.6.1.0, running on Apache 2.4.12 and PHP 5.6.11. on a local Windows environment a week ago. Testing Back Office functionality I've encountered 2 main issues: Several pages (dashboard, translations...) show only a blank page after loading for 30-40 seconds. Overall, BO is pretty slow, with loading times being 25 seconds avg. What i've tried so far, reading other forum entries: Enabling error reporting: still blank page. Checking PHP error log: no errors relating to these blank pages. Uninstall, delete files, database and any configurations, reinstall: still the same problems. Editing php configurations (max execution time, max input time, both to 1000, assigned 256M to PHP): nothing different happened. Disconnect Ethernet cable: worked like a charm, <5 seconds load times and no blank pages...but this is more like an ugly, non-practical-in-any-live-site workaround. Front Office works really nice, no complaints there, but Back Office is a whole different story. The long loading times would be bearable...if the pages finally loaded. Any of you have the slightest idea of why disconnecting the cable make everything work alright? It makes no sense to me since this PS instance is on a totally local environment. Any of your assistance or advise is highly appreciated, thanks in advance.
×
×
  • Create New...