Advertisement
Guest User

Untitled

a guest
Feb 18th, 2020
96
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 3.11 KB | None | 0 0
  1. <?php
  2. $str_catalogo = file_get_contents('http://localhost/artigraf.pt/Catalog_es_ES_DEMO.json');
  3. //var_dump($str);
  4. $json_catalogo = json_decode($str_catalogo, true);
  5.  
  6. $catalogo = $json_catalogo['root']['Products'][0];
  7. //print_r($catalogo);
  8.  
  9.  
  10. foreach ($catalogo['Product'] as $field_catalogo => $value_catalogo) {
  11.  
  12. $value_catalogo['id'];
  13.  
  14. echo '
  15. <div class="col-sm-4 col-xs-12" >
  16. <div class="product-image-wrapper">
  17. <div class="single-products">
  18. <div class="productinfo text-center" style="background-color: #f2f2f2; border: #e6e6e6 1px solid">';
  19.  
  20.  
  21.  
  22.  
  23.  
  24. $str_imagens = file_get_contents('http://localhost/artigraf.pt/MultimediaLinks_es_ES_DEMO.json');
  25. //var_dump($str);
  26. $json_imagens = json_decode($str_imagens, true);
  27.  
  28. $imagens_count = count($json_imagens['root']['Products'][0]['Product']);
  29.  
  30. // serve para percorrer todas as imagens do ficheiro
  31. for ($i = 0; $i < $imagens_count; $i++) {
  32. $imagens = $json_imagens['root']['Products'][0]['Product'][$i]['MultimediaLinks'];
  33. //print_r($imagens);
  34.  
  35.  
  36. foreach ($imagens['MultimediaLink'] as $field_imagens => $value_imagens) {
  37.  
  38. // serve para ir buscar o id no ficheiro de catalogo
  39. $imagens_1 = $json_imagens['root']['Products'][0];
  40.  
  41. foreach ($imagens_1['Product'] as $field_imagens_1 => $value_imagens_1) {
  42.  
  43. if ($value_catalogo['id'] === $value_imagens_1['id']) {
  44. echo '<img src="' . $value_imagens['Url'] . '" width="500" height="250" alt=""/>';
  45. }
  46. }
  47. }
  48. }
  49.  
  50.  
  51.  
  52. echo '
  53. <a href="product-details.php?id_produto=' . $value_catalogo['id'] . '">
  54.  
  55. <p style="margin: 20px 0 10px;"></p>
  56.  
  57. <h2 style="margin-bottom: 9%"> €</h2>
  58.  
  59. <button class="btn_lista add-to-cart" style="">Comprar agora +
  60. </button>
  61. </a>
  62. </div>
  63. </div>
  64. </div>
  65. </div> ';
  66.  
  67. }
  68.  
  69. ?>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement