Forums / Setting Up Categories, Products, Attributes / Creating an add-on "product type book" for ZC 1.5

Creating an add-on "product type book" for ZC 1.5

Views: 111,146

Results 361 to 380 of 427
26 Mar 2016, 4:08 PM
#361
fjbern1943 avatar

fjbern1943

Zen Follower

Join Date:
Apr 2015
Location:
United States
Posts:
144
Plugin Contributions:
0

Creating an add-on "product type book" for ZC 1.5

philou:

Hi Frank,

menitu must respond to you, since he wrote the original post.
Let me just point out again, that there is an inclusion mechanism, which allows you to place a file which begins with "collect_info" like "collect_info_ceon_uri.php" and it will be included automatically by "collect_info.php". The same must then be implemented for "preview_info" and "update_product", so you deal with all your extra data in all three files and leave the original files untouched (if possible).

Regards,
p.

Hello p.

I created a file "collect_info_seo.php" and put in this file "// BEGIN CEON URI MAPPING 1 of 2 require_once(DIR_WS_CLASSES . 'class.CeonURIMappingAdminProductPages.php'); $ceon_uri_mapping_admin = new CeonURIMappingAdminProductPages(); $ceon_uri_mapping_admin->collectInfoHandler(); // END CEON URI MAPPING 1 of 2
but now I only get this same text at the top of my collect_info.php page instead of ceon uri box near the bottom of the page.

I also created another file "collect_info_metatags.php" and that looks like it is functioning properly.

I have not done anything with the preview nor update yet.

Thanks for your help,
Frank

26 Mar 2016, 4:21 PM
#362
philou avatar

philou

Zen Follower

Join Date:
Jan 2006
Posts:
165
Plugin Contributions:
1

Re: Creating an add-on "product type book" for ZC 1.5

Sorry I am not familiar myself with CEON. There is only one include of "collect_info_*.php" named files at the top of "collect_info.php"
If you need extra code anywhere else, then you do have to modify the "collect_info.php" file itself.

regards,
p.

26 Mar 2016, 4:50 PM
#363
fjbern1943 avatar

fjbern1943

Zen Follower

Join Date:
Apr 2015
Location:
United States
Posts:
144
Plugin Contributions:
0

Re: Creating an add-on "product type book" for ZC 1.5

philou:

Sorry I am not familiar myself with CEON. There is only one include of "collect_info_*.php" named files at the top of "collect_info.php"
If you need extra code anywhere else, then you do have to modify the "collect_info.php" file itself.

regards,
p.

Hello p.

I uploaded the collect_info_metatags.php, preview_info_meta_tags.php and update_info_meta_tags.php files and all is well with the metatags.

That proves that your system of adding these files to the directory works.

If you do not use ceon URI for friendly url's, what do you use if any?

Best regards,

Frank

26 Mar 2016, 4:56 PM
#364
philou avatar

philou

Zen Follower

Join Date:
Jan 2006
Posts:
165
Plugin Contributions:
1

Re: Creating an add-on "product type book" for ZC 1.5

Hi Frank,

the metatags are included by core ZEN CART functionality, not by BookX. You can verify this, by looking at the "normal" product folder in ADMIN/includes/modules/product. It also has extra collect_info_metatags.php and that has nothing to do with BookX.
As a convenience not to have to add code to the collect_info.php directly, BookX provides this extra include functionality, so your modifications do not break when an update comes along.

I don not ucrrently use user friendly URIs. Not exactly "modern", I know, but that's how it is at the moment :-)

Regards,
p.

27 Mar 2016, 2:52 PM
#365
fjbern1943 avatar

fjbern1943

Zen Follower

Join Date:
Apr 2015
Location:
United States
Posts:
144
Plugin Contributions:
0

Re: Creating an add-on "product type book" for ZC 1.5

philou:

Hi Frank,

the metatags are included by core ZEN CART functionality, not by BookX. You can verify this, by looking at the "normal" product folder in ADMIN/includes/modules/product. It also has extra collect_info_metatags.php and that has nothing to do with BookX.
As a convenience not to have to add code to the collect_info.php directly, BookX provides this extra include functionality, so your modifications do not break when an update comes along.

I don not ucrrently use user friendly URIs. Not exactly "modern", I know, but that's how it is at the moment :-)

Regards,
p.

OK Thanks p.
Yes I understand this functionality of Bookx and it works great for the metatags.

I will have to investigate more on my ceon problem or maybe switch to another friendly url mod.

In the meantime on my add to cart page I get "TEXT_PRODUCT_MANUFACTURERCanon" instead of "Manfacturer Canon"

Using the Developer Tool Kit I see:

/hsphere/local/home/religiousbooks/religiousbookshop.com/includes/templates/responsive_sheffield_blue/templates/tpl_product_bookx_info_display.php

Line #575 : echo (($flag_show_product_info_manufacturer == 1 and !empty($manufacturers_name)) ? '<li>' . TEXT_PRODUCT_MANUFACTURER . $manufacturers_name . '</li>' : '') . "\n";

Does this file need to be changed in some way?

Best regards,

Frank

27 Mar 2016, 3:33 PM
#366
philou avatar

philou

Zen Follower

Join Date:
Jan 2006
Posts:
165
Plugin Contributions:
1

Re: Creating an add-on "product type book" for ZC 1.5

Hi fj,

your are right, this definition seems to be missing from the language file of BookX. If the name of the constant is output to screen, then it means the constant is not defined.

in ZC/includes/languages/english/product_info.php there is the definition

17: define('TEXT_PRODUCT_MANUFACTURER', 'Manufactured by: ');  

but in ZC/includes/languages/english/product_bookx_info.php the above line is missing. Please add it to your language file in: ZC/includes/languages/YOURLANGUAGE/product_bookx_info.php and I will insert it in the next release.

Regards,
p.

27 Mar 2016, 3:46 PM
#367
fjbern1943 avatar

fjbern1943

Zen Follower

Join Date:
Apr 2015
Location:
United States
Posts:
144
Plugin Contributions:
0

Re: Creating an add-on "product type book" for ZC 1.5

Thanks p.

That did the trick!

Best regards,

Frank

27 Mar 2016, 9:29 PM
#368
mesnitu avatar

mesnitu

Totally Zenned

Join Date:
Aug 2014
Location:
Lisbon
Posts:
597
Plugin Contributions:
0

Re: Creating an add-on "product type book" for ZC 1.5

First let me thank you very, very much for easy populate/bookx plugin! Installed and working without a glitch. using Easy Populate 4.0.33a - Beta 02-29-2016 w/ BookX0.9.9

During this week, I'm hopping to commit some more changes to the ep4bookx, cause I found some issues related to 151, and in the way found some other minor issues that must be fix.
So please follow the suggestion and make your changes in a local machine to check if everything is ok.

When I tried to implement the changes you outlined above, I got the ceon uri code at the top of the collect_info page

But it's not working ? Do you have the CEON fields in the product edit ?

Checking my file collect_info.php from CEON I got this:

<tr>
            <td class="main"><?php echo TEXT_PRODUCTS_SORT_ORDER; ?></td>
            <td class="main"><?php echo zen_draw_separator('pixel_trans.gif', '24', '15') . ' ' . zen_draw_input_field('products_sort_order', $pInfo->products_sort_order); ?></td>
          </tr>
                          <?php if (isset($extra_html_end)) echo $extra_html_end; // this was possibly filled by an included file above ?>
<?php // BEGIN CEON URI MAPPING 2 of 2
       echo $ceon_uri_mapping_admin->collectInfoBuildURIMappingFields();
// END CEON URI MAPPING 2 of 2 ?>
        </table></td>
      </tr>
      <tr>
        <td><?php echo zen_draw_separator('pixel_trans.gif', '1', '10'); ?></td>
      </tr>

And the **collect_info_seo.php **

    // BEGIN CEON URI MAPPING 1 of 2
    require_once(DIR_WS_CLASSES . 'class.CeonURIMappingAdminProductPages.php');
    
    $ceon_uri_mapping_admin = new CeonURIMappingAdminProductPages();
    
    $ceon_uri_mapping_admin->collectInfoHandler();
    
    // END CEON URI MAPPING 1 of 2 

    //$extra_html_end .= '<!-- BEGIN CEON URI MAPPING 2 of 2 -->' . $ceon_uri_mapping_admin->collectInfoBuildURIMappingFields() . '<!-- END CEON URI MAPPING 2 of 2 -->'; 

Hope it helps.

“Though the problems of the world are increasingly complex, the solutions remain embarrassingly simple.” ― Bill Mollison

27 Mar 2016, 9:33 PM
#369
drbyte avatar

drbyte

Sensei

Join Date:
Jan 2004
Posts:
63,515
Plugin Contributions:
176

Re: Creating an add-on "product type book" for ZC 1.5

I recommend that if you're going to create separate files for Ceon stuff, that you use Ceon in the filename. So, collect_info_seo.php would be collect_info_ceon.php instead. That way you know it's for Ceon, instead of assuming that Ceon is synonymous with "seo"

.
Zen Cart - putting the dream of business ownership within reach of anyone!
Donate to: DrByte directly or to the Zen Cart team as a whole

Remember: Any code suggestions you see here are merely suggestions. You assume full responsibility for your use of any such suggestions, including any impact ANY alterations you make to your site may have on your PCI compliance.
Furthermore, any advice you see here about PCI matters is merely an opinion, and should not be relied upon as "official". Official PCI information should be obtained from the PCI Security Council directly or from one of their authorized Assessors.

28 Mar 2016, 9:27 AM
#370
mesnitu avatar

mesnitu

Totally Zenned

Join Date:
Aug 2014
Location:
Lisbon
Posts:
597
Plugin Contributions:
0

Re: Creating an add-on "product type book" for ZC 1.5

Yes you are right. it should have ceon as good practice.

The include file, it's because the bookx product type allows those extra include ( witch the normal product should do too in my opinion , for the code and html).
In the normal product , that ceon code it's "manually" inserted bellow

$products_description = $_POST['products_description'];
      $products_url = $_POST['products_url'];
    } 

The bookx product type allows that one include, but on the html side another one is needed, so on updates, it will "override" that code any way.
So fjbern1943 , if you have the ceon stuff working on the normal product, just take a good look, use the "search" in your software or open a side by side window. What's on the normal product has to be the in the bookx product type also.

good luck

“Though the problems of the world are increasingly complex, the solutions remain embarrassingly simple.” ― Bill Mollison

10 Apr 2016, 2:03 PM
#371
mesnitu avatar

mesnitu

Totally Zenned

Join Date:
Aug 2014
Location:
Lisbon
Posts:
597
Plugin Contributions:
0

Re: Creating an add-on "product type book" for ZC 1.5

fjbern1943:

First let me thank you very, very much for easy populate/bookx plugin! Installed and working without a glitch. using Easy Populate 4.0.33a - Beta 02-29-2016 w/ BookX0.9.9

I know it has been some time since I tried to implement the ceon URI mods you stated above but I could never get it to work as intended. Could you provide some help at this time? My setup:
Zen Cart 1.54
Responsive_sheffield_blue v2.0 template
Bookx version 0.9.4 r8
PHP Version 5.3.29

When I tried to implement the changes you outlined above, I got the ceon uri code at the top of the collect_info page and could not get any further, and of course no ceon box at the bottom of the page, so could we start there if you have the time. There were other problems but I thought if I could get the collect_info.php working I might be able to figure out the other pages and maybe the metatags problems also.

Best regards,

Frank

I think I might missed mentioning another file:
did you made changes to **admin/product_bookx.php ** ?

I was updating to 155 and redoing this ... I don't think I've mentioned this.

“Though the problems of the world are increasingly complex, the solutions remain embarrassingly simple.” ― Bill Mollison

10 Apr 2016, 6:25 PM
#372
mesnitu avatar

mesnitu

Totally Zenned

Join Date:
Aug 2014
Location:
Lisbon
Posts:
597
Plugin Contributions:
0

Re: Creating an add-on "product type book" for ZC 1.5

About the second step , now that I'm redoing it, I see that one can't use the $extra_html_end ( or at least I can't )

the Ceon it's building or collecting some info, that appears to need to be at the end. But this doesn't echo the object.
It only prints the checkbox , but not the text field.

$extra_html_end .= "<!-- BEGIN CEON URI MAPPING 2 of 2 -->" . $ceon_uri_mapping_admin->collectInfoBuildURIMappingFields() . "<!-- END CEON URI MAPPING 2 of 2 -->";

Or even saying that $extra_html_end = that object to print it at the end, doesn't work. ( or I don't know how to make it work )
So, using this :

<td class="main"><?php echo zen_draw_separator('pixel_trans.gif', '24', '15') . ' ' . zen_draw_input_field('products_sort_order', $pInfo->products_sort_order); ?></td>
          </tr>
<?php // BEGIN CEON URI MAPPING 2 of 2
  echo $ceon_uri_mapping_admin->collectInfoBuildURIMappingFields();
// END CEON URI MAPPING 2 of 2 ?>
        </table></td>

It's ok.

“Though the problems of the world are increasingly complex, the solutions remain embarrassingly simple.” ― Bill Mollison

10 Apr 2016, 7:34 PM
#373
mesnitu avatar

mesnitu

Totally Zenned

Join Date:
Aug 2014
Location:
Lisbon
Posts:
597
Plugin Contributions:
0

Re: Creating an add-on "product type book" for ZC 1.5

I've sent to git the files needed for bookx / ceon.
I'm on zc155 with bookx 0.95
But I think it's working, new bookx, updates, and move the book to other categories...
Hope it helps... and for me it's good too in the future, because it's very boring to do all this stuff all over again.

https://github.com/mesnitu/Ceon-BookX

“Though the problems of the world are increasingly complex, the solutions remain embarrassingly simple.” ― Bill Mollison

11 Apr 2016, 3:28 PM
#374
mesnitu avatar

mesnitu

Totally Zenned

Join Date:
Aug 2014
Location:
Lisbon
Posts:
597
Plugin Contributions:
0

Re: Creating an add-on "product type book" for ZC 1.5

Right
I was in pain, because I was following my own tips... this files have to be changed too :

In ceon_uri_mapping_filenames.php add :
define('FILENAME_PRODUCT_BOOKX_INFO', 'product_bookx_info');

In ceon_uri_mapping_product_pages.php add :
FILENAME_PRODUCT_BOOKX_INFO,

“Though the problems of the world are increasingly complex, the solutions remain embarrassingly simple.” ― Bill Mollison

12 Apr 2016, 8:41 PM
#375
mesnitu avatar

mesnitu

Totally Zenned

Join Date:
Aug 2014
Location:
Lisbon
Posts:
597
Plugin Contributions:
0

Re: Creating an add-on "product type book" for ZC 1.5

I just realize now that this new version has the breacrumb :) Nice !

Have you try this one on zv155 ?
I'm having a litle situation with product listing , that I recall mentioning some time ago.

I think it was on zc151 that I couldn't do it also.

Now I have a zc154 that I was making, only with zc and bookx. And it was ok.

Now, I have zc155, but I already have, the ceon, reward points, image handler, sitemapxml.
But probably this could be related to the ceon, since he's too in the index_product_listing .
But , I already remove ceon code from that page, just to test it... but no results.

making a var_dump($extra_bookx_filter_term_info);

I'll get NULL .

This is the array with bookx extra info, right ?

Or I should be looking somewhere else ?

In zc154 I was using some module for layout in columns or rows.... but I think that zen155 already has this.

Anyway, perhaps you could guide me were to look.

Thanks

“Though the problems of the world are increasingly complex, the solutions remain embarrassingly simple.” ― Bill Mollison

13 Apr 2016, 11:06 AM
#376
mesnitu avatar

mesnitu

Totally Zenned

Join Date:
Aug 2014
Location:
Lisbon
Posts:
597
Plugin Contributions:
0

Re: Creating an add-on "product type book" for ZC 1.5

Well, the only way that I can get that extra info on listings is changing the observer around line 568 from

if ($product_name_column) {
				$listing->Move(0);
				$listing->cursor = 0;

to :

if (isset($product_name_column)) {
                 		$listing->Move(0);
				$listing->cursor = 0;

Some php version.... thing ?

the $product_name_column is 0 in the listing array... so he's there, but only using the if ($product_name_column) , I don't get inside that IF

“Though the problems of the world are increasingly complex, the solutions remain embarrassingly simple.” ― Bill Mollison

13 Apr 2016, 1:32 PM
#377
mesnitu avatar

mesnitu

Totally Zenned

Join Date:
Aug 2014
Location:
Lisbon
Posts:
597
Plugin Contributions:
0

Re: Creating an add-on "product type book" for ZC 1.5

There's a litle addition that could be made in bookx observer class, to get the right canonical url :

Now if one filters ie: a publisher ,
?main_page=index&typefilter=bookx&bookx_publisher_id=36

the canonical url is the home page

<link rel="canonical" href="http://pb155.local:8080/" />

But there are notifies in the init_canonical.php that could be use.
so in the bookx observer, one could add on function productTypeFilterObserver() :

,'NOTIFY_MODULE_PRODUCT_LISTING_ALPHA_SORTER_BEGIN'
,'NOTIFY_INIT_CANONICAL_PARAM_WHITELIST'
 ,'NOTIFY_INIT_CANONICAL_DEFAULT'   
	   					 )

On function update()

 case 'NOTIFY_INIT_CANONICAL_PARAM_WHITELIST':
			    $this->insert_bookx_canonical($callingClass, $notifier, $paramsArray);
			    break;
            
case 'NOTIFY_INIT_CANONICAL_DEFAULT':
			    $this->insert_bookx_canonical_case_default($callingClass, $notifier, $paramsArray);
			    break; 

And add this ( this is just a test )

   
 //$zco_notifier->notify ('NOTIFY_INIT_CANONICAL_PARAM_WHITELIST', $current_page, $excludeParams, $keepableParams, $includeCPath);
    function insert_bookx_canonical(&$callingClass, $notifier, $paramsArray) {
        global $keepableParams;
        $keepableParams[] = 'bookx_publisher_id';
       
    }

    //$zco_notifier->notify ('NOTIFY_INIT_CANONICAL_DEFAULT', $current_page, $excludeParams, $canonicalLink);
    function insert_bookx_canonical_case_default(&$callingClass, $notifier, $paramsArray) {
       
        global $db, $keepableParams, $current_page, $excludeParams, $canonicalLink;


        switch ( true ) {
            case ($current_page == FILENAME_DEFAULT && isset($_GET['typefilter']) && $_GET['typefilter'] != '' && ( (isset($_GET['bookx_publisher_id']) && $_GET['bookx_publisher_id'] != '' ) ) ):
                unset($excludeParams[array_search('typefilter', $excludeParams)]);
                $canonicalLink = zen_href_link($current_page, zen_get_all_get_params($excludeParams), 'NONSSL', false);
                break;
        }
    }

So now the canonical link is :

<link rel="canonical" href="http://pb155.local:8080/index.php?main_page=index&typefilter=bookx&bookx_publisher_id=36" />

I have made a query to add the publisher name to the canonical link... but I'm not sure if that is good...to have a url link and the canonical link different.

“Though the problems of the world are increasingly complex, the solutions remain embarrassingly simple.” ― Bill Mollison

28 May 2016, 8:44 AM
#378
mesnitu avatar

mesnitu

Totally Zenned

Join Date:
Aug 2014
Location:
Lisbon
Posts:
597
Plugin Contributions:
0

Re: Creating an add-on "product type book" for ZC 1.5

Hi
About the filters.
I think the filters , always filters all authors, series, etc... even if they don't have a book associated.

But there's a option, on listing, to display books out of stock from authors, etc...

But out of stock is different from a book id that doesn't exist anymore....

I've done this primary simple thing, to just filter series that has books associated. I think this makes sense, but probably I' missing something.

$bookx_filter_values_query = 'SELECT DISTINCT bs.bookx_series_id, bsd.series_name, be.bookx_series_id
		                          FROM ' . TABLE_PRODUCT_BOOKX_SERIES . ' bs
                                  LEFT JOIN ' . TABLE_PRODUCT_BOOKX_EXTRA . ' be ON bs.bookx_series_id = be.bookx_series_id   
		                          LEFT JOIN ' . TABLE_PRODUCT_BOOKX_SERIES_DESCRIPTION . ' bsd ON bs.bookx_series_id = bsd.bookx_series_id AND bsd.languages_id = "' . (int)$_SESSION['languages_id'] . '"'
		                        . (!empty($extra_filter_query_parts['join_multi_filter']) ? $extra_filter_query_parts['join_multi_filter'] . ' ON be.bookx_series_id = bs.bookx_series_id ' : '')
		                        . bookx_assemble_filter_extra_join($extra_filter_query_parts['join'], array('series'))
                              . ' WHERE 1 ' . bookx_assemble_filter_extra_where($extra_filter_query_parts['where'], array('series'))
		                      . ' ORDER by bs.series_sort_order, bsd.series_name';

	$bookx_series = $db->Execute ( $bookx_filter_values_query );

And on the while loop

while ( ! $bookx_series->EOF ) {
            
            if ($bookx_series->fields['bookx_series_id'] !='') {
                
                $bookx_series_name = ((strlen ( $bookx_series->fields ['series_name'] ) > ( int ) BOOKX_MAX_DISPLAY_FILTER_DROPDOWN_LEN) ? substr ( $bookx_series->fields ['series_name'], 0, ( int ) BOOKX_MAX_DISPLAY_FILTER_DROPDOWN_LEN ) . '..' : $bookx_series->fields ['series_name']);
			$bookx_series_array [] = array (
					'id' => $bookx_series->fields ['bookx_series_id'],
					'text' => $bookx_series_name
			);
            }
			
			$bookx_series->MoveNext ();
		}

I think this makes more sense ? , or could be a future to have in a configuration option....to list everything even if there's no books anymore.
But personalty, I think, that it's a lot of "dead" links for a customer.

Another nice feature, would be a admin routine, upon admin click, to delete all series, etc... that don't have books anymore.

“Though the problems of the world are increasingly complex, the solutions remain embarrassingly simple.” ― Bill Mollison

28 May 2016, 8:59 AM
#379
mesnitu avatar

mesnitu

Totally Zenned

Join Date:
Aug 2014
Location:
Lisbon
Posts:
597
Plugin Contributions:
0

Re: Creating an add-on "product type book" for ZC 1.5

To avoid issues on series_id, probably better to replace with this:

$bookx_filter_values_query = 'SELECT DISTINCT bs.bookx_series_id, bsd.series_name, bxe.bookx_series_id as series_books

LEFT JOIN ' . TABLE_PRODUCT_BOOKX_EXTRA . ' bxe ON bs.bookx_series_id = bxe.bookx_series_id

if ($bookx_series->fields['series_books'] !='') {

“Though the problems of the world are increasingly complex, the solutions remain embarrassingly simple.” ― Bill Mollison

29 May 2016, 12:32 PM
#380
mesnitu avatar

mesnitu

Totally Zenned

Join Date:
Aug 2014
Location:
Lisbon
Posts:
597
Plugin Contributions:
0

Re: Creating an add-on "product type book" for ZC 1.5

After all the logic is wrong. Some sort of products status must be made...
Meanwhile, I've done so, but possibly some more checking should be made.
Perhaps later, this could go into another level.

$bookx_filter_values_query = 'SELECT DISTINCT bs.bookx_series_id, bsd.series_name, bxe.bookx_series_id as series_books, p.products_status
		                          FROM ' . TABLE_PRODUCT_BOOKX_SERIES . ' bs
                                  LEFT JOIN ' . TABLE_PRODUCT_BOOKX_EXTRA . ' bxe ON bs.bookx_series_id = bxe.bookx_series_id   
		                          LEFT JOIN ' . TABLE_PRODUCT_BOOKX_SERIES_DESCRIPTION . ' bsd ON bs.bookx_series_id = bsd.bookx_series_id AND bsd.languages_id = "' . (int)$_SESSION['languages_id'] . '"
                                  LEFT JOIN ' . TABLE_PRODUCTS . ' p ON p.products_id = bxe.products_id '
		                        . (!empty($extra_filter_query_parts['join_multi_filter']) ? $extra_filter_query_parts['join_multi_filter'] . ' ON be.bookx_series_id = bs.bookx_series_id ' : '')
		                        . bookx_assemble_filter_extra_join($extra_filter_query_parts['join'], array('series'))
                              . ' WHERE 1 AND p.products_status !=0 ' . bookx_assemble_filter_extra_where($extra_filter_query_parts['where'], array('series'))
		                      . ' ORDER by bs.series_sort_order, bsd.series_name';

“Though the problems of the world are increasingly complex, the solutions remain embarrassingly simple.” ― Bill Mollison