Page 1 of 1

Override wishlist.containsSku

Posted: Sun Feb 21, 2016 8:47 pm
by wzzhy001
Hello.

At first,I want product could add to wishlist without it`s attribute,like "color","size".

But now,I choose the way that check the product`s attribute and make it default value to save into wishlist. It works well, I make the attribute hidden in the front site.

Now, I use this way to check whether the product has saved in the wishlist.

Code: Select all

<div th:class="${'productActions' + #object.id}">
      <blc:named_order orderVar="wishlist" orderName="wishlist" />
        <div class="in_wishlist" th:classappend="${!wishlist.containsSku(#object.defaultSku)}? ' hidden'">
            <a href="/account/wishlist" class="add_wish">
                <span>in wishlist</span>
                <i class="iconfont">&#xe603;</i>
           </a>
        </div>
        <div class="add_to_wishlist" th:classappend="${wishlist.containsSku(#object.defaultSku)}? ' hidden'">
          <blc:form method="POST" th:action="@{/account/wishlist/add}">   
             <input type="hidden" name="productId" th:value="*{id}" />
             <input type="hidden" name="quantity" value="1" />
             <div class="add_wish addToWishlist">
                  <span>into wishlist</span>
                <i class="iconfont">&#xe602;</i>
               </div>
          </blc:form>
        </div>
   </div>


And the question is the main page could not check the product correctly. Because only the default attribute has saved into the wishlist. So the main page could not show the "in wishlist".

Then I search the method ".containsSku", it belong to OrderImpl.

So I wanna to override the OrderImpl and check the Order.name whether it is "wishlist", and make it other way to check wishlist.

But I just know how to extend an Entity, and it is different from overriding a Service.

How to Override the OrderImpl or it has another method to check whether the product inwishlist without attributes.

My English is poor,excuse me. Please help me. Thank you. The email would make me reply quickly: 344105304@qq.com

Re: Override wishlist.containsSku

Posted: Tue Jul 25, 2017 4:20 pm
by phillipuniverse
I think that the best thing to do in this case is to add another method for containsProduct() that is similar to containsSku() but looks for Product matches instead. Sounds like that is essentially what you want.

Since this is just a helper method and you don't actually want to add another column to the database it makes more sense to do this in a service or in a variable expression on the frontend. You can look for implementations of BroadleafVariableExpression as a starting point on adding these utilities to the frontend.

The Broadleaf forums are being retired as a readonly archive of questions. For active discussions and questions, check out the broadleaf-commerce tag on Stack Overflow which is actively monitored by the Broadleaf team.