Announcement

Collapse
No announcement yet.

Is it possible to show number of products per section / sub-section

Collapse
X
 
  • Filter
  • Time
  • Show
Clear All
new posts

    #46
    You probablty did nothing wrong but is was the PHP integration within SD that was misbehaving.

    I've noticed that PHP heredoc syntax in particular often produces syntax errors and restructuring the code or putting a dummy statement on a new line after the ENDOFCODE; may inexplicably fix it.
    Norman - www.drillpine.biz
    Edinburgh, U K / Bitez, Turkey

    Comment


      #47
      Originally posted by NormanRouxel View Post
      Most of the code you need is spread around the Community. Here's it collected together into a single working lump:
      Code:
      <actinic:block php="true">
      	$count = 0;
      	<actinic:block type="ProductList" if="%3cactinic%3avariable%20name%3d%22ProductType%22%20%2f%3e%20%3d%3d%200" >$count++;</actinic:block>	
      	<actinic:block type="ChildSectionList">			
      		<actinic:block type="ProductList" if="%3cactinic%3avariable%20name%3d%22ProductType%22%20%2f%3e%20%3d%3d%200" >$count++;</actinic:block>
      		<actinic:block type="ChildSectionList">			
      			<actinic:block type="ProductList" if="%3cactinic%3avariable%20name%3d%22ProductType%22%20%2f%3e%20%3d%3d%200" >$count++;</actinic:block>	
      			<actinic:block type="ChildSectionList">			
      				<actinic:block type="ProductList" if="%3cactinic%3avariable%20name%3d%22ProductType%22%20%2f%3e%20%3d%3d%200" >$count++;</actinic:block>	
      				<actinic:block type="ChildSectionList">			
      					<actinic:block type="ProductList" if="%3cactinic%3avariable%20name%3d%22ProductType%22%20%2f%3e%20%3d%3d%200" >$count++;</actinic:block>
      				</actinic:block>
      			</actinic:block>
      		</actinic:block>
      	</actinic:block>
      	echo "Products: $count";
      </actinic:block>
      I have used Norman's code exactly as it is shown above (I am using SellerDeck 12.0.3 NLPA) and it seems to be calculating the number of products perfectly well on all sections of my website apart from one section, and it is really flummoxing me as to why.

      If anybody has a moment to check, please see the product count calculated for the 5th sub-section (Half-Price Sale) on my Flesh Tunnels & Plugs page. It states that there are 32 products in the section, however, if you go into the section you will see from the pagination links that there are actually 79 products in there. My pagination is set to 32 products per page and I wonder if it's not a coincidence that the count code has displayed '32'.

      I have tried creating a new section, as well as moving some (and all) of the products from the half-price sale into other sections where the count does work, but it just then changes the count for that section to '32'. It's like the products are taking the gremlin with them! But, on the other hand, I then moved 90 products from a section where the count worked, into the section that didn't work (half-price sale) and the count changed to '32'. So my gremlin theory failed. I also tried moving the position of the half-price section from 5th to, say, 2nd - that didn't work. I have compared all of the settings of the half-price sale section to those of other sections, and they all seem to match completely.

      If I have less than 32 products in the Half-Price Sale section, the count is calculated correctly. If I have any number of products higher than 32 in the Half-Price Sale section, the count says '32'.

      I have inserted Norman's code at the bottom of the code that I have in 'Section Link Within A Box'. So the two chunks of code together, as I have them at the moment, are shown below:-

      Code:
      <table width="100%" border="0" cellspacing="15" cellpadding="10" class="thinborder1">
         <tr>
            <td align="left" height="35" bgcolor="<actinic:variable name="Palette1" />"><span class="boxheading"><a href="<actinic:block if="%28%3cactinic%3avariable%20name%3d%22IsFilteringPageAsDefaultView%22%20%2f%3e%20%3d%3d%20False%29%20AND%0d%3cactinic%3avariable%20name%3d%22IsLoginPageSuppressed%22%20%2f%3e%20AND%0d%3cactinic%3avariable%20name%3d%22UnregCustomersAreNotAllowed%22%20%2f%3e" ><actinic:variable name="SectionPageName" /></actinic:block><actinic:block if="%3cactinic%3avariable%20name%3d%22IsFilteringPageAsDefaultView%22%20%2f%3e%20OR%0d%28%3cactinic%3avariable%20name%3d%22IsLoginPageSuppressed%22%20%2f%3e%20%3d%3d%20false%29%20OR%0d%28%3cactinic%3avariable%20name%3d%22UnregCustomersAreNotAllowed%22%20%2f%3e%20%3d%3d%20false%29" ><actinic:variable name="SectionURL" /></actinic:block>" class="boxlink"><actinic:variable formatting="font(Size|12)" name="SectionName" /></a></span></td>
         </tr>
         <tr>
            <td>
               <table border="0" cellspacing="0" cellpadding="0" align="center">
                  <tr> 
                     <td valign="top">
                        <a href="<actinic:block if="%28%3cactinic%3avariable%20name%3d%22IsFilteringPageAsDefaultView%22%20%2f%3e%20%3d%3d%20False%29%20AND%0d%3cactinic%3avariable%20name%3d%22IsLoginPageSuppressed%22%20%2f%3e%20AND%0d%3cactinic%3avariable%20name%3d%22UnregCustomersAreNotAllowed%22%20%2f%3e" ><actinic:variable name="SectionPageName" /></actinic:block><actinic:block if="%3cactinic%3avariable%20name%3d%22IsFilteringPageAsDefaultView%22%20%2f%3e%20OR%0d%28%3cactinic%3avariable%20name%3d%22IsLoginPageSuppressed%22%20%2f%3e%20%3d%3d%20false%29%20OR%0d%28%3cactinic%3avariable%20name%3d%22UnregCustomersAreNotAllowed%22%20%2f%3e%20%3d%3d%20false%29" ><actinic:variable name="SectionURL" /></actinic:block>" target="_self">
                           <img alt="<actinic:variable encoding="strip" name="SectionName" />" title="<actinic:variable encoding="strip" name="SectionName" />" src="<actinic:variable name="SectionImageFileName" />"border="0" />
                        </a>
                        <br>
                     </td>
      <!--               <td align="left" valign="bottom">
                        <actinic:variable name="SectionDescription" />
      						<br><br>
                     </td> -->
                  </tr>
                  <tr>
               </table><actinic:block php="true">
      	$count = 0;
      	<actinic:block type="ProductList" if="%3cactinic%3avariable%20name%3d%22ProductType%22%20%2f%3e%20%3d%3d%200" >$count++;</actinic:block>	
      	<actinic:block type="ChildSectionList">			
      		<actinic:block type="ProductList" if="%3cactinic%3avariable%20name%3d%22ProductType%22%20%2f%3e%20%3d%3d%200" >$count++;</actinic:block>
      		<actinic:block type="ChildSectionList">			
      			<actinic:block type="ProductList" if="%3cactinic%3avariable%20name%3d%22ProductType%22%20%2f%3e%20%3d%3d%200" >$count++;</actinic:block>	
      			<actinic:block type="ChildSectionList">			
      				<actinic:block type="ProductList" if="%3cactinic%3avariable%20name%3d%22ProductType%22%20%2f%3e%20%3d%3d%200" >$count++;</actinic:block>	
      				<actinic:block type="ChildSectionList">			
      					<actinic:block type="ProductList" if="%3cactinic%3avariable%20name%3d%22ProductType%22%20%2f%3e%20%3d%3d%200" >$count++;</actinic:block>
      				</actinic:block>
      			</actinic:block>
      		</actinic:block>
      	</actinic:block>
      	echo "Products: $count";
      </actinic:block>
      
            </td>
         </tr>
      </table>
      I had tarted the code up a bit with colour, alignment and a few lines which made it display different text depending on whether there are 0, 1 or >1 products in the section, however I have stripped it back for the purposes of this post.

      If anybody does have a bit of time to have a look at this, I would really welcome your comments. Thank you.

      Comment


        #48
        I have just noticed that the other four sections on Flesh Tunnels & Plugs contain sub-sections, whereas the half-price sale section does not. I wonder if this is anything to do with it? I will go through the whole site now and see if I can find the same kind of thing happening elsewhere.

        Edited to say: following the above, I just created a sub-section in the half-price sale section (so that it matched all of its fellow sections in terms of having a sub-section) and moved all of the sale products into that new sub-section, but this made no difference. The count still said '32' for the half-price sale section and the new sub-section that I had just created also had a count of '32' (even though there were 79 products in there).
        Last edited by MrsBee; 22-Feb-2014, 07:54 PM. Reason: Update

        Comment

        Working...
        X