I’m trying to show the right sidebar of my Magento shopping cart in an external PHP file. I was able to get that file to show the sidebar, but for some reason the sidebar is not showing the correct information with regards to the items in the cart. If I have any items in my cart, it will still say “you have no items in your cart”. If I modify sidebar.phtml to echo the $_cartQty = $this->getSummaryCount() function, it just displays nothing. Not even 0. Your help would be greatly appreciated!
My code of calling sidebar.phtml:
<?php
require_once 'app/Mage.php';
umask(0);
Mage::app()->loadArea('frontend');
Mage::app()->setCurrentStore(6);
$layout = Mage::getSingleton('core/layout');
//load default xml layout handle and generate blocks
$layout->getUpdate()->load('default');
$layout->generateXml()->generateBlocks();
//get the loaded head and header blocks and output
$headBlock = $layout->getBlock('right');
$headerBlock = $layout->getBlock('cart_sidebar');
echo $headBlock->toHtml() . $headerBlock->toHtml();
The sidebar.phtml is just a default 1.7.2 file, so that should be straightforward.
I found the solution that worked at this website -- totally awesome! http://www.codeoncall.com/get-shopping-cart-quantity-outside-of-magento/
Thanks for all those who looked at this, and I hope it will help someone in the future.
Related
I got a problem with my whislist. Here is the thing.
I try to programmatically add into a whistlist, a new Item.
So I use the $whishlist->addNewItem() function. The product is added, but if I had other products in my whislist, they've been removed!
Here is what I use:
<?php
$customer = Mage::getModel('customer/customer')->load($my_customer_id);
$product = Mage::getModel('catalog/product')->load($my_product_id);
$wishlist = Mage::getModel('wishlist/wishlist')->loadByCustomer($customer, true);
$request = new Varien_Object(array());
$result = $wishlist->addNewItem($product, $request);
$wishlist->save();
?>
Did I do something wrong?
Thank you guys
EDIT:
I Finally found, it seems weird, but in my case, I have to remove this line $wishlist->save();
I had to remove this line $wishlist->save();
I don't know if it's THE solution, but it works for me.
Thank's to everyone :)
Remove the ->save on the wishlist. Sometimes it works
This might help you,
Lets say you have to add a product to wishlist on click so it would be like :
<a onclick="setLocation('<?php echo $this->helper('wishlist')->getAddUrl(Mage::registry('current_product'));?>')">add to wishlist</a>
I too had the same problem. But in my case product visibility in magento backend is set to "Not Visible Individually". changed product visibility and it worked.
I had the same problem and the "save" function was not in cause.
My problem came from the products redindexation. I've found my solution here : Why is my wish list limited to one item?
Reindexing every indexes made my wishlist worked again for products recently added through the rest API.
To do it automatically, I've change this index to "Update on Save" in the admin : Product Flat Data - Reorganize EAV product structure to flat structure.
My wishlist works perfectly fine now (even with the "save" function).
I just would like to ask if anyone here is familiar with IWD's Onepage Checkout extension. By default, under the reviews block, it only shows the name of the product, there are no thumbnail images for each product. What I want to do is include a thumbnail in the list of products under review column.
When I tried modifying info.phtml inside /template/opc/onepage/review I found that this echoes all the products under the reviews block.
<?php foreach($this->getItems() as $_item): ?>
<?php echo $this->getItemHtml($_item)?>
<?php endforeach ?>
Now, I can't locate where is the items template that getItemHtml is calling. I tried modifying the default item.phtml under the base theme, but it didn't work.
I hope someone here is familiar with this extension and the location of the items template. :(
OOops. Never mind. I already located it inside base/default/template/checkout/onepage/review/item.phtml
In a bundle product page, I need to display if a product in the bundle is out of stock. Currently, the product is simply not appearing in the dropdown. I've looked at the "select.phtml" file and found at the beginning that this line of code get the option value for the dropdown :
<?php $_selections = $_option->getSelections(); ?>
Unfortunately, this doesn't fetch "out of stock" items. So, is there a way to include these items?
Thank you.
Hoping this can help someone. After searching for hours, finally found the line that was causing the problem inside app/code/core/Mage/Bundle/Block/View/Type/Bundle.php
You need to change this line
$this->_options = $optionCollection->appendSelections($selectionCollection, false,
Mage::helper('catalog/product')->getSkipSaleableCheck()
);
to this
$this->_options = $optionCollection->appendSelections($selectionCollection, false,
true
//Mage::helper('catalog/product')->getSkipSaleableCheck()
);
Building on SimCity's answer, rather than extending/overwriting the block, you can do the following. I have added this code to the top of bundle/catalog/product/view/type/bundle/options.phtml
// Get the current value of SkipSaleableCheck
<?php $skipSaleableCheck = Mage::helper('catalog/product')->getSkipSaleableCheck() ?>
// Overwrite this value with a 'true' value
<?php Mage::helper('catalog/product')->setSkipSaleableCheck(true) ?>
You can then reset this value at the bottom of the same file using the following code:
<?php Mage::helper('catalog/product')->setSkipSaleableCheck($skipSaleableCheck) ?>
This method provides the same result without having to overwrite core Magento blocks.
In Magento 1.8.1 you find the file in app/code/core/Mage/Bundle/Block/Catalog/Product/View/Type/Bundle.php
Be aware of making changes in the core will get you site no good for updates. Make a copy of your file to your local directory.
We're redoing our theme in Magento to use a grid system (semantic.gs), and I've been tasked with the duty setting up the PDP page to use this new grid system template. We eventually will want this template on all pages, but for now, it's been specifically requested ONLY on the PDP page. So basically I want to set a custom theme/template (including header and footer, not just columns) that I can load on certain pages. Can anyone point me in the direction of how to go about doing this? Extensive SO and google searching has come up pretty fruitless.
So far:
I created a new layout called 2columns-left-grid.phtml in app/design/frontend/[my_interface]/[my_theme]/template/page
I modified these lines:
<?php echo $this->getChildHtml('header') ?>
and
<?php echo $this->getChildHtml('footer') ?>
To be:
<?php echo $this->getChildHtml('header2') ?>
and
<?php echo $this->getChildHtml('footer2') ?>
I duplicated header.phtml and named it header2.phtml, and duplicated footer.phtml and named it footer2.html
My questions:
Will this work, and if so, what other code do I need to modify (xml files, etc)
How can I get this template to apply ONLY to the PDP page for now?
Thanks!
Hello you can override product tag
< catalog_product_view translate="label">
/app/design/frontend/base/default/layout/catalog.xml
from into your new module layout xml
I have made a site site in joomla & in this i use Virtuemart.
In virtumart when user purchse the item then there is a thank page. In this thank page i want to add one module which contain text so that user can change it later. But i am not be able to show it on thanks page. I want to show this module in thanks page data means in between the data not at bottom of thanks page.means in between the lines of thanks page. how can i include my custom module in thanks page of virtuemart.
You need to do some programming for something like this...
Check this out http://docs.joomla.org/JModuleHelper/renderModule
You can install JUMI, modify the Thank You article and add following php script to the article:
jimport( 'joomla.application.module.helper' );
$module = JModuleHelper::getModule( 'yourmodule', 'You Module Title' );
$attribs['style'] = 'xhtml'; // this is optional, if set template XHTML style will be used
echo JModuleHelper::renderModule( $module, $attribs );