Skip to main content

Posts

get configurable items of product magento 2

 $product_id = 25; $objectManager = \Magento\Framework\App\ObjectManager::getInstance(); $configProduct = $objectManager->create('Magento\Catalog\Model\Product')->load($product_id); foreach ($configProduct->getOptions() as $options) {     $optionData = $options->getValues();     $parent_title = $options->getTitle();     $parent_id = $options->getId();     $parent[$parent_id] = $options->getTitle();     foreach ($optionData as $data) {         /* echo '<pre>';          print_r($data->getData());         echo '</pre>'; */         $optionPrice [ $data['option_id'] ][ $data['title'] ] = $data->getPrice();         $optionid [ $data['option_id'] ][ $data['title'] ] = $data['option_type_id'];     } } $optionPricemy...

get bundle product options magento 2

<?php         $id = 9;          $_objectManager = \Magento\Framework\App\ObjectManager::getInstance();          $product = $_objectManager->get('\Magento\Catalog\Model\Product')->load($id);          $customOptions = $_objectManager->get('Magento\Catalog\Model\Product\Option')->getProductOptionCollection($product);          $productTypeInstance = $_objectManager->get('Magento\ConfigurableProduct\Model\Product\Type\Configurable');          $productAttributeOptions = $productTypeInstance->getConfigurableAttributesAsArray($product);          $typeInstance = $_objectManager->get('Magento\GroupedProduct\Model\Product\Type\Grouped');          $childs = $typeInstance->getAssociatedProducts($product);        ...

Get latest products magento 2

  <?php $objectManager = \Magento\Framework\App\ObjectManager::getInstance(); $productCollection = $objectManager ->create( 'Magento\Catalog\Model\ResourceModel\Product\CollectionFactory' ); $collection = $productCollection ->create() ->addAttributeToSelect( '*' ) ->load(); $store = $objectManager->get('Magento\Store\Model\StoreManagerInterface')->getStore();    foreach ( $collection as $product ){ echo 'Name = ' . $product ->getName(). '<br/>' ; }   foreach ($collection as $product) { $imageUrl = $store->getBaseUrl(\Magento\Framework\UrlInterface::URL_TYPE_MEDIA) . 'catalog/product' . $product->getImage(); <div class="item"> <a href="<?= $product->getProductUrl(); ?>"> <div class="product-home"> <span class="tag">NEU</span> <img src="<?php echo $imageUrl; ?>" alt...

Include jquery, owl carousel, bootstrapjs in magento 2

  app/design/frontend/Vendor/Theme/Magento_Theme/layout/default.xml   < referenceContainer name = "after.body.start" > < block class = "Magento\Framework\View\Element\Template" name = "custom.js" template = "Magento_Theme::custom_js.phtml" /> </ referenceContainer >   app/design/frontend/Vendor/Theme/requirejs-config.js /**  * Copyright © 2015 Magento. All rights reserved.  * See COPYING.txt for license details.  */ var config = {     map: {         '*': {             'respond': 'js/respond.min',             'customScript':'js/customscript'         }     },     paths: {             'bootstrap': 'js/bootstrap.min',      ...

Magento 1: get all categories with product count

 <?php $cat_id = Mage::getModel('catalog/layer')->getCurrentCategory()->getId(); ?>                     <?php $category = Mage::getModel('catalog/category')->load($cat_id); ?>                     <?php //echo $category->getName(); ?>                                         <?php $_helper = Mage::helper('catalog/category') ?>                     <?php $_categories = $_helper->getStoreCategories() ?>                     <?php if (count($_categories) > 0): ?>      ...