0

I am trying to access the product listing on the frontend

But I am getting this error.

Parse error: syntax error, unexpected 'else' (T_ELSE) in C:\xampp\htdocs\testmastersdirect\mastersdirect.masters-sp.com\shop\app\design\frontend\ASAD\masters\Magento_Catalog\templates\product\list.phtml on line 317

enter image description here

enter image description here

getLoadedProductCollection(); $_helper = $this->helper('Magento\Catalog\Helper\Output'); $StockState = $objectManager->get('\Magento\CatalogInventory\Api\StockStateInterface'); ?>
 <div class="quotation-overlay"></div>
    <div class="quotation-popup-modal">
            <div class="close-button"></div>
            <div class="quotation-popup-content-wrapper">
                    <div class="quotation-popup-title">
                            <?php echo __("Request Quote"); ?>
                    </div>
                    <div class="quotation-popup-details-wrapper">
                            <?php echo __("Product:") ?>
                    </div>

                    <div class="quotation-popup-form">
                                    <label for="quotation-message"><?php echo __("Message:"); ?></label>
                                    <textarea name="quotation-message" id="quotation-message"></textarea>
                                    <div class="button-wrapper">
                                            <a href="javascript:void(0);" id="submit-quotation" class="add-to-bag">
                                            <?php echo __("Request Quote");?>
                                            </a>
                                    </div>
                    </div>
            </div>
            <div class="quotation-popup-response-wrapper">
                    <?php echo __("Your quotation request was successfully submitted and a copy has been send to you by email. Customer services will contact you shortly.");?>
            </div>
    </div>
<script type="text/javascript">

      require(['jquery', 'jquery/ui'], function(jQuery){

       jQuery(".quotation-popup-modal .close-button").on("click", function () {
                    jQuery(".quotation-popup-modal").hide();
                    jQuery(".quotation-overlay").fadeOut();
                    jQuery("body").removeClass("no-scroll");
            });
       jQuery(".quotation-overlay").on("click", function() {
                    jQuery(".quotation-popup-modal").hide();
                    jQuery(".quotation-overlay").fadeOut();
                    jQuery("body").removeClass("no-scroll");

            });


        jQuery('#submit-quotation').on("click", function() {
            var productName = window.currentQuoteProductName;
            var productSKU = window.currentQuoteProductSKU;
            var quoteMessage = jQuery("#quotation-message").val();

            jQuery.ajax({
                    url:"<?php echo $this->getBaseUrl(); ?>quotation_request",
                    type: "POST",
                    data: { productname:productName, productsku:productSKU, message:quoteMessage },
                    showLoader: true,
                    cache: false,
                    success: function(response){
                            jQuery(".quotation-popup-content-wrapper").hide();
                            if(response !== "success")
                                    jQuery(".quotation-popup-response-wrapper").text("An error occured. Please contact customer services.")
                            jQuery(".quotation-popup-response-wrapper").show();


                        }
                    });
            return false;
            });

   window.openQuoteModal = function(productname, sku) {
        window.currentQuoteProductName = productname;
        window.currentQuoteProductSKU = sku;
        
        jQuery(".quotation-popup-modal .quotation-popup-details-wrapper").text("Product: "+productname);
        console.log('request quote');
                    jQuery(".quotation-popup-modal").show();
                    jQuery(".quotation-overlay").fadeIn();
                    jQuery("body").addClass("no-scroll");

   }

   }); //end require call
        //]]>
count()): ?>
<div class="message info empty"><div><?php /* @escapeNotVerified */ echo __('We can\'t find products matching the selection.') ?></div></div>
<?php echo $block->getAdditionalHtml() ?>
<?php

//ADAD-DK always grid $viewMode = 'grid'; $image = 'category_page_grid'; $hover_image = "category_page_grid_hover"; $showDescription = false; $templateType = \Magento\Catalog\Block\Product\ReviewRendererInterface::SHORT_VIEW; /** * Position for actions regarding image size changing in vde if needed */ $pos = $block->getPositioned(); ?>

getToolbarHtml() ?>
            <?php
            //category search results
            $request = $objectManager->get('Magento\Framework\App\Request\Http');  
            $param_cat = $request->getParam('cat');
            if($param_cat){
                $category_collection_all = $_product->getCategoryIds();
                if (!in_array($param_cat, $category_collection_all)) {
                                continue;

                }
            }
            
            
                //category search results
            ?>
                <div class="product-item" data-container="product-grid">
                    
                    <?php
                    //Normal Image
                    $productImage = $block->getImage($_product, $image);
                 
                        
                    ?>
                    <div class="product-item-col1">
                    
                    
                        <?php // Product Image ?>
                        <a href="<?php /* @escapeNotVerified */ echo $_product->getProductUrl() ?>" class="product photo product-item-photo" tabindex="-1">
                            <?php echo str_replace('img','img class="normal-image"',$productImage->toHtml()) ?>
                            <?php echo $hoverImageHtml ?>
                        </a>
                        <div class="product-text">
                            <?php
                                $_productNameStripped = $block->stripTags($_product->getName(), null, true);
                            ?>
                            <div class="product-name">
                                <a class="product-item-link"
                                   href="<?php /* @escapeNotVerified */ echo $_product->getProductUrl() ?>">
                                    <?php /* @escapeNotVerified */ echo $_helper->productAttribute($_product, $_product->getName(), 'name'); ?>
                                </a>
                                <?php if($_product->getFulfilmentRegion()): ?>
                                <div class="fulfilment-region">
                                    (<?php echo $_product->getResource()->getAttribute("fulfilment_region")->getFrontend()->getValue($_product);?>)
                                </div>
                                
                                <?php else: ?>
                                    <div class="fulfilment-region">
                                        (USA)
                                    </div>
                                    
                                <?php endif; ?>
                            </div>
                            <!--icons-->
                            <div class="product-icons-wrapper">
                             <?php 
                                       
                                ?>
                                    <?php 
                                    $attr =  $_product->getResource()->getAttribute('masters_icons')->getFrontEnd()->getValue( $_product);
                                    if($attr):
                                    
                                        $attr_array = explode(",", $attr);
                                        foreach($attr_array as $icon) :
                                                $img_src = strtolower($icon);
                                                
                                                $img_src = trim($img_src);
                                                
                                                //Make alphanumeric (removes all other characters)
                                                $img_src = preg_replace("/[^a-z0-9_\s-]/", "", $img_src);
                                                //Clean up multiple dashes or whitespaces
                                                $img_src = preg_replace("/[\s-]+/", " ", $img_src);
                                                //Convert whitespaces and underscore to dash
                                                $img_src = preg_replace("/[\s_]/", "-", $img_src);          
                                                
                                            ?>
                                            <div class="icon-wrapper"><img src="<?php echo $IMG_PATH.$img_src.'.jpg'; ?>" /></div>
                                    <?php endforeach;
                                    endif;
                                ?>
                            </div>
                            <!-- end icons -->
                            <!--Attributes-->
                            <div class="product-attributes">
                                <?php if($_product->getMasters_manufacturer()): ?>
                                <?php echo $_product->getMasters_manufacturer(); ?> <br />
                                <?php endif; ?>
                                <?php if($_product->getMasters_ndc()){ ?>
                                        <?php echo 'NDC: '. $_product->getMasters_ndc();?> <br />
                                <?php } ?>
                                <?php if($_product->getMasters_upc()){ ?>
                                        <?php echo 'UPC: '. $_product->getMasters_upc();?><br />
                                <?php } ?>

                                <?php if($_product->getPipCode()){ ?>
                                        <?php echo $_product->getPipCode();?><br />
                                <?php } ?>

                                
                                <?php if($_product->getActiveIngredient()): ?>
                                <?php echo  $_product->getResource()->getAttribute('active_ingredient')->getFrontEnd()->getLabel(); ?>: <?php echo $_product->getActiveIngredient(); ?><br />
                                <?php endif; ?>
                                <?php if($_product->getMastersDf()): ?>
                                <?php echo  $_product->getResource()->getAttribute('masters_df')->getFrontEnd()->getLabel(); ?>: <?php echo $_product->getMastersDf(); ?><br />
                                <?php endif;        ?>
                                
                                <?php if( $_product->getEdiPacksize()): ?>
                                <?php echo $_product->getResource()->getAttribute('edi_packsize')->getFrontEnd()->getLabel();?>: <?php echo $_product->getEdiPacksize();?>
                                <?php endif; ?>
                                <?php echo 'MSP: '. $_product->getSku(); ?><br />
                            </div>
                            <div class="product-price tablet mobile">
                             <?php echo $block->getProductPrice($_product) ?> 
                            </div>
                            <div class="add-to-bag-wrapper mobile">
                                 <!--REAL ADD TO CART MECHANISM-->
            <?php
                $controlledAttribute = $_product->getResource()->getAttribute('controlled_product');
                $controlledProduct = 0;
                if($controlledAttribute) {
                    if("Magento\Framework\Phrase" == get_class($controlledAttribute->getFrontend()->getValue($_product)))
                        $controlledProduct = $controlledAttribute->getFrontend()->getValue($_product)->getText() == "Yes";
                    else
                        $controlledProduct = $controlledAttribute->getFrontend()->getValue($_product);
                }
            ?>
                            <?php if ($_product->isSaleable() && !$controlledProduct): ?>
                                    <?php $postParams = $block->getAddToCartPostParams($_product); ?>
                                    <form data-role="tocart-form" action="<?php /* @escapeNotVerified */ echo $postParams['action']; ?>" method="post">

                                    <div class="quantity">
                                        <!-- <input type="text" name="qty" class="input-text qty" value="1"/> -->
                                        <input class="input-text qty mod" type="number" name="qty" id="qty" maxlength="12" value="1">
                                    </div>
                                        <input type="hidden" name="product" value="<?php /* @escapeNotVerified */ echo $postParams['data']['product']; ?>">
                                        <input type="hidden" name="<?php /* @escapeNotVerified */ echo Action::PARAM_NAME_URL_ENCODED; ?>" value="<?php /* @escapeNotVerified */ echo $postParams['data'][Action::PARAM_NAME_URL_ENCODED]; ?>">
                                        <?php echo $block->getBlockHtml('formkey')?>
                                        <button class="add-to-cart action tocart" type="submit"
                                                title="<?php echo $block->escapeHtml(__('Add')); ?>"
                                               >
                                        <?php
                                       
                                        $stockState = $objectManager->get('\Magento\CatalogInventory\Api\StockStateInterface');
                                        $stockQuantity = $stockState->getStockQty($_product->getId(), $_product->getStore()->getWebsiteId());
                                        $i = 0;
                                        if($stockQuantity == 0){
                                            $i = 1;
                                            $buttonTitle = __('Request'); 
                                        }else{
                                            $i = 2;
                                            $buttonTitle = __('   Add'); 
                                        }
                                        ?>
                                            <span>
                                            <?php if($i == 2){ ?>
                                                <i class="fa fa-cart-plus" aria-hidden="true"></i>
                                            <? } ?>

                                            <?php /* @escapeNotVerified */ echo $buttonTitle; ?></span>
                                        </button>
                                    </form>

                            <!--END ADD TO CART MECH-->
                                    <?php else: ?>
                            <!--Enquiry Trigger-->
getName(); ?>','getSku();?>');">
                            <!--Enquiry Trigger End-->
                                <?php endif; ?>

                            </div>
                            <div class="quantity-available mobile">
                            <?php
                                                     $StockQuantity = $StockState->getStockQty($_product->getId(), $_product->getStore()->getWebsiteId());
                            ?>
                                <?php echo __("Quantity Available")?>: <?php echo $StockQuantity; ?> 
                            </div>
                        
                            <!--Attributes-->
                            <!--Hide product function container-->
                            <div><?php echo $block->getProductDetailsHtml($_product); ?></div>
                        </div>
                    </div><?php //end col1 ?>
                    <div class="product-item-col2">
                        <div class="product-price">
                        <?php /* @escapeNotVerified */ echo $block->getProductPrice($_product) ?>
                        </div>
                    </div>
                    <div class="product-item-col3">
                   <!--REAL ADD TO CART MECHANISM-->
                            <?php if ($_product->isSaleable() && !$controlledProduct): ?>
                            <?php
                                   //real
                                    $stockState = $objectManager->get('\Magento\CatalogInventory\Api\StockStateInterface');
                                    $stockQuantity = $stockState->getStockQty($_product->getId(), $_product->getStore()->getWebsiteId());
                                    $i = 0;    
                                    if($stockQuantity == 0){
                                        $i = 1;
                                        $buttonTitle = __('Request'); 
                                    }else{
                                        $i = 2;
                                        $buttonTitle = __('   Add'); 
                                    }
                                    ?>

                                    <?php $postParams = $block->getAddToCartPostParams($_product); ?>
                                    <form data-role="tocart-form" action="<?php /* @escapeNotVerified */ echo $postParams['action']; ?>" method="post">

                                    <div class="quantity">
                                        <!-- <input type="number" name="qty" class="input-text qty" value="1"/> -->

                                        <input class="input-text qty mod" type="number" name="qty" id="qty" maxlength="12" value="1">
                                    </div>
                                        <input type="hidden" name="product" value="<?php /* @escapeNotVerified */ echo $postParams['data']['product']; ?>">
                                        <input type="hidden" name="<?php /* @escapeNotVerified */ echo Action::PARAM_NAME_URL_ENCODED; ?>" value="<?php /* @escapeNotVerified */ echo $postParams['data'][Action::PARAM_NAME_URL_ENCODED]; ?>">
                                        <input type="hidden" name="requesttype" value="<?php /* @escapeNotVerified */ echo $buttonTitle; ?>">
                                        <?php echo $block->getBlockHtml('formkey')?>
                                        <button class="add-to-cart action tocart" type="submit"
                                                title="<?php echo $block->escapeHtml(__('Add')); ?>"
                                               >
                                   
                                            <span>
                                            <?php if($i == 2){ ?>
                                                <i class="fa fa-cart-plus" aria-hidden="true"></i>
                                            <? } ?>
                                            

                                            <?php /* @escapeNotVerified */ echo $buttonTitle; ?></span>
                        
                                        </button>
                    <div class="quantity-available 11"> 
                    <?php echo __("Quantity Available");?>: <?php echo $StockQuantity;?>
                    </div>
                    <div id='error-validation-clearall' style='color:red' class='error_validation-cartcustom-<?php echo $_product->getId();?>'></div>
                                    </form>
                                 
                            <!--END ADD TO CART MECH-->
                <?php else: ?>
            <!--Enquiry Trigger-->
        <button class="add-to-cart quote" type="submit" onclick="openQuoteModal('<?php echo $_product->getName(); ?>','<?php echo $_product->getSku();?>');">
            <span><?php echo __("Request Quote"); ?></span>
        </button>
            
            <!--Enquiry Trigger End-->
                <?php endif; ?> 
                    </div>

                      
                    
                </div><!--end product-item-->
            <?php endforeach; ?>
        
    </div><!-- end product-list-table -->
</div>
    
    
</div><!-- end product-grid-->
<!--Pager for infinite scroll-->
<div style="display:none;"><?php echo $block->getToolbarHtml() ?></div>
<?php if (!$block->isRedirectToCartEnabled()) : ?>
    <script type="text/x-magento-init">
    {
        "[data-role=tocart-form], .form.map.checkout": {
            "catalogAddToCart": {}
        }
    }
    </script>
<?php endif; ?>
2
  • seems like you do not have a starting "if():" Aug 26, 2021 at 7:43
  • Please share full code. I think somewhere if closing tag is missing.
    – Gulshan
    Aug 26, 2021 at 8:33

2 Answers 2

0

Comment That line like this one :

<?php //else: ?>

Then clear the cache and then check.

0

Check at line: 274 replace with:

if($controlledAttribute) {
                            if("Magento\Framework\Phrase" == get_class($controlledAttribute->getFrontend()->getValue($_product))):
                                $controlledProduct = $controlledAttribute->getFrontend()->getValue($_product)->getText() == "Yes";
                            else:
                                $controlledProduct = $controlledAttribute->getFrontend()->getValue($_product);
                            endif;
                        }

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.