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

    #31
    Can this be used to show a total of subsections within a section? (eg spp pages)



    PS Excuse me if its obvious but I'm a fool.
    Football Heaven

    For all kinds of football souvenirs and memorabilia.

    Comment


      #32
      this solution counts all products, below a certain section, example:

      Code:
      - Main section 1 (6 products)
        - Sub 1 (3 Products)
            - Prod
            - Prod
            - Prod
      
        - Sub 2 (1 Products)
            - Prod
      
        - Sub 3 (2 Products)
          - SubSub 3 (1 Product)
              - Prod
          - SubSub 3 (1 Product)
              - Prod
      it can be set to count sections, but i dont really think theres any point, considering that it already understands where products are in trees. This is how I saw more complex online stores, doing it.

      The way its implimented, you can put it in section layouts, or even in section lists. As long as SectionID is exposed, it can pull out the products down-tree of that ID.

      Comment


        #33
        I was wondering if there is an updated version of this code, or maybe a different way to achieve displaying a total no. of products within a section and sub-sections?

        This post is quite old now and I'm having issues getting it working.
        Web . Design . Multimedia . Branding

        Comment


          #34
          Richard. If you're using SD 2013, you may be having problems with this bug.
          Norman - www.drillpine.biz
          Edinburgh, U K / Bitez, Turkey

          Comment


            #35
            Duncan: This was actually on a V11 site, so no.

            Could the code from your link be used to achieve a total products count?
            Web . Design . Multimedia . Branding

            Comment


              #36
              No, but such code is already on the Community. Try searching.
              Norman - www.drillpine.biz
              Edinburgh, U K / Bitez, Turkey

              Comment


                #37
                I have, which led me to this thread.

                I haven't found any other examples, but maybe I'm using the wrong keywords. I'll try again.
                Web . Design . Multimedia . Branding

                Comment


                  #38
                  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>
                  Norman - www.drillpine.biz
                  Edinburgh, U K / Bitez, Turkey

                  Comment


                    #39
                    Thanks Norman, that's brilliant! I had found bits and pieces but as you said, it was a tad spread out.

                    Thanks so much for collating this. I'll try it on my client site.
                    Web . Design . Multimedia . Branding

                    Comment


                      #40
                      Update. Just edited my above post to make it cleaner.

                      And a warning that it won't work in SD 2013 V12.0.0 and 12.0.1 until a bug is SD is fixed.
                      Norman - www.drillpine.biz
                      Edinburgh, U K / Bitez, Turkey

                      Comment


                        #41
                        Top man! Thanks again.
                        Web . Design . Multimedia . Branding

                        Comment


                          #42
                          Hi there, following on from what NormanRouxel has kindly suggested, I am trying to get the code to only show the price if there is only one product in the section.
                          The following code does this in two steps,
                          1 count all products in a section;
                          2 if more than one product from skip.

                          However the if statement is not working and is always true! see below


                          Code:
                          			<actinic:block php="true">$productsonpage = 0;</actinic:block>
                          			<actinic:block type="ProductList"><actinic:block php="true">if ( '<actinic:variable name="ProductName" encoding="perl" selectable="false" />' ) $productsonpage++;</actinic:block></actinic:block>
                          							
                          			<actinic:block if="%24productsonpage%20%3c%202" >
                          				<actinic:block type="ProductList" >
                          					<actinic:block type="PriceList" >
                          						<actinic:variable name="PriceLayout" value="Compact Tax Inclusive Price" />
                          						</actinic:block> 
                          					</actinic:block>
                          				</actinic:block>
                          			</actinic:block>

                          What have I done wrong .

                          Comment


                            #43
                            You cannot use PHP variables in BlockIf's. They are not in scope there.
                            Norman - www.drillpine.biz
                            Edinburgh, U K / Bitez, Turkey

                            Comment


                              #44
                              Code:
                              <actinic:block php="true">
                              if ($productsonpage < 2)
                              	{
                              	$html = <<<ENDOFCODE
                              	Actinic code goes here
                              ENDOFCODE;	// NB this line must not be indented
                              	echo $html;
                              	}
                              </actinic:block>
                              Norman - www.drillpine.biz
                              Edinburgh, U K / Bitez, Turkey

                              Comment


                                #45
                                Norman thanks for the reply.

                                Initially I got a PHP Parse error. But now I seem to have it working. Code below

                                Code:
                                <actinic:block php="true">$productsonpage = 0;</actinic:block>
                                <actinic:block type="ProductList"><actinic:block php="true">if ( '<actinic:variable name="ProductName" encoding="perl" selectable="false" />' ) $productsonpage++;</actinic:block></actinic:block>
                                
                                <actinic:block php="true">
                                <actinic:block type="ProductList" >
                                <actinic:block type="PriceList" >
                                if($productsonpage == 1)
                                {
                                $html = <<<ENDOFCODE
                                <actinic:variable name="PriceLayout" value="Compact Tax Inclusive Price" />
                                ENDOFCODE;
                                echo $html;
                                }
                                </actinic:block>
                                </actinic:block>
                                </actinic:block>

                                Comment

                                Working...
                                X