Magento 2 Custom Stock Status Custom Development - fixes.co.za [PDF]

Jan 9, 2017 - How to change the stock status on Magento 2 based on custom options.

3 downloads 18 Views 32KB Size

Recommend Stories


Delivering Custom Status Icons
You have to expect things of yourself before you can do them. Michael Jordan

tourneo custom & kombi custom
Keep your face always toward the sunshine - and shadows will fall behind you. Walt Whitman

Custom PDF Report
Don’t grieve. Anything you lose comes round in another form. Rumi

Custom PDF Report
If you are irritated by every rub, how will your mirror be polished? Rumi

Custom PDF Report
Just as there is no loss of basic energy in the universe, so no thought or action is without its effects,

Custom Exhibition Stand Manufacturers | Shop Fitting | Custom
Kindness, like a boomerang, always returns. Unknown

Custom Limited
Don't fear change. The surprise is the only way to new discoveries. Be playful! Gordana Biernat

CUSTOM Setup
We may have all come on different ships, but we're in the same boat now. M.L.King

custom aerosols
If you want to go quickly, go alone. If you want to go far, go together. African proverb

Custom Applicator
When you do things from your soul, you feel a river moving in you, a joy. Rumi

Idea Transcript


fixes.co.za

About

fixes.co.za

search

Magento2

Magento 2 Custom Stock Status Custom Development Jan 9, 2017

How to change the stock status on Magento 2 based on custom options

The Task The task is to change the stock status on the product view page based on a seperate backend attribute.

Magento 1 code In the file: app/designfrontend/default/{theme}/template/catalog/product/view/type/default.phtml

The code for doing this in magento 1 is: ``` available + qty > 0: in stock available + qty < 1 + normally in stock warehouse available + qty < 1 backordered not available temporarily not available

getChildHtml('product_type_data_extra') ?> getPriceHtml($_product) ?> ```

The solution First thing to do is check where in the template is the stock indicator by showing template hints. THe template is /vendor/magento/modulecatalog/view/frontend/templates/product/view/type/default.phtml

and the block class is: Magento\Catalog\Block\Product\View\Type\Simple\Interceptor for simple products But there is a snare, the template for bundle products is /var/www/shootingstuff/project/vendor/magento/modulebundle/view/frontend/templates/catalog/product/view/type/bundle.phtml and the block

is Magento\Bundle\Block\Catalog\Product\View\Type\Bundle\Interceptor

The incorrect way: Overriding core template files So we found the string In Stock in app/code/Magento/Catalog/view/frontend/templates/product/view/type/default.phtml .

So changing stuff in this file only changes simple products. For Downloadable you have to check: Magento/Downloadable/view/frontend/templates/catalog/product/type.phtml

For Grouped products: Magento/GrouperProduct/view/frontend/templates/product/view/type/default.phtml

For Bundled products: Magento/Bundle/view/frontend/templates/catalog/product/view/type/bundle.phtml

and the summary.html file. So it is in alot of places… Flippit.

The JS option This is probably the best way to do it.

Correct way is using dependency injection http://magento.stackexchange.com/questions/97943/how-to-get-stock-quantity-of-each-product-inmagento-2

fixes.co.za fixes.co.za [email protected]

surfer190 shutch190

A bunch of useful fixes that get to the code and cut through the excess

Smile Life

When life gives you a hundred reasons to cry, show life that you have a thousand reasons to smile

Get in touch

© Copyright 2015 - 2024 PDFFOX.COM - All rights reserved.