I created this class that is requesting large amount of data, I was getting this error:Collection size 1,156 exceeds maximum size of 1,000. And then I found an approach to fix this error, the code is below using an wrapper class that handles the limit. It works in the sandbox, but I don't have a lot of data there. So when I tested it in production I am getting this error: Response size exceeded 15MB organization limit. I couldn't find much help about this error. I don't know if there is something wrong in the code or there is a different approach. I will appreciate any help!
VF Page code:
<apex:pageBlock >
<apex:repeat value="{!thousandBlocks}" var="block">
<apex:pageBlockTable value="{!block.zeroInventory}" var="p" id="mid">
<apex:column value="{!p.Account__r.Name}"/>
<apex:column value="{!p.Name}"/>
<apex:column value="{!p.Product_Name__c}"/>
<apex:column value="{!p.Virtual_Amz__c}"/>
<apex:column value="{!p.Total_Inventory2__c}"/>
<apex:column value="{!p.Days_of_Inventory__c}"/>
<apex:column value="{!p.X24_Hr_Units__c}"/>
<apex:column value="{!p.X7_Day_Units__c}"/>
<apex:column value="{!p.X30_Day_Units__c}"/>
<apex:column value="{!p.X24_Hr_Units__c}"/>
<apex:column headerValue="Go To"> <span class="label label-success"><a href="https://na2.salesforce.com/{!p.id}" target="_blank" style="color:white;">Go to Product</a></span></apex:column>
</apex:pageBlockTable>
</apex:repeat>
</apex:pageBlock>
Class code:
public class dashBoardPOIssues {
private limitWrapper[] thousandBlocks = new limitWrapper[]{};
private final integer listLimit;
public dashBoardPOIssues(){
//for zero inventory
listLimit = 950;
}
//for zero inventory
public limitWrapper[] getthousandBlocks()
{
thousandBlocks = new limitWrapper[]{};
integer counter = 0;
integer loopCount = 0;
NRProducts__c[] tmpcase = new NRProducts__c[]{};
for(NRProducts__c c:[SELECT id, Name, Account__r.Name, ASIN__c,CreatedDate,Product_Name__c,Virtual_Amz__c,Total_Inventory2__c,Days_of_Inventory__c,X24_Hr_Units__c,X7_Day_Units__c,X30_Day_Units__c FROM NRProducts__c WHERE Total_Inventory2__c = 0 AND Buyer_lookup__c =:UserInfo.getUserId()])
{
if(counter < listLimit)
{
tmpcase.add(c);
counter++;
}
else
{
loopCount++;
thousandBlocks.add(new limitWrapper(tmpcase,loopCount));
tmpcase = new NRProducts__c[]{};
tmpcase.add(c);
counter = 0;
}
}
if(thousandBlocks.size() == 0)
{
loopCount++;
thousandBlocks.add(new limitWrapper(tmpcase,loopCount));
}
return thousandBlocks;
}
public class limitWrapper
{
public NRProducts__c [] zeroinventory {get;set;}
public integer blockNumber {get;set;}
public limitWrapper(NRProducts__c[] accs, integer i)
{
zeroinventory = accs;
blockNumber = i;
}
}
}