Announcement

Collapse
No announcement yet.

Filter products based on a foreign entity

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

  • Filter products based on a foreign entity

    Hello, I wondered, what were the exact steps to get to prefilter the products when filling out a sales order based on the brand value.

  • #2
    Can you ex-plane prefilter the products.

    Comment


    • Milko
      Milko commented
      Editing a comment
      Yes, for example:
      Into the sales order, I add a field called "vendor".
      Now, I need to filter the product by $vendor (brand), when I open the list to add the items into the Sales Order.

  • #3
    Hi,
    You can save own filter condition according to each brand value and use it upo selecting products in sales order. For example to create your own brand filter go to Products list view, configure a filter condition and press All -> Save filter (see attachments).
    Attached Files

    Comment


    • Milko
      Milko commented
      Editing a comment
      Thank you, but that solution only works with my user, if I want something wide to the organization?

  • #4
    Well, the easiest way is:
    1. In the Product entity create 'Varchar' field type and call it for example like 'hiddenBrandName'.
    2. Add Formula for the Product entity:
    Code:
    hiddenBrandName = brandName
    3. Recalculate formula for all Products.
    4. Create Product.php in espocrm/custom/Espo/Custom/SelectManagers
    Add this code into it:
    PHP Code:
    <?php

    namespace Espo\Custom\SelectManagers;

    class 
    Product extends \Espo\Modules\Sales\SelectManagers\Product
    {
        protected function 
    filterPhoenixolutions(&$result)
        {
            
    $result['whereClause'][] = array(
                
    'hiddenBrandName' => 'Phoenixolutions'
            
    );
        }
     }
    5. Create Product.json in espocrm/custom/Espo/Custom/Resources/metadata/clientDefs
    Configure the "filterList" parameter:
    Code:
    {
        "filterList": [
            "__APPEND__",
            {
                "name": "phoenixolutions"
            }
        ]
    }
    6. Cleare cache.


    You can also fetching brand by its id. In this way you do not need to create one more field and use Formula.
    Last edited by Maximus; 09-12-2019, 11:19 AM.

    Comment


    • Milko
      Milko commented
      Editing a comment
      Thank you!

  • #5
    You can also utilize Report Filter (if you have advanced pack). It allows adding filters to all users or users from specific team.

    Comment


    • Milko
      Milko commented
      Editing a comment
      Yes, I have the advanced pack, there is a way to use a variable instead of a fixed value into the report filter?
Working...
X