Jump to content
kymation

[Addon] Modular Product Page (Bootstrap)

Recommended Posts

Hello,
I have  Modular Product Page (Bootstrap) installed, and I would like to install Header Tags SEO addon by @Jack_mcs.
and on the Header Tags SEO addon  installation doc need changes  in product_info.php file.  and i cant find where is the code for calling the database ..
find 

 $product_info_query = tep_db_query("select p.products_id, pd.products_name, pd.products_description, p.products_model, p.products_quantity, p.products_image, pd.products_url, p.products_price, p.products_tax_class_id, p.products_date_added, p.products_date_available, p.manufacturers_id from " . TABLE_PRODUCTS . " p, " . TABLE_PRODUCTS_DESCRIPTION . " pd where p.products_status = '1' and p.products_id = '" . (int)$HTTP_GET_VARS['products_id'] . "' and pd.products_id = p.products_id and pd.language_id = '" . (int)$languages_id . "'");
    $product_info = tep_db_fetch_array($product_info_query);

 REPLACE WITH:

/*** Begin Header Tags SEO ***/
    $product_info_query = tep_db_query("select p.products_id, pd.products_name, pd.products_description, p.products_model, p.products_quantity, p.products_image, pd.products_url, p.products_price, p.products_tax_class_id, p.products_date_added, p.products_date_available, p.manufacturers_id, pd.products_head_sub_text from " . TABLE_PRODUCTS . " p, " . TABLE_PRODUCTS_DESCRIPTION . " pd where p.products_status = '1' and p.products_id = '" . (int)$HTTP_GET_VARS['products_id'] . "' and pd.products_id = p.products_id and pd.language_id = '" . (int)$languages_id . "'");
    $product_info = tep_db_fetch_array($product_info_query);
    
    $product_info['products_name'] = $header_tags_array['title_alt'];
    /*** End Header Tags SEO ***/ 

Thank you in advance,
Joe

Share this post


Link to post
Share on other sites

The Modular Product Page Addon uses the products class to get the data. I retrieves all of the data from the products tables, so there is no need to modify the SQL query.

I don't know about that last line in the replacement code. It should probably go in the template (catalog/includes/modules/content/product_info/templates/cm_pi_name.php) but I don't know where that  $header_tags_array gets defined. You could try something like

global $header_tags_array;
$product_info->products_name = $header_tags_array['title_alt'];

at the top of that file.

Regards

Jim


See my profile for a list of my addons and ways to get support.

Share this post


Link to post
Share on other sites

Hello @kymation, everyone 
I still have some issue with install Header Tags SEO addon by @Jack_mcs  with Modular Product Page (Bootstrap) installed, Here is the code whats need to change  in product_info.php :
 

In products_info.php

FIND:

  require(DIR_WS_INCLUDES . 'template_top.php');

ADD BENEATH:
  
  /*** Begin Header Tags SEO ***/  
  echo "<a name=\"\$header_tags_array['title']\"></a>";
  /*** End Header Tags SEO ***/ 

FIND:

    $product_info_query = tep_db_query("select p.products_id, pd.products_name, pd.products_description, p.products_model, p.products_quantity, p.products_image, pd.products_url, p.products_price, p.products_tax_class_id, p.products_date_added, p.products_date_available, p.manufacturers_id, p.products_gtin from " . TABLE_PRODUCTS . " p, " . TABLE_PRODUCTS_DESCRIPTION . " pd where p.products_status = '1' and p.products_id = '" . (int)$_GET['products_id'] . "' and pd.products_id = p.products_id and pd.language_id = '" . (int)$languages_id . "'");
    $product_info = tep_db_fetch_array($product_info_query);

    tep_db_query("update " . TABLE_PRODUCTS_DESCRIPTION . " set products_viewed = products_viewed+1 where products_id = '" . (int)$_GET['products_id'] . "' and language_id = '" . (int)$languages_id . "'");

REPLACE WITH:

    /*** Begin Header Tags SEO ***/
    $product_info_query = tep_db_query("select p.products_id, pd.products_name, pd.products_description, p.products_model, p.products_quantity, p.products_image, pd.products_url, p.products_price, p.products_tax_class_id, p.products_date_added, p.products_date_available, p.manufacturers_id, p.products_gtin, pd.products_head_sub_text from products p, products_description pd where p.products_status = '1' and p.products_id = '" . (int)$_GET['products_id'] . "' and pd.products_id = p.products_id and pd.language_id = '" . (int)$languages_id . "'");
    $product_info = tep_db_fetch_array($product_info_query);
    $product_info['products_name'] = $header_tags_array['title_alt'];
    /*** End Header Tags SEO ***/ 

    tep_db_query("update products_description set products_viewed = products_viewed+1 where products_id = '" . (int)$_GET['products_id'] . "' and language_id = '" . (int)$languages_id . "'");

FIND:

  <?php echo stripslashes($product_info['products_description']); ?>

REPLACE WITH:

  <?php /*** Begin Header Tags SEO ***/ ?>
  <?php echo HTS_Highlight(stripslashes($product_info['products_description']), $header_tags_array['keywords']); ?>
  <?php /*** End Header Tags SEO ***/ ?>


FIND:

</div>

</form>

ADD ABOVE:

      <?php /*** Begin Header Tags SEO ***/
      if (tep_not_null($product_info['products_head_sub_text'])) {
          echo '<div class="hts_sub_text" style="padding:10px 0;">' . $product_info['products_head_sub_text'] . '</div>';
      }
      if (HEADER_TAGS_DISPLAY_CURRENTLY_VIEWING == 'true') {
          echo '<div id="hts_viewing">' .TEXT_VIEWING;
          $header_tags_array['title'] = (tep_not_null($header_tags_array['title']) ? $header_tags_array['title'] : $product_info['products_name']);
          echo '<a title="' . $header_tags_array['title'] . '" href="' . tep_href_link('product_info.php', 'products_id=' . $product_info['products_id'], 'NONSSL') . '"/# ' . $header_tags_array['title'] . '">' . $header_tags_array['title'] . '</a>';
          echo '</div>';
      }
      if (HEADER_TAGS_DISPLAY_SOCIAL_BOOKMARKS == 'true') {
        echo '<div style="float:right; margin-top:5px; margin-right:4px;">';
        include('includes/modules/header_tags_social_bookmarks.php');
        echo '</div>';
      }
      /*** End Header Tags SEO ***/
      ?>

Can you please advice me

Thank you 
Joe

 

Edited by joe122joe

Share this post


Link to post
Share on other sites

I advise that you not use old Addons that require changes to core code. Doing so will break future code changes such as the upgrade to 2.4 when it is released. You can use one of the modular Addons to add header tags. Better yet, take the header tags out of 2.3.4BS Edge or the 2.4 beta and use those.

Regards

Jim


See my profile for a list of my addons and ways to get support.

Share this post


Link to post
Share on other sites

Hi Jim

I am in the same situation as joe122joe. All my pages on my site have the title tag as my store name which is not good for SEO. It looks like the tables support individual seo tage per product but I cannot work out how this can work with the modular product page.

I checked in the EDGE version but cannot see a suitable module. So can you advise if you know of any suitable module that might work with your add on?

Thanks a lot

Share this post


Link to post
Share on other sites

Download a copy of the latest Edge release, then go to /includes/modules/header_tags/ and copy all of the modules to the same folder in your store. Do the same with /includes/languages/english/modules/header_tags/. You can then install all of the Header Tag modules that you want to use.

Regards

Jim


See my profile for a list of my addons and ways to get support.

Share this post


Link to post
Share on other sites

Thank you Jim @kymation I downloaded the Header Tag modules from the latest Edge release and installed it, The Product Title Module  (Enable Product Title Module) it set to True, but still not shown the product titles on the page title ,The  another modules(Category Title,Manufacturer Title) working well.

any help
 Thank your 
Joe

 

Share this post


Link to post
Share on other sites

Yes I agree with Joe. Something is not allowing product titles to be changed. Any input would be gratefully received.

Share this post


Link to post
Share on other sites

Sorry for the double post. However I found what seems to be stopping it from working:

in ht_product_title.php module

if ($product_check['total'] > 0) { 


}

 

I checked the $product_check array and there doesn't seem to be anything in it. Maybe it doesn't exist or isn't used in the modular product page. However just commenting this if loop out it then does show the product name in the title tag.

Edited by ollyno1uk2
adding file source

Share this post


Link to post
Share on other sites

I am once again trying to add in the auto price update addon, I have managed to make all the changes but the am getting the below error.

Fatal error: Cannot use object of type product_info as array in C:\xampp\htdocs\generic\includes\modules\content\product_info\cm_pi_price_update.php on line 47

I'm sure I've read somewhere that it is due to the way $product_info is being used in the modular page. 

Any advice?

Share this post


Link to post
Share on other sites

You are correct: This Addon gets all of its data from a product class, which is instantiated as $product_info. You can change your auto price update Addon to use the data from the product class, or you can change all occurrences of $product_info in that Addon to something else. Either way will work, but the former will be faster.

Regards

Jim


See my profile for a list of my addons and ways to get support.

Share this post


Link to post
Share on other sites
2 hours ago, kymation said:

You are correct: This Addon gets all of its data from a product class, which is instantiated as $product_info. You can change your auto price update Addon to use the data from the product class, or you can change all occurrences of $product_info in that Addon to something else. Either way will work, but the former will be faster.

Regards

Jim

So changing $product_info['products_price'] to $product_info->products_price() should do the trick? 

Share this post


Link to post
Share on other sites

I made the change mentioned above but it is still not working. There is a hidden field as part of the addon and having made it visible I can see the below error.

<br /><b>Warning</b>:  implode(): Invalid arguments passed in <b>C:\xampp\htdocs\generic\includes\modules\content\product_info\templates\cm_pi_options.php</b> on line <b>37</b><br />NULL

This is the code it relates to

<input type="text" name="optionsid" id="optionsid" value="<?php echo implode(",",$products_attributes); ?>" />

 

Share this post


Link to post
Share on other sites
$products_attributes

is not set in the products class that this module relies on. You could probably set this with something like this:

$products_attributes = array();
if( $product_info->has_options() === true ) {
    $products_attributes = $product_info->options_names();
}

I'm assuming that $products_attributes is supposed to be an array of option names and IDs. If it's really an array of attributes for a particular option, you need to use $product_info->options_data( $products_options_id ) instead of $product_info->options_names(), and provide the option ID as $products_options_id.

Regards

Jim


See my profile for a list of my addons and ways to get support.

Share this post


Link to post
Share on other sites

I thought it might be missing too but it is added in during the install instructions for the attribute update.

    $numberofopt = tep_db_num_rows($products_options_name_query);	  
      $opt_count = 0;	  
      $products_attributes = array();
	  while ($products_options_name = tep_db_fetch_array($products_options_name_query)) {
	    array_push($products_attributes,$products_options_name['products_options_id']);
        $opt_count++;

 

Share this post


Link to post
Share on other sites
On 27/08/2017 at 2:44 AM, kymation said:

$products_attributes

is not set in the products class that this module relies on. You could probably set this with something like this:


$products_attributes = array();
if( $product_info->has_options() === true ) {
    $products_attributes = $product_info->options_names();
}

I'm assuming that $products_attributes is supposed to be an array of option names and IDs. If it's really an array of attributes for a particular option, you need to use $product_info->options_data( $products_options_id ) instead of $product_info->options_names(), and provide the option ID as $products_options_id.

Regards

Jim

I have done as you suggested but my output is just Array, Array

I'll keep trying but if I'm missing something obvious I wouldn't say no to a nudge in the right direction.

Share this post


Link to post
Share on other sites

That means your code is expecting to get a single attribute and it's getting an array of all attributes. I'm not familiar with the Addon that you're trying to integrate, so I can't tell you specifically what needs to be changed. Usually the code loops through the array and outputs the attributes in the desired form (pulldown menu, radio buttons, etc.) You'll need to figure out how it is trying to do that and feed it the array in the correct location.

Regards

Jim


See my profile for a list of my addons and ways to get support.

Share this post


Link to post
Share on other sites

@kymation it is expecting an array only it has too many values, I am only able to output the full $product_info->options_names(); but I only need ['product_options_id'] from the array.

Share this post


Link to post
Share on other sites

I now have this working for drop downs and will post the addon later. Now on to getting it to work for the radio button addon I've made.

Share this post


Link to post
Share on other sites

@kymation  I was looking something like this 

    tep_db_query("update " . TABLE_PRODUCTS_DESCRIPTION . " set products_viewed = products_viewed+1 where products_id = '" . (int)$HTTP_GET_VARS['products_id'] . "' and language_id = '" . (int)$languages_id . "'");

in your addon  and didn't found it .. because  there is no viewed products sort in the database .. 

thank you
Joe

Share this post


Link to post
Share on other sites

Fixed
I just add it to includes/classes/product_info.php and its work now
after this line 

 $this->product_info = $this->get_product_data();

add this line
 

		          tep_db_query("update " . TABLE_PRODUCTS_DESCRIPTION . " set products_viewed = products_viewed+1 where products_id = '" . (int)$_GET['products_id'] . "' and language_id = '" . (int)$languages_id . "'");

I dont know if it is the right way but its working for me 

Joe

Edited by joe122joe

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

×