Jump to content

AT2

Members
  • Posts

    5
  • Joined

  • Last visited

About AT2

  • Birthday 10/23/1990

Contact Methods

  • Skype
    andrea.toniolo.web

Profile Information

  • Location
    Italy, Legnano (Milano)
  • Activity
    Freelancer

Recent Profile Visitors

6,630,952 profile views

AT2's Achievements

Newbie

Newbie (1/14)

12

Reputation

  1. you can get the url of the cover image by this code: //GET IMAGE LINK $id_image = Product::getCover((int)$product['id_product']); if (sizeof($id_image) > 0) { $image = new Image($id_image['id_image']); $image_url = _PS_BASE_URL_._THEME_PROD_DIR_.$image->getExistingImgPath().".jpg"; } you have to paste it in classes/PaymentModule.php , before the creation of the "tr" of the product. then use $image_url where you want to show the image. i did it like this: //GET IMAGE LINK $id_image = Product::getCover((int)$product['id_product']); if (sizeof($id_image) > 0) { $image = new Image($id_image['id_image']); $image_url = _PS_BASE_URL_._THEME_PROD_DIR_.$image->getExistingImgPath().".jpg"; } if (!$customization_quantity || (int)$product['cart_quantity'] > $customization_quantity) $products_list .= '<tr style="background-color: '.($key % 2 ? '#DDE2E6' : '#EBECEE').';"> <td><img src="'.$image_url.'" width="100" height="100"/></td> <td style="padding: 0.6em 0.4em;width: 15%;">'.$product['reference'].'</td> <td style="padding: 0.6em 0.4em;width: 30%;"><strong>'.$product['name'].(isset($product['attributes']) ? ' - '.$product['attributes'] : '').'</strong></td> <td style="padding: 0.6em 0.4em; width: 20%;">'.Tools::displayPrice(Product::getTaxCalculationMethod() == PS_TAX_EXC ? Tools::ps_round($price, 2) : $price_wt, $this->context->currency, false).'</td> <td style="padding: 0.6em 0.4em; width: 15%;">'.((int)$product['cart_quantity'] - $customization_quantity).'</td> <td style="padding: 0.6em 0.4em; width: 20%;">'.Tools::displayPrice(((int)$product['cart_quantity'] - $customization_quantity) * (Product::getTaxCalculationMethod() == PS_TAX_EXC ? Tools::ps_round($price, 2) : $price_wt), $this->context->currency, false).'</td> </tr>'; PS VERSION: 1.5.3.1
  2. have you tried my solution? it should work with your version too.
  3. i think you should follow my instructions. it's very easy. You're welcome
  4. Look at post #15 of that link. In any case, if you follow my instructions you don't need to read that thread. If you use this solution, you don't have to regenerate any image, so it fits your needs. bye
  5. Hi guys, I have tested yesterday the solution i found here, then i saw the problems with layered navigation, filter etc... and i thought that the solution must be different, the solution must be something above the singolar category class or similar. so i think you are on the wrong road and i searched for another solution. the solution i found is write in french language, i watched the code and i've get it work. my version of prestashop is the last one: 1.5.3.1 but this solution should work (or adapted) for any version. the link for the solution is http://www.prestasho...g-des-produits/ i explain for the non-french reader (like me, i'm italian) you have to edit class/Link.php find : public function getImageLink($name, $ids, $type = NULL) and edit to : public function getImageLink($name, $ids, $type = NULL, $idOver= NULL) (id over is the id of the product) then find : $split_ids = explode('-', $ids); $id_image = (isset($split_ids[1]) ? $split_ids[1] : $split_ids[0]); $theme = ((Shop::isFeatureActive() && file_exists(_PS_PROD_IMG_DIR_.Image::getImgFolderStatic($id_image).$id_image.($type ? '-'.$type : '').'-'.(int)Context::getContext()->shop->id_theme.'.jpg')) ? '-'.Context::getContext()->shop->id_theme : ''); and edit to: $split_ids = explode('-', $ids); $id_image = (isset($split_ids[1]) ? $split_ids[1] : $split_ids[0]); $theme = ((Shop::isFeatureActive() && file_exists(_PS_PROD_IMG_DIR_.Image::getImgFolderStatic($id_image).$id_image.($type ? '-'.$type : '').'-'.(int)Context::getContext()->shop->id_theme.'.jpg')) ? '-'.Context::getContext()->shop->id_theme : ''); if(isset($idOver)){ $result = Db::getInstance()->ExecuteS('SELECT id_image FROM '._DB_PREFIX_.'image WHERE id_product = '.$idOver.' AND position = 2'); foreach ($result as $row) $id_image_over = $row['id_image']; }else{ $id_image_over = 0; } if($id_image_over != 0){ $id_image = $id_image_over; } so the finally function getImageLink should look like this: public function getImageLink($name, $ids, $type = null, $idOver= NULL) { $not_default = false; // legacy mode or default image $theme = ((Shop::isFeatureActive() && file_exists(_PS_PROD_IMG_DIR_.$ids.($type ? '-'.$type : '').'-'.(int)Context::getContext()->shop->id_theme.'.jpg')) ? '-'.Context::getContext()->shop->id_theme : ''); if ((Configuration::get('PS_LEGACY_IMAGES') && (file_exists(_PS_PROD_IMG_DIR_.$ids.($type ? '-'.$type : '').$theme.'.jpg'))) || ($not_default = strpos($ids, 'default') !== false)) { if ($this->allow == 1 && !$not_default) $uri_path = __PS_BASE_URI__.$ids.($type ? '-'.$type : '').$theme.'/'.$name.'.jpg'; else $uri_path = _THEME_PROD_DIR_.$ids.($type ? '-'.$type : '').$theme.'.jpg'; } else { // if ids if of the form id_product-id_image, we want to extract the id_image part $split_ids = explode('-', $ids); $id_image = (isset($split_ids[1]) ? $split_ids[1] : $split_ids[0]); $theme = ((Shop::isFeatureActive() && file_exists(_PS_PROD_IMG_DIR_.Image::getImgFolderStatic($id_image).$id_image.($type ? '-'.$type : '').'-'.(int)Context::getContext()->shop->id_theme.'.jpg')) ? '-'.Context::getContext()->shop->id_theme : ''); if(isset($idOver)){ $result = Db::getInstance()->ExecuteS('SELECT id_image FROM '._DB_PREFIX_.'image WHERE id_product = '.$idOver.' AND position = 2'); foreach ($result as $row) $id_image_over = $row['id_image']; }else{ $id_image_over = 0; } if($id_image_over != 0){ $id_image = $id_image_over; } if ($this->allow == 1) $uri_path = __PS_BASE_URI__.$id_image.($type ? '-'.$type : '').$theme.'/'.$name.'.jpg'; else $uri_path = _THEME_PROD_DIR_.Image::getImgFolderStatic($id_image).$id_image.($type ? '-'.$type : '').$theme.'.jpg'; } return $this->protocol_content.Tools::getMediaServer($uri_path).$uri_path; } then edit your_theme/product-list.tpl, find: <img src="{$link->getImageLink($product.link_rewrite, $product.id_image, 'home_default')}" alt="{$product.legend|escape:'htmlall':'UTF-8'}" {if isset($homeSize)} width="{$homeSize.width}" height="{$homeSize.height}"{/if} /> and edit to: <img onmouseover="this.src='{$link->getImageLink($product.link_rewrite, $product.id_image, 'home_default', $product.id_product)}'" onmouseout="this.src='{$link->getImageLink($product.link_rewrite, $product.id_image, 'home_default')}'" src="{$link->getImageLink($product.link_rewrite, $product.id_image, 'home_default')}" alt="{$product.legend|escape:'htmlall':'UTF-8'}" {if isset($homeSize)} width="{$homeSize.width}" height="{$homeSize.height}"{/if} /> pay attention to 'home_default', in my case it works, for some other it could be 'home' or different. I think that this solution can be use everywhere you want, without touching other classes or controllers (like it should be i think), just change the img part where you want (featured product and so) i hope everyone can understand my bad english. hope it helps. bye
×
×
  • Create New...