Post by uralgit » Tue Dec 18, 2012 10:42 pm

Hi,
I need to put "manufacturers" and a "group of attributes" below all thumbnails in latest, featured, bestsellers modules.

[img]
Manufacturer.png

Manufacturer.png (18.63 KiB) Viewed 2230 times

[/img]

I need an extension or any free or professional solution for this case.
Thanks

New member

Posts

Joined
Tue Oct 09, 2012 5:09 pm

Post by straightlight » Sun Dec 30, 2012 1:16 am

Here's a free solution.

- catalog/controller/module/latest.php file.
- catalog/controller/module/featured.php file.
- catalog/controller/module/bestsellers.php file.

Same steps.

Find:

Code: Select all

$results = $this->model_catalog_product->getProducts($data);
Add after each in those files:

Code: Select all

$this->load->model('catalog/manufacturer');

$this->data['text_manufacturer']       = $this->language->get('text_manufacturer');
Then, find on each:

Code: Select all

$this->data['products'][] = array(
add before each:

Code: Select all

$attribute_groups = $this->model_catalog_product->getProductAttributes($result['product_id']);

$manufacturer = $this->model_catalog_manufacturer->getManufacturer($result['manufacturer_id']);

$manufacturers = $this->url->link('product/manufacturer/info', 'manufacturer_id=' . $result['manufacturer_id']);
After each:

Code: Select all

$this->data['products'][] = array(
add:

Code: Select all

'attribute_groups'                     => $attribute_groups,
'manufacturers'                         => $manufacturers,
'manufacturer'                           => $manufacturer,
In your catalog/view/theme/<your_theme>/template/module/latest.tpl file.
In your catalog/view/theme/<your_theme>/template/module/featured.tpl file.
In your catalog/view/theme/<your_theme>/template/module/bestsellers.tpl file.

Find each:

Code: Select all

<div class="name"><a href="<?php echo $product['href']; ?>"><?php echo $product['name']; ?></a></div>
add below each:

Code: Select all

<div class="description">
        <?php if ($product['manufacturer']) { ?>
        <span><?php echo $text_manufacturer; ?></span> <a href="<?php echo $product['manufacturers']; ?>"><?php echo $product['manufacturer']; ?></a><br />
        <?php } ?>
</div>
<?php if ($product['attribute_groups']) { ?>
  <div id="tab-attribute" class="tab-content">
    <table class="attribute">
      <?php foreach ($product['attribute_groups'] as $attribute_group) { ?>
      <thead>
        <tr>
          <td colspan="2"><?php echo $attribute_group['name']; ?></td>
        </tr>
      </thead>
      <tbody>
        <?php foreach ($attribute_group['attribute'] as $attribute) { ?>
        <tr>
          <td><?php echo $attribute['name']; ?></td>
          <td><?php echo $attribute['text']; ?></td>
        </tr>
        <?php } ?>
      </tbody>
      <?php } ?>
    </table>
  </div>
  <?php } ?>

Dedication and passion goes to those who are able to push and merge a project.

Regards,
Straightlight
Programmer / Opencart Tester


Legendary Member

Posts

Joined
Mon Nov 14, 2011 11:38 pm
Location - Canada, ON

Post by uralgit » Tue Jan 01, 2013 8:02 pm

latestL.jpg

latestL.jpg (44.2 KiB) Viewed 2131 times

Hi Straightlight,

First ı want to thank you for your explanatory, clear answer.
I applied your code on 'latest'.
I'm attaching here the result as an image in latest module .
As seen on the image;
== On the image, On the left corner, Samsung Galaxy does not have any manufacturer assigned to it, so it does not display any
'Array'.
==text_manufacturer's output 'text' is to be corrected.
==Product Attributes are in a table.(I'll remove the table. )
==Product-name has to be just below the immage.
== Besides these we have to sellect only one 'group of attribute'. Not all groups and all attributes.( Let's say only Memory group on the image )or maybe only the first attribute group.
I try to replace some code to find a solution but ı do not have enough php knowledge manage it.
Waiting for your help or modifications on the code.
Thanks

New member

Posts

Joined
Tue Oct 09, 2012 5:09 pm

Post by straightlight » Tue Jan 01, 2013 11:49 pm

From the template instruction above, replace:

Code: Select all

<div class="description">
        <?php if ($product['manufacturer']) { ?>
        <span><?php echo $text_manufacturer; ?></span> <a href="<?php echo $product['manufacturers']; ?>"><?php echo $product['manufacturer']; ?></a><br />
        <?php } ?>
</div>
with:

Code: Select all

<div class="description">
        <?php if ($product['manufacturer']) { ?>
             <span><?php echo $text_manufacturer; ?></span> 
             <?php foreach ($product['manufacturer'] as $manufacturer) { ?>
             <a href="<?php echo $this->url->link('product/manufacturer/info', 'manufacturer_id=' . $manufacturer['manufacturer_id']); ?>"><?php echo html_entity_decode($manufacturer['name'], ENT_QUOTES, 'UTF-8'); ?></a><br />
             <?php } ?>
        <?php } ?>
</div>
As for the text_manufacturer, in your catalog/language/english/product/product.php file,

add above the ?>:

Code: Select all

$_['text_manufacturer'] = 'Manufacturer: ';
However, look for the text_manufacturer in the file first before adding that step. If it already exists in the file, there's no need to add it multiple times.

Dedication and passion goes to those who are able to push and merge a project.

Regards,
Straightlight
Programmer / Opencart Tester


Legendary Member

Posts

Joined
Mon Nov 14, 2011 11:38 pm
Location - Canada, ON

Post by uralgit » Wed Jan 02, 2013 6:51 pm

latest3.jpg

latest3.jpg (38.15 KiB) Viewed 2114 times

Hi Straightlight,

HAPPY NEW YEAR

Above is an image of the 'latest' module after latest modification, which is more descriptive than some sentences.
Thanks

New member

Posts

Joined
Tue Oct 09, 2012 5:09 pm

Post by uralgit » Wed Jan 02, 2013 10:39 pm

latest4.jpg

latest4.jpg (39.86 KiB) Viewed 2106 times

Hi Straightlight,
I made a small change on your code. So, one of two questions is solved. Attributes from a sellected attribute_group are produced:

Code: Select all

 <?php if ($product['attribute_groups']) { ?>
      <div id="tab-attribute" class="tab-content">
          <?php foreach ($product['attribute_groups'] as $attribute_group) { ?>
          <?php if ($attribute_group['name']=='Memory') { ?>
            <?php foreach ($attribute_group['attribute'] as $attribute) { ?>
               <?php echo $attribute['name']; ?>
               <?php echo ":"; ?>
             <?php echo $attribute['text']; ?>
              <?php } ?>
            <?php } ?>
          <?php } ?>
      </div>
      <?php } ?>
[/highlight]

But displaying manufacturer_name (linked to it's file) is not solved.
I'm waiting for some help for this issue.
Thanks for your effort and guidance for the solved part.
Best wishes

New member

Posts

Joined
Tue Oct 09, 2012 5:09 pm

Post by straightlight » Wed Jan 02, 2013 10:47 pm

But displaying manufacturer_name (linked to it's file) is not solved.
I'm not sure what you mean by manufacturer_name linked to it's file ... could you elaborate that a little ?

As for the manufacturer_name, it would rather be: manufacturer['name'] from the loop.

Dedication and passion goes to those who are able to push and merge a project.

Regards,
Straightlight
Programmer / Opencart Tester


Legendary Member

Posts

Joined
Mon Nov 14, 2011 11:38 pm
Location - Canada, ON

Post by uralgit » Thu Jan 03, 2013 9:05 pm

Forget it please. I only wanted to emphasize the remaining manufacturers name problem.

New member

Posts

Joined
Tue Oct 09, 2012 5:09 pm

Post by uralgit » Sat Jan 05, 2013 6:36 pm

Hi straightlight ,

will you offer any suggestion to put manufacturer name below the thumbnails in modules ????
Regards

New member

Posts

Joined
Tue Oct 09, 2012 5:09 pm

Post by straightlight » Mon Jan 07, 2013 5:12 am

According to your last reply above, you did mentioned to forget about it ...

Dedication and passion goes to those who are able to push and merge a project.

Regards,
Straightlight
Programmer / Opencart Tester


Legendary Member

Posts

Joined
Mon Nov 14, 2011 11:38 pm
Location - Canada, ON

Post by uralgit » Mon Jan 07, 2013 6:14 pm

Hi, straightlight,
There is a misunderstanding about 'forget it'. I did not mean to forget the questions on this post. Anyway the remaining question about 'manufacturer name' or 'brand' under all thumbnails is waiting an answer from our experienced friends like you.
Best Regards

New member

Posts

Joined
Tue Oct 09, 2012 5:09 pm

Post by uralgit » Wed Jan 09, 2013 9:49 pm

Hi Straightlight and all viewers,

Let's not close this post before getting any suitable explanation for the unsolved part of the issue : "putting the manufacturer name below every thumbnail in latest, featured, bestsellers or/and similar modules".
The solutions from straightlight are very close to find the correct answer. But my php knowledge is not capabil to develop it. Here ı want to give some additional info about the final situation. I made some small changes on the straightlight's codes and this image demonstrates the final output : On the image you see the links produced with this code.
Below is 'latest.tpl' the compleat file where ı added straightlight's codes into the file :

Code: Select all

<div class="box">
  <div class="box-heading"><?php echo $heading_title; ?></div>
  <div class="box-content">
    <div class="box-product">
      <?php foreach ($products as $product) { ?>
      <div>
        <?php if ($product['thumb']) { ?>
        <div class="image"><a href="<?php echo $product['href']; ?>">
        <img src="<?php echo $product['thumb']; ?>" alt="<?php echo $product['name']; ?>" /></a></div>
        <?php } ?>
           <div class="name"><a href="<?php echo $product['href']; ?>"><?php echo $product['name']; ?></a></div>
 
 <!-- BELOW IS CODE FOR MANUFACTURER AND A GROUP OF ATTRiBUTES (Attribute group= 'Memory') --> 
              
<?php if ($product['manufacturer']) { ?>
<div class="description">        
                  <?php foreach ($product['manufacturer'] as $manufacturer) { ?>                  
                 <a href="<?php echo $this->url->link('product/manufacturer/info', 'manufacturer_id=' . $manufacturer['manufacturer_id']); ?>">
                  <?php echo html_entity_decode($manufacturer['name'], ENT_QUOTES, 'UTF-8'); ?>
                  </a><br />                
                 <?php } ?>
            <?php } ?>
    </div>
 <!----------THıS PART BELOW FOR ATTRıBUTE GROUP-------------> 
                <?php if ($product['attribute_groups']) { ?>
      <div id="tab-attribute" class="tab-content">
          <?php foreach ($product['attribute_groups'] as $attribute_group) { ?>
          <?php if ($attribute_group['name']=='Memory') { ?>
            <?php foreach ($attribute_group['attribute'] as $attribute) { ?>
               <?php echo $attribute['name']; ?>
               <?php echo ":"; ?>
             <?php echo $attribute['text']; ?>
              <?php } ?>
            <?php } ?>
          <?php } ?>
      </div>
      <?php } ?>
  <!-- ABOVE YOU FıND CODE FOR MANUFACTURER AND A GROUP OF ATTRiBUTES (Attribute group=Memory') -->
 
            <?php if ($product['price']) { ?>
        <div class="price">
          <?php if (!$product['special']) { ?>
          <?php echo $product['price']; ?>
          <?php } else { ?>
          <span class="price-old"><?php echo $product['price']; ?></span> <span class="price-new">
          <?php echo $product['special']; ?></span>
          <?php } ?>
        </div>
        <?php } ?>
        <?php if ($product['rating']) { ?>
        <div class="rating"><img src="catalog/view/theme/default/image/stars-<?php echo $product['rating']; ?>.png" alt="<?php echo $product['reviews']; ?>" /></div>
        <?php } ?>
        <div class="cart"><input type="button" value="<?php echo $button_cart; ?>" onclick="addToCart('<?php echo $product['product_id']; ?>');" class="button" /></div>
      </div>
      <?php } ?>
    </div>
  </div>
</div>
And this is the result :
latest-5.jpg

latest-5.jpg (130.41 KiB) Viewed 1978 times

Now please some help for the final solution

Thanks

New member

Posts

Joined
Tue Oct 09, 2012 5:09 pm

Post by straightlight » Thu Jan 10, 2013 8:41 am

Replace:

Code: Select all

<div class="description">
        <?php if ($product['manufacturer']) { ?>
             <span><?php echo $text_manufacturer; ?></span>
             <?php foreach ($product['manufacturer'] as $manufacturer) { ?>
             <a href="<?php echo $this->url->link('product/manufacturer/info', 'manufacturer_id=' . $manufacturer['manufacturer_id']); ?>"><?php echo html_entity_decode($manufacturer['name'], ENT_QUOTES, 'UTF-8'); ?></a><br />
             <?php } ?>
        <?php } ?>
</div>
with:

Code: Select all

<div class="description">
        <?php if ($product['manufacturer']) { ?>
             <span><?php echo $text_manufacturer; ?></span>
             <a href="<?php echo $this->url->link('product/manufacturer/info', 'manufacturer_id=' . $product['manufacturer']['manufacturer_id']); ?>"><?php echo html_entity_decode($product['manufacturer']['name'], ENT_QUOTES, 'UTF-8'); ?></a><br />             
        <?php } ?>
</div>

Dedication and passion goes to those who are able to push and merge a project.

Regards,
Straightlight
Programmer / Opencart Tester


Legendary Member

Posts

Joined
Mon Nov 14, 2011 11:38 pm
Location - Canada, ON

Post by uralgit » Thu Jan 10, 2013 5:01 pm

latestF.png

latestF.png (43.07 KiB) Viewed 1956 times

latestF1.png

latestF1.png (42.38 KiB) Viewed 1956 times

Hi Straightlight,

This is the final hit which meet the target.
This post will be very usefull for many members of opencart community.
Straightlight has now brighten our way in this post.

Thank You very much Straightlight.

New member

Posts

Joined
Tue Oct 09, 2012 5:09 pm
Who is online

Users browsing this forum: No registered users and 1 guest