#StackBounty: #magento2 #javascript #uicomponent #full-page-cache #ecommerce-tracking Non-cacheable Javascript snippets using UI compon…

Bounty: 250

I’m asking this question as I’m unsure about the best way to proceed.

I’ve ported a module from Magento 1 to Magento 2, and it includes some Javascript tracking snippets that contain a small amount of dynamic data, e.g. an extra line or two if you’ve just added a product to your cart.

I’m concerned that the full page cache in Magento 2 will get in the way of the dynamic nature of some of these snippets.

Questions:

  1. Do I need to worry about the FPC here?
  2. Should I be using a UI component for this?
  3. Would this be the recommended approach for implementing these kinds of things in Magento 2?


Get this bounty!!!

#StackBounty: #magento2 #price #knockoutjs #mini-cart Magento 2 Minicart – Display line item subtotal rather than unit price

Bounty: 50

In the Magento 2 mini cart I would like to display the line item subtotal rather than unit price.

So in the example below the price in the minicart should be $90 because I’ve added two watches to the cart.

enter image description here

I see this Magento displays this price from a KnockoutJS template

app/code/Magento/Checkout/view/frontend/web/template/minicart/item/default.html

with this piece of code:

<!-- ko foreach: $parent.getRegion('priceSidebar') -->
    <!-- ko template: {name: getTemplate(), data: item.product_price, as: 'price'} --><!-- /ko -->
<!-- /ko -->

The item object contains this data:

canApplyMsrp:false
is_visible_in_site_visibility:true
item_id:"155"
product_has_url:true
product_id:"2"
product_image:Object
product_name:"Test Product"
product_price:"↵↵    <span class="price-excluding-tax" data-label="Excl. Tax">↵            <span class="minicart-price">↵            <span class="price">$45.00</span>        </span>↵↵        </span>↵"
product_price_value:30
product_sku:"01002"
product_type:"simple"
product_url:"http://dev.example.com/test-product.html"
qty:2

In my theme, how can I override the current price value used, product_price, to display the line item sub-total price instead? Properly formatted with the correct currency symbol.

So far I’ve tried the below:

<!-- ko template: {name: getTemplate(), data: item.product_price * item.qty, as: 'price'} --><!-- /ko -->  // returns a NaN

<!-- ko template: {name: getTemplate(), data: item.product_price_value * item.qty, as: 'price'} --><!-- /ko -->  // returns the correct price but without the currency symbol


Get this bounty!!!

#StackBounty: #magento2 #configuration #system-config #iframe Magento 2 – Showing iframe in admin configuration panel

Bounty: 50

I want the users who download and install my extension from the marketplace to go through a registration/login flow. Since the normal system.xml file supports only static pages and doing the entire thing using FE models is too complicated, I’m wondering if I can instead show everything in an iframe?

Showing everything in an iframe gives me lot of advantages like –

  • Flexibility over design. Magento buttons/elements are ugly.
  • Being able to use the same iframe my other eCommerce offerings
  • Much much less engineering time since our team is much more comfortable with JavaScript/CSS than PHP/XML etc

So my question is how to implement the iframe and are there any disadvantages that I’m missing?

I see its possible for Magento 1


Get this bounty!!!

#StackBounty: #magento2 #knockoutjs #mini-cart #product-type Filter by product type in minicart

Bounty: 50

In Magento 2, I have made a special system. When a (configurable or virtual) product is ordered, the related products are automatically added.

The configurable and virtual products are mealboxes, and the related products that come with the box are the recipes. They are free of charge, and are added so the customer can ‘save’ the recipes in the customer dashboard that way.

Enough of that, now my question:

In the minicart, I want to filter the products. I want to show every product type EXCEPT for the downloadable products. But I don’t know how to filter this, since the products are loaded via knockout.js…

Is there a way to do this?


Get this bounty!!!

#StackBounty: #magento2 #swatches Create Visual Swatch Attribute

Bounty: 150

Can anyone provide a working example for creating a visual swatch (or even a text swatch) attribute as part of a setup script. I’ve tried the example on Magento 2 create custom swatch attribute programmatically but it doesn’t work for me. The issue I’ve ran into there is that the the attribute repository cannot find the new attribute that was created. I tried putting some cache clearing in between but no luck.

Thanks.


Get this bounty!!!

#StackBounty: #magento2 #product #product-collection magento 2 best seller ,most viewed and Wishlist product collection

Bounty: 50

Hi can you please anyone give me the working code of best seller ,most viewed collection and Wishlist Product collection

I try with multiple codes but unfortunately, i am not getting any result

Index.php

<?php

namespace MPSTestBlockBestproduct;


class Index extends MagentoFrameworkViewElementTemplate implements MagentoWidgetBlockBlockInterface
{
    /**
     * Default value for products count that will be shown
     */
    const DEFAULT_PRODUCTS_COUNT = 100;
    /**
     * Products count
     *
     * @var int
     */
    protected $_productsCount;
    /**
     * @var MagentoFrameworkAppHttpContext
     */
    protected $httpContext;
    protected $_resourceFactory;
    /**
     * Catalog product visibility
     *
     * @var MagentoCatalogModelProductVisibility
     */
    protected $_catalogProductVisibility;

    /**
     * Product collection factory
     *
     * @var MagentoCatalogModelResourceModelProductCollectionFactory
     */
    protected $_productCollectionFactory;

    /**
     * Image helper
     *
     * @var MagentoCatalogHelperImage
     */
    protected $_imageHelper;
     /**
     * @var MagentoCheckoutHelperCart
     */
    protected $_cartHelper;
    /**
     * @param Context $context
     * @param MagentoCatalogModelResourceModelProductCollectionFactory $productCollectionFactory
     * @param MagentoCatalogModelProductVisibility $catalogProductVisibility
     * @param MagentoFrameworkAppHttpContext $httpContext
     * @param array $data
     */
   public function __construct(
    MagentoCatalogBlockProductContext $context,
        MagentoReportsModelResourceModelReportCollectionFactory $resourceFactory,
        MagentoReportsModelGroupedCollectionFactory $collectionFactory,
        MagentoReportsHelperData $reportsData,
        array $data = []
    ) {
        $this->_resourceFactory = $resourceFactory;
        $this->_collectionFactory = $collectionFactory;
        $this->_reportsData = $reportsData;
              $this->_imageHelper = $context->getImageHelper();
        $this->_cartHelper = $context->getCartHelper();
        parent::__construct($context, $data);
    }

    /**
     * get featured product collection
     */
   public function getBestsellerProduct(){
     $limit = self::DEFAULT_PRODUCTS_COUNT;

        $resourceCollection = $this->_resourceFactory->create('MagentoSalesModelResourceModelReportBestsellersCollection');
        $resourceCollection->setPageSize($limit);
        return $resourceCollection;
   }



}

bestProducts.phtml

<?php $bestSellingCollection =  $block->getBestsellerProduct();
echo $bestSellingCollection->count();
print_r($bestSellingCollection->getData());
?>

I got some random product. I deleted all order and products in backend that deleted products showing in Bestseller collection

Most Viewed product

Index.php

<?php

namespace MPSTestBlockMostproduct;


class Index extends MagentoFrameworkViewElementTemplate implements MagentoWidgetBlockBlockInterface
{
     /**
     * @var MagentoReportsModelResourceModelProductCollectionFactory
     */
    protected $_productsFactory;

    /**
     * @param MagentoFrameworkViewElementTemplateContext $context
     * @param MagentoReportsModelResourceModelProductCollectionFactory $productsFactory
     * @param array $data
     */
    public function __construct(
        MagentoFrameworkViewElementTemplateContext $context,
        MagentoReportsModelResourceModelProductCollectionFactory $productsFactory,
        array $data = []
    ) {
        $this->_productsFactory = $productsFactory;
        parent::__construct($context, $data);
    }

    /**
     * Getting most viewed products
     */
    public function getCollection()
    {

        $currentStoreId = $this->_storeManager->getStore()->getId();

        $collection = $this->_productsFactory->create()
        ->addAttributeToSelect(
            '*'
        )->addViewsCount()->setStoreId(
                $currentStoreId
        )->addStoreFilter(
                $currentStoreId
        );
        $items = $collection->getItems();
        return $items;
    }

}

mostProduct.phtml

<?php  $mostCollection =  $block->getCollection();

echo $mostCollection->count();
?>

I din’t get product how i get most view products

How to get all coustmer products wishlist collection


Get this bounty!!!

#StackBounty: #magento2 Blank "column main" if static block only on CMS Page

Bounty: 50

I created a CMS Page, where I included a “.phtml” file with block–>Widget.
On that CMS Page, I do only have that “.phtml” file and no other content written in the cms page.
Now there is a blank “column main” on that cms page. How can I remove that?

The “Column main” shouldnt even be there, if there is no content in it anyways..

enter image description here


Get this bounty!!!

#StackBounty: #magento2 #configurable-product #price Magento2 How to get configurable option and its price?

Bounty: 100

I am trying to pull configurable products option and price on product detail page on seprate section. on radio button. I’ve used below code to get detail of options but i can retrive price of options.

$blockObj = $block->getLayout()->createBlock('MagentoConfigurableProductBlockProductViewTypeConfigurable');


$_attributes = $blockObj->decorateArray($blockObj->getAllowAttributes());

 foreach ($_attributes as $_attribute): ?>

    <?php foreach ($_attribute->getData('options') as $option):    ?>
        // option detail here
     <?php endforeach; ?>
 <?php endforeach; ?>

I’ve also try to get product id of options but i can get in above data. anyone have idea. how to get it?
Note: I’ve used objectmanager for testing now. I’ll use class to use once my code will be ready


Get this bounty!!!

#StackBounty: #magento2 #shipping #configuration #usps Magento 2 : USPS Unable to read response, or response is empty

Bounty: 50

I signed up for the shipping API of USPS and put my test credentials from Magento 2 admin panel. Still I am unable to fetch the shipping rates for USPS carrier. On front end it shows –

enter image description here

The error reads as – “This shipping method is currently unavailable. If you would like to ship using this shipping method, please contact us.

After checking in log folder in debug.log, I found this entry –

enter image description here

The log file reads – “Unable to read response, or response is empty

I have been scratching head for about 4 hrs now. I am pretty sure my credentials are correct. What could be possibly wrong?

I am using Magento ver. 2.0.13.

Hugely appreciate any help 🙂


Get this bounty!!!

#StackBounty: #magento2 #magento-2.1 #product-images #gallery #fotorama-slider change fotorama slider

Bounty: 50

I want to place the fotorama slider in an absolute div that is behind other elements.
Also the slider should behave like the css background property cover.

I found that the slider plugin used has an option to set to cover. But I can’t find out how to set it.
Also when I change the div containing the fotorama to position absolute it just ignores the height altogether.
This might be because of that cover option as the slider will scale the image up and the image is 4:3 but the space is 16:9.

How can I change/set this behavior?


Get this bounty!!!