Magento bundle dropdown need to display out of stock - php

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.

Related

how to get attribs in tags Joomla

For extra data fields used in Joomla:
<?php
$attribs = new JRegistry($this->item->attribs);
echo $attribs->get('extrafield_name');
?>
or
<?php echo $params->get('extrafield_name'); ?>
I tried the same thing, to display extra fields of com_content in com_tags.
as I can fix that. Thank you for your help.
Situation before this change:
I have a couple of custom fields added to my article using the same technique as described here:
https://zunostudios.com/blog/development/203-how-to-add-custom-fields-to-articles-in-joomla
I then made a menu item of the type "tagged items" and tried to override the joomla default template for the tagged items list, which I found under components/com_tags/views/tag/tmpl/default_items.php
However the attribs are not available in $item (line 35 and ongoing)
Situation after this change:
The query which returns the items of the "tagged items" now also returns the attribs. And one can use something like this to use the attribs in the tagged items list:
$attrb = json_decode($item->attribs);
echo $attrb->foo;
I hope I didn't break anything - this is my first patch to the joomla project, so I'm happy to hear your feedback and improve my solution.

Magento - Wishlist addNewItem remove all my items

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).

Magento sidebar will not show cart quantity

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.

How to add html code inside wp post/except via template file

In a WordPress woocommerce template, this line outputs woocomerce product description / excerpt
<?php echo apply_filters( 'woocommerce_short_description', $post->post_excerpt ) ?>
Adding my HTML after that line outputs my HTML outside the div that holds the excerpt/description of the product. I am trying to add a div inside the content as if it was added in the editor.
Basically, I want to add something in all products but because I have many products already, I want a way to insert it in template file or something just once and applied to all.
Anyone know how can I do that?
You could add a filter that adds the div, before the woocommerce software adds it. Try something like this, inside your <theme>/functions.php file:
function add_my_div($desc) {
return '<div class="my-div">'.$desc.'</div>';
}
add_filter('woocommerce_short_description', 'add_my_div', 0, 1);
Notice it is on priority 0. This should run before most other filters. The default value for priority is 10, and I am pretty sure that is the priority that WC adds it's wrapper div.
Hope this helps.
jquery .append did the trick for me
http://api.jquery.com/append/
#loushou Thanks for your comment. It looks like your suggestion could work also but I haven/t tried it yet. Will do If I got the time and update my findings here.
Thanks

How can add tracking code (tradetracker and daisycon) on thank you page

I have a task, I did research but I still cannot be done.
I am using OpenCart. And I have to add code tracking (from tradetracker and daisycon) to thank you page.
How can I do it?
If you aren't too comfortable with writing your own extension and your tracking code is JavaScript or HTML you can place it straight into your template. You will find the template you need in:
/catalog/view/theme/default/template/common/success.php
The only problem is that this will now fire every time the page loads. Any success goes to this template.
To fix this you need to go into the controller and make a small addition.
Find:
if (isset($this->session->data['order_id'])) {
Add a new line below reading:
$this->data['enable_tracking'] = TRUE;
Then back in the template before simply add an if statement round the tracking code you have added like so:
<?php if($enable_tracking === TRUE){ ?>
Delete this line and replace with tracking code
<?php } ?>
That should solve your problem.

Categories