Results 1 to 4 of 4
  1. #1
    Join Date
    Feb 2009
    Posts
    123
    Plugin Contributions
    0

    Default Add text to all product descriptions in a category

    Hi,

    What table joins can I use to find all products in a given category?
    I initially thought that master_categories_id on the products table would be it, but when I query the table as

    SELECT * FROM products_description where master_categories_id = 100

    it throws the error

    Error: Unknown column 'master_categories_id' in 'where clause'
    SQLState: 42S22
    ErrorCode: 1054

    I know SQL but not a MySQL guy, so not sure how to use that column. Appreciate any tips!
    My install: was Vanilla 1.3.9h, now 1.5.5b, Apache 2.4, PHP 7.0.6, MySQL 5.5.8 64b, Windows 7 64b, 8GB RAM, i3 3.3gHz
    Modules: [Payment=Paypal] [Shipping=Canada Post 1.5.3 merged] [nonCAPTCHA]

  2. #2
    Join Date
    Feb 2009
    Posts
    123
    Plugin Contributions
    0

    Default Re: Add text to all product descriptions in a category

    Oops, master_category_id is in the products, not products_descriptions. The SQL should be like this:

    update products_description as d
    join products as p on p.products_id = d.products_id and p.master_categories_id = 100
    set d.products_description = concat(
    d.products_description
    ,'<p>NOTICE TO CUSTOMERS: ...'
    )
    WHERE d.products_description not like '%NOTICE TO CUSTOMERS%'

    And then it worked!
    My install: was Vanilla 1.3.9h, now 1.5.5b, Apache 2.4, PHP 7.0.6, MySQL 5.5.8 64b, Windows 7 64b, 8GB RAM, i3 3.3gHz
    Modules: [Payment=Paypal] [Shipping=Canada Post 1.5.3 merged] [nonCAPTCHA]

  3. #3
    Join Date
    Jul 2012
    Posts
    16,718
    Plugin Contributions
    17

    Default Re: Add text to all product descriptions in a category

    So, mind you this query doesn't necessarily find all product that appear in a category as for example if a product has the master_categories_id to one category it could be linked to another/many. So the question becomes do you want to work with product that have a base assignment to a particular category or product that appear in a category?

    For the latter there is another joining table products_to_categories where every category in which a product exists is listed and could result in additional product being updated as compared to the above query.
    ZC Installation/Maintenance Support <- Site
    Contribution for contributions welcome...

  4. #4
    Join Date
    Feb 2009
    Posts
    123
    Plugin Contributions
    0

    Default Re: Add text to all product descriptions in a category

    I do not have any of that, so it works for me.
    My install: was Vanilla 1.3.9h, now 1.5.5b, Apache 2.4, PHP 7.0.6, MySQL 5.5.8 64b, Windows 7 64b, 8GB RAM, i3 3.3gHz
    Modules: [Payment=Paypal] [Shipping=Canada Post 1.5.3 merged] [nonCAPTCHA]

 

 

Similar Threads

  1. v150 Zenid text intermittently populates all website product category links
    By BlightyExPat in forum General Questions
    Replies: 6
    Last Post: 11 Nov 2014, 04:34 AM
  2. How to add text on all product page?
    By hara in forum General Questions
    Replies: 4
    Last Post: 7 Jul 2011, 09:42 AM
  3. how to add the optiona name(text type) to all products under a category?
    By mybiz9999 in forum Setting Up Categories, Products, Attributes
    Replies: 3
    Last Post: 7 Aug 2010, 04:24 AM
  4. Add Text to top of Product Descriptions Page
    By bluelion in forum Templates, Stylesheets, Page Layout
    Replies: 5
    Last Post: 6 Sep 2008, 06:02 PM
  5. Replies: 10
    Last Post: 26 Oct 2006, 11:07 PM

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
disjunctive-egg
Zen-Cart, Internet Selling Services, Klamath Falls, OR