0

I have some problem with my category-product relationship. I am using junction object to connect product and category with master-detail, but it gives me an error in my component that i dont get.

Error: Action failed: c:ProductCategoryList$controller$selectCategory [Cannot read property 'setParams' of undefined]

There are code:

<aura:component implements="flexipage:availableForAllPageTypes"  controller="ProductCategoryController" >
<aura:registerEvent 
                    name="updateFilterEvent" 
                    type="c:UpdateFilterEvent"
                    />

<aura:handler 
              name="init" 
              action="{!c.doInit}" 
              value="{!this}"
              />

<aura:handler 
              event="c:CategorySelectEvent"
              action="{!c.selectCategory}"
              />

<aura:attribute 
                name="productCategories" 
                type="ProductCategory__c[]"
                />

 <aura:attribute 
                name="selectedCategories" 
                type="ProductCategory__c[]"
                default="[]"
                />

<article class='slds-card'>
    <header class="slds-card__header slds-grid">
        <div class="slds-col slds-size_2-of-12">
            <lightning:buttonIcon 
                                  onclick="{!c.toPrevCategories}"
                                  iconName="utility:back" 
                                  variant="brand" 
                                  alternativeText="Back" 
                                  iconClass="dark"
                                  />
        </div>
        <div class="slds-col slds-align_absolute-center">
              Категории:
        </div>
    </header>
    
    <div class="slds-card__body slds-card__body_inner">
        <ul class="slds-has-dividers_around-space">
            <aura:iteration  items="{!v.productCategories}" var="category">
                <c:ProductCategoryListItem category="{!category}"/>
            </aura:iteration>
        </ul>
    </div>
</article> 
 </aura:component>

And controller:

({
doInit : function(component, event, helper) {
    helper.getChildCategories(component);
},

selectCategory: function(component, event, helper){
    let category = event.getParam("category");
    
    let selectedCategories =component.get("v.selectedCategories"); 
    
    selectedCategories.push(category.ProductCategoryParent__c); 

    component.set("v.selectedCategories", selectedCategories);

    helper.getChildCategories(component,category.Id);
    
    _storeUtil.fireWithParams(
        "UpdateFilterEvent",
        {
            "filterParams":{
                "key": "category",
                "value": category.Id
            }
        }
    );      
},

toPrevCategories: function(component, event, helper){
    let prevSelectedCategory =component.get("v.selectedCategories").pop(); 
    helper.getChildCategories(component,prevSelectedCategory);
    
    _storeUtil.fireWithParams(
        "UpdateFilterEvent",
        {
            "filterParams":{
                "key": "category",
                "value": prevSelectedCategory
            }
        }
    );
},

})

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.