Without actually running your code, the reasons for this can be difficult to find.
This is not a solution for the actual issue, but a description on how to debug this type of issue. I hope it helps you towards solving the issue.
I hope it also shows to others how important it is to use breakpoints with a debugger to solve a lot of magento 'why the f**ck is this not working' issues.
Are you using a debugger? This type of issue is easy to solve if you use a debugger, and step through the code, and check all the variables, values etc. Without this you are really just taking pot shots in the dark.
btw, I use netbeans with xdebug. (just in case you need a solution for that ;) )
Now, that all said, this is how I would start with the debug of this.
In list.phtml the toolbar is fetched via the code <?php echo $this->getToolbarHtml() ?>
, thus I would start by whacking a breakpoint on that line, and then step into the routine to find why...
ok, so stepping in, I find this code:
/**
* Retrieve list toolbar HTML
*
* @return string
*/
public function getToolbarHtml()
{
return $this->getChildHtml('toolbar');
}
thus, is the child block attached?
yes it is, so that is not the issue.
Lets see what template is used for this block.
Using the debugger, I can expand the toolbar child block, and view all its properties/values etc. The template is:
So, lets go do a break point in that file, and see code flow from there...
The first line of code in that template is <?php if($this->getCollection()->getSize()): ?>
Using the debugger, I can step over this line, and confirm it evaluates to true, if not ? why not....
And here my example ends, as the line in the tolbar could be your issue....
I hope this example helps, and show you how important it is to use a real debugger when coding with magento (or any application for that matter) :)
Using breakpoints, and stepping through the code, and actually have the ability to view all the classes/objects/values etc during a run, makes it pretty easy to solve this type of issue.
Have fun :)
When you get a collection of products and you have it in the system configuration to use the product flat table, the collection will retrieve products from the flat table of the corresponding store view.
Looking at your query, it's retrieving your products from the product flat table of store ID 1 (shop_catalog_product_flat_1
) for some reason. If you want to retrieve all products as you see in the admin, then you can force a store in your independent script using the following.
Mage::app()->setCurrentStore(0)
This will ensure your collection will retrieve products from the main product table, shop_catalog_product_entity
in your case.
Best Answer
I think you just need to save your item , then you can use it :