Configurable product is not showing out of stock items - magento

We're running Magento 1.9.2.4
There are several simple products making up a few configurable products which we are wanting customers to be able to order if they are in stock or out of stock.
We're running custom themes and plugins, i've reverted back to RWD to ensure there are no template mistakes and disabled all of the plugins.
All options have been set globally, i've double checked the both the simple and configurable products to ensure that they are set with product levels and are in stock where applicable.
Cache has been cleared and all data has been re-indexed.
I've attached a screen shot of the settings.
https://www.dropbox.com/s/x96aqhh2h9b86ik/Screenshot%202017-02-14%2018.59.54.png?dl=0
I've read lots of threads and there appears to be a few people that have had this issue on different versions of Magento but none of the fixes appear to have worked.

I found the issue, the availability.phtm file needed updating to pull in another status.
There was an article I found online which helped, its not 100% right for 1.9.2.4 but got me most of the way there.
<?php $_product = $this->getProduct() ?>
<?php echo $this->getPriceHtml($_product) ?>
<?php $stockLevel = (int)Mage::getModel('cataloginventory/stock_item')->loadByProduct($_product)->getQty(); ?>
<?php if($_product->isSaleable()<strong> && $stockLevel > 0</strong>): ?>
<p class="availability in-stock"><?php echo $this->__('Availability:') ?> <span><?php echo $this->__('In stock') ?></span></p>
<?php elseif($_product->isSaleable() && $stockLevel <= 0): ?>
<p class="availability in-stock">
<?php echo $this->__('Availability:') ?> <span><?php echo $this->__('Available for Backorder') ?></span><br />
<?php echo $this->__('Please allow up to two weeks for delivery') ?>
</p>
<?php else: ?>
<p class="availability out-of-stock"><?php echo $this->__('Availability:') ?> <span><?php echo $this->__('Out of stock') ?></span></p>
<?php endif; ?>
https://edmondscommerce.github.io/magento/ssssssssssssss.html

Related

Magento: How to show custom attribute on product page below description

I have a custom attribute for products in which I add a video URL.
I made this Embed video responsive using css.
Now I want to call the custom attribute on the product page, so it shows the video.
The file responsible for this is: description.phtml
I've tried the following:
?>
<?php $_description = $this->getProduct()->getDescription(); ?>
<?php if ($_description): ?>
<h2><?php echo $this->__('Details') ?></h2>
<div class="std">
<?php echo $this->helper('catalog/output')->productAttribute($this->getProduct(), $_description, 'description') ?>
</div>
<div class="std">
<?php echo $_product->getAttributeText('video') ?>
</div>
<?php endif; ?>
But I get the error:
Fatal error: Call to a member function getAttributeText() on a non-object in /data/web/public/app/design/frontend/base/default/template/catalog/product/view/description.phtml on line 40
The video does show however. I'm probably doing this all wrong. Can I fix this with a simple edit of the code, or do I have to use an entirely different approach?
Thanks.
<?php echo $this->getProduct()->getAttributeText('video'); ?>
Try this. Or on top of document add this
<?php $_product = $this->getProduct(); ?>

Remove attribute from layered filter based on parent category

On my magento site, each product sits in two parent categories. Basically, each product is in both "Shop by Product" and "Shop by Device", and then of course there are child categories in side of those. For example, case for a tablet will appear in Shop by Device > iPad, as well as Shop by Product > Tablet Cases.
Each product also has an attribute for "compatibility" and "product type." I would like to remove the "compatibility" filter from layered filters on the catalog page when shopping under "Shop by Device," and remove the "product type" filter when shopping under "Shop by Product"
Any suggestions?
put the code in start of layer.phtml in catalog/layer/view.phtml
$yes=0;
if(Mage::registry('current_catgeory')){
if(Mage::registry('current_catgeory')->getParentId()==$catid):
$yes=1
endif;
}
then filter showing position add
<?php foreach ($_filters as $_filter): ?>
<?php if($_filter->getItemsCount()): ?>
<dt><?php echo $this->__($_filter->getName()) ?></dt>
<dd><?php echo $_filter->getHtml() ?></dd>
<?php endif; ?>
<?php endforeach; ?>
change
<?php foreach ($_filters as $_filter): ?>
if($yes==1 && $_filter->getName()==$Attributelabel){
//hide
}
else{
<?php if($_filter->getItemsCount()): ?>
<dt><?php echo $this->__($_filter->getName()) ?></dt>
<dd><?php echo $_filter->getHtml() ?></dd>
<?php endif; ?>
}
<?php endforeach; ?>

Magento product custom options to be positioned below the price

I would like my Magento product custom options to be positioned below the price. I tried moving the blocks in catalog.xml file but nothing worked.
I did flush all cache every time.
This can be done from within the manage product section in admin. Under design, set "Display Product Options In" > "Product Info Column"
This function can be found in
/app/design/frontend/your_package/your_theme/template/catalog/product/view.phtml
or, if it's not there, look in
/app/design/frontend/your_package/default/template/catalog/product/view.phtml
If the file is not present, then create it by copying from
/app/design/frontend/base/default/template/catalog/product/view.phtml
or, if you are on the Enterprise Edition, from:
/app/design/frontend/enterprise/default/template/catalog/product/view.phtml
Remember not to touch anything in the /app/design/frontend/enterprise/default/
The code responsible for showing prices is:
<?php echo $this->getChildHtml('tierprices') ?>
You have to move the code responsible for showing the options, that looks like this:
<?php if (!$this->hasOptions()):?>
<div class="add-to-box">
<?php if($_product->isSaleable()): ?>
<?php echo $this->getChildHtml('addtocart') ?>
<?php endif; ?>
<?php echo $this->getChildHtml('addto') ?>
</div>
<?php else:?>
<?php if ($_product->isSaleable() && $this->hasOptions() && $this->getChildChildHtml('container1') ):?>
<div class="options-container-small">
<?php echo $this->getChildChildHtml('container1', '', true, true) ?>
</div>
<?php else: ?>
<?php echo $this->getChildHtml('addto') ?>
<?php endif;?>
<?php endif; ?>
directly below the code that's responsible for prices. Remember that the code above is an example, it may look different in your template, so don't copy-paste it.
Anyway, the file responsible for showing prices is usually /app/design/frontend/your_package/your_theme/template/catalog/product/view/tierprices.phtml (with the same fallbacks as usual), but you shouldn't modify it in your case.
You can change them by edit template (.phtml) file:
app/design/frontend/{default}/{default}/catalog/product/view.phtml
Modify the template Or ovverride it in your theme !
/app/design/frontend/base/default/template/catalog/product/view.phtml
This is where the price is :
<?php echo $this->getTierPriceHtml() ?>
This means customer options showing between this if (){}
<?php if (!$this->hasOptions()):?>
So you can move them as you like in the template file ! or you can style them with CSS to put them at custom position !

Hide certain Magento attribute filters

I have some lines of PHP code that will prevent certain attribute filters to be shown within the layered navigation block (i.e. Price and Category). This way I need to add all the filters that I don't want to be shown by hand which takes a lot of time and isn't the best solution.
What I want is the filter attributes "Price" and "Category" to be shown and if the filtername is different, don't display that filter at all. This way the price and category filters are always displayed, and the other filters get hidden. I don't have to add all the filters by hand which I do not want to show up in the list.
My question is, what needs to change within the PHP code to make it work the way I just described?
<?php $_filters = $this->getFilters() ?>
<?php foreach ($_filters as $_filter): ?>
<?php if($_filter->getItemsCount()): ?>
<?php if($_filter->getName() != "Price" AND $_filter->getName() != "Category"): ?>
<dt><?php echo $this->__($_filter->getName()) ?></dt>
<dd><?php echo $_filter->getHtml() ?></dd>
<?php endif; ?>
<?php endif; ?>
<?php endforeach; ?>
Ah I see. Funnily enough I was working on something virtually identical yesterday and this works for me (I mean to the change to the IF statement);
<?php foreach ($_filters as $_filter): ?>
<?php if (Mage::helper('catalog')->__($_filter->getName()) == 'Price' || Mage::helper('catalog')->__($_filter->getName()) == 'Category'): ?>
<dt><?php echo Mage::helper('catalog')->__($_filter->getName()) ?></dt>
<dd><?php echo $_filter->getHtml() ?></dd>
<?php endif; ?>
<?php endforeach; ?>
Hopefully it will work for you too.

Display only in stock options for configurable products on catalog pages in Magento

I've managed to add options to configurable products on my catalog pages using the code found here: http://www.magentocommerce.com/boards/viewthread/21039/P45/#t167724. What I'd like to do now is only show the options that are available according to the stock of the simple product that the option is coming from.
For example, if I have a t-shirt (configurable product) that has various colors (simple products) and my red color is out of stock, red wouldn't be shown as an option when the configurable product is displayed.
What's the best way to do this?
Update:
For the sake of clarity, here is the relevant block of code from the link I posted.
<?php if($product->getTypeId() == "configurable"): ?>
<?php $attValConfig = $product->getTypeInstance()->getConfigurableAttributesAsArray(); ?>
<?php if(sizeof($attValConfig)): ?>
<?php foreach($attValConfig as $attValConfigSingle): ?>
<fieldset class="product-options" id="product-options-wrapper">
<label><?php echo $attValConfigSingle['label']; ?>:</label>
<select name="super_attribute[<?php echo $attValConfigSingle['attribute_id'] ?>]" id="attribute<?php echo $_product->getId() ?>" class="required-entry super-attribute-select">
<?php foreach($attValConfigSingle['values'] as $attValConfigSingleVal): ?>
<option value="<?php echo $attValConfigSingleVal['value_index'] ?>"><?php echo $attValConfigSingleVal['label'] ?></option>
<?php endforeach; ?>
</select>
</fieldset>
<?php endforeach; ?>
<?php endif; ?>
<?php endif; ?>
Since this code is simply getting all of the configurable options and displaying them, it doesn't check to see if the simple product that backs the configurable option is in stock. How do I do this?
I just wondering why we are checking the quantity for stock status why dont't we look on stock availability of simple products.
I have achieved to show out of stock on configurable product according to stock status.
Now you can make product "out stock" and "in stock" through stock availability attribute of simple product.
Try the following ( do what you want returning result ) :
$_productCollection = Mage::getModel('cataloginventory/stock_item')->getCollection()
->addIdFilter($productId) // this line is wrong, don't care this
->addFieldToFilter('qty', array('gteq' => 1));

Resources