0

I have created 2 attributes for my products, attribute1 and attribute2, both are multi-select dropdowns. What I wanted to achieve is that the second attribute values changes based on the options selected in the first attribute.

Suppose in attribute1 some abc is selected, in attribute2 some 'asa','asd','asd' these should be available. something like City and Area. If a particular city is selected, the area in that city should be listed there in 2nd dropdown.

I have a separate table for all the links between these attributes.

Layout File(catalog_product_edit);

<?xml version="1.0"?>
<page xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="urn:magento:framework:View/Layout/etc/page_configuration.xsd">
    <body>
        <referenceContainer name="content">
            <block class="Vendor\Module\Block\Adminhtml\Catalog\Product\Edit\Myfle" 
                    name="module_block_adminhtml_catalog_product_edit_myfile"
                    template="Vendor_Module::module_product_dw.phtml">
            </block>
        </referenceContainer>
    </body>
</page>

Block File:

<?php
namespace Vendor\Module\Block\Adminhtml\Catalog\Product\Edit\Myfile;
class Myfile extends \Magento\Backend\Block\Template
{
    public function __construct(
        \Magento\Backend\Block\Template\Context $context,
        array $data = [] )
    {
        $this->urlBuilder = $context->getUrlBuilder();
        parent::__construct($context, $data);
    }
}

All are the files and folder structure is correct? coz am getting a strange error Parse error: syntax error, unexpected 'class' (T_CLASS) in ......./Block/Adminhtml/Catalog/Product/Edit/Myfile.php on line 7

Note: PHP version is fine(5.6). And also Other blocks loaded without any problem.

Am stuck here.Please help how to do this?

0

Please try to complete php tag for your block file as follows

<?php
namespace Vendor\Module\Block\Adminhtml\Catalog\Product\Edit\Myfile;
class Myfile extends \Magento\Backend\Block\Template
{
    public function __construct(
        \Magento\Backend\Block\Template\Context $context,
        array $data = [] )
    {
        $this->urlBuilder = $context->getUrlBuilder();
        parent::__construct($context, $data);
    }
}
?>
  • The closing ?> tag MUST be omitted from files containing only PHP. See coding standards here – subroutines May 18 '17 at 0:47

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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