Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Full page cache problem in magento 2 #13219

Closed
BabliDey opened this issue Jan 16, 2018 · 4 comments
Closed

Full page cache problem in magento 2 #13219

BabliDey opened this issue Jan 16, 2018 · 4 comments
Labels
Issue: Format is not valid Gate 1 Failed. Automatic verification of issue format is failed

Comments

@BabliDey
Copy link

#6624
#6392

As the two above told issues are closed that's why I am posting this .

I am using magento 2.1.8. I my custom theme app\design\frontend\Sample\theme-frontend-shop\Magento_Catalog\templates\product\view\form.phtml I have done

`
$quoteId = $objectManager->get('Magento\Checkout\Model\Session')->getQuoteId();
$currentItemCount=0;
if(!empty($quoteId)){
$cartItems = $objectManager->get('\Magento\Checkout\Model\Session')->getQuote()->getAllVisibleItems();
$itemsIds = array();
foreach ($cartItems as $cartItem) {
$itemsIds[] = $cartItem->getProduct()->getId();
}

$currentItemCount = count($itemsIds);

}

echo $currentItemCount;
`

and in my app\design\frontend\Sample\theme-frontend-shop\Magento_Catalog\layout\catalog_product_view.xml I have added
<referenceBlock name="product.info.addtocart" class="Magento\Checkout\Block\Cart" before="-" template="Blumeidealnew_shop::product/view/form.phtml" cacheable="false" />

But this is not working properly when full page cache is enabled.

Need help to fix this issue.

@magento-engcom-team magento-engcom-team added the Issue: Format is not valid Gate 1 Failed. Automatic verification of issue format is failed label Jan 16, 2018
@OZZlE
Copy link
Contributor

OZZlE commented Jan 16, 2018

You should never user ObjectManager in M2 unless you are writing a Symfany a lá php bin/magento script..

@BabliDey
Copy link
Author

Then how can I get cart item count from a custom theme html page?

@OZZlE
Copy link
Contributor

OZZlE commented Jan 17, 2018

You could use a Controller and put the class in the constructor, or if it's a normal theme just in the block class contructor you are using

@magento-engcom-team
Copy link
Contributor

@BabliDey please refer to the Community Forums or the Magento Stack Exchange site for advice or general discussion about this issue. The GitHub issue tracker is intended for Magento Core technical issues only.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Issue: Format is not valid Gate 1 Failed. Automatic verification of issue format is failed
Projects
None yet
Development

No branches or pull requests

3 participants