composer.json
{
"name": "learning/module-contact",
"description": "contact",
"require": {
"php": "~5.5.0|~5.6.0|~7.0.0",
"magento/framework": "100.0.*",
"magento/module-ui": "100.0.*",
"magento/module-config": "100.0.*",
"magento/module-contact": "100.0.*"
},
"type": "magento2-module",
"version": "100.0.0",
"license": [
"OSL-3.0",
"AFL-3.0"
],
"autoload": {
"files": [ "registration.php" ],
"psr-4": {
"Learning\\Contact\\": ""
}
}
}
registration.php
\Magento\Framework\Component\ComponentRegistrar::register(
\Magento\Framework\Component\ComponentRegistrar::MODULE,
'Learning_Contact',
__DIR__
);
module.xml
<?xml version="1.0"?>
<config xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="urn:magento:framework:Module/etc/module.xsd">
<module name="Learning_Contact" setup_version="2.0.0">
<sequence>
<module name="Magento_Contact"/>
</sequence>
</module>
</config>
Edit.php
namespace Learning\Contact\Block\Address;
class Edit extends \Magento\Customer\Block\Address\Edit
{
/**
* Registry
*
* @var \Magento\Framework\Registry
*/
protected $_registry;
public function __construct(
\Magento\Framework\View\Element\Template\Context $context,
\Magento\Directory\Helper\Data $directoryHelper,
\Magento\Framework\Json\EncoderInterface $jsonEncoder,
\Magento\Framework\App\Cache\Type\Config $configCacheType,
\Magento\Directory\Model\ResourceModel\Region\CollectionFactory $regionCollectionFactory,
\Magento\Directory\Model\ResourceModel\Country\CollectionFactory $countryCollectionFactory,
\Magento\Customer\Model\Session $customerSession,
\Magento\Customer\Api\AddressRepositoryInterface $addressRepository,
\Magento\Customer\Api\Data\AddressInterfaceFactory $addressDataFactory,
\Magento\Customer\Helper\Session\CurrentCustomer $currentCustomer,
\Magento\Framework\Api\DataObjectHelper $dataObjectHelper,
\Magento\Framework\Registry $registry,
array $data = []
){
$this->_registry = $registry;
parent::__construct($context, $directoryHelper, $jsonEncoder, $configCacheType, $regionCollectionFactory, $countryCollectionFactory, $customerSession, $addressRepository, $addressDataFactory, $currentCustomer, $dataObjectHelper, $data);
}
public function _toHtml()
{
if ($this->getTemplate() == 'address/edit.phtml')
{
$this->setTemplate('Magento_Customer::address/edit.phtml');
$editHtml = $this->fetchView($this->getTemplateFile());
$htmlToInsertAfter = ''. __('Address') .'';
$this->setTemplate('Learning_Contact::custom.phtml');
$addressCandidatesHtml = $this->fetchView($this->getTemplateFile());
return $editHtml.$addressCandidatesHtml;
//return substr_replace($editHtml, $addressCandidatesHtml, strpos($editHtml, $htmlToInsertAfter)+strlen($htmlToInsertAfter),0);
}
return parent::_toHtml();
}
}
I think you need remove params 6 in addForeignKey function because in:
/**
* Add Foreign Key to table
*
* @param string $fkName the foreign key name
* @param string $column the foreign key column name
* @param string $refTable the reference table name
* @param string $refColumn the reference table column name
* @param string $onDelete the action on delete row
* @return $this
* @throws \Zend_Db_Exception
* @SuppressWarnings(PHPMD.CyclomaticComplexity)
*/
public function addForeignKey($fkName, $column, $refTable, $refColumn, $onDelete = null)
{
$upperName = strtoupper($fkName);
// validate column name
if (!isset($this->_columns[strtoupper($column)])) {
throw new \Zend_Db_Exception('Undefined column "' . $column . '"');
}
switch ($onDelete) {
case self::ACTION_CASCADE:
case self::ACTION_RESTRICT:
case self::ACTION_SET_DEFAULT:
case self::ACTION_SET_NULL:
break;
default:
$onDelete = self::ACTION_NO_ACTION;
}
$this->_foreignKeys[$upperName] = [
'FK_NAME' => $fkName,
'COLUMN_NAME' => $column,
'REF_TABLE_NAME' => $refTable,
'REF_COLUMN_NAME' => $refColumn,
'ON_DELETE' => $onDelete
];
return $this;
}
Best Answer
catalog_product_view.xml