This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| private $logger; | |
| public function __construct(\Psr\Log\LoggerInterface $logger) | |
| { | |
| $this->logger = $logger; | |
| } | |
| public function doSomething() | |
| { | |
| try { |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| /* | |
| * Controller | |
| */ | |
| // $_SERVER | |
| $this->getRequest()->getServer('SERVER_NAME'); | |
| // $_GET | |
| $this->getRequest()->getParams(); | |
| $this->getRequest()->getParam('getparam'); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| public function __construct( | |
| \Magento\Framework\App\ResourceConnection $resource | |
| ) { | |
| $this->connection = $resource->getConnection(); | |
| $this->resource = $resource; | |
| } | |
| public function sampleMethod() | |
| { | |
| $tableName = $this->resource->getTableName(self::TABLE_NAME); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| private $_objectManager; | |
| public function __construct( | |
| \Magento\Framework\ObjectManagerInterface $objectManager, | |
| \Psr\Log\LoggerInterface $logger | |
| ) { | |
| $this->_objectManager = $objectManager; | |
| $this->logger = $logger; | |
| } | |
| $resource = $this->_objectManager->create('\Magento\Framework\App\ResourceConnection'); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| public function __construct( | |
| \Magento\Framework\App\ResourceConnection $resource | |
| ) { | |
| $this->connection = $resource->getConnection(); | |
| $this->resource = $resource; | |
| } | |
| $select = $this->connection | |
| ->select() | |
| ->from($this->tableName) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| DELETE FROM catalog_product_entity_int WHERE store_id <> 0; | |
| DELETE FROM catalog_product_entity_varchar WHERE store_id <> 0; | |
| DELETE FROM catalog_product_entity_text WHERE store_id <> 0; | |
| DELETE FROM catalog_product_entity_decimal WHERE store_id <> 0; | |
| DELETE FROM catalog_product_entity_datetime WHERE store_id <> 0; | |
| DELETE FROM catalog_category_entity_int WHERE store_id <> 0; | |
| DELETE FROM catalog_category_entity_varchar WHERE store_id <> 0; | |
| DELETE FROM catalog_category_entity_text WHERE store_id <> 0; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Remove theme.css from pub/static | |
| bin/magento dev:source-theme:deploy --type="css" --locale="en_GB" --area="frontend" --theme="Xigen/Theme" css/theme | |
| Processed Area: frontend, Locale: en_GB, Theme: Xigen/Theme, File type: css. | |
| -> css/theme.css | |
| Successfully processed. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| protected $productFactory; | |
| protected $product; | |
| protected $productAction; | |
| public function __construct( | |
| \Magento\Catalog\Model\ProductFactory $productFactory, | |
| \Magento\Catalog\Model\ResourceModel\Product $product, | |
| \Magento\Catalog\Model\Product\Action $action | |
| ) { | |
| $this->productFactory = $productFactory; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| composer require symfony/var-dumper | |
| \Symfony\Component\VarDumper\VarDumper::dump($var); | |
| use Symfony\Component\VarDumper\VarDumper; | |
| VarDumper::dump($var); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| // quick log | |
| $writer = new \Zend\Log\Writer\Stream(BP . '/var/log/test.log'); | |
| $logger = new \Zend\Log\Logger(); | |
| $logger->addWriter($writer); | |
| $logger->info('Your text message'); | |
| // 2.4.3 + syntax | |
| $writer = new \Zend_Log_Writer_Stream(BP . '/var/log/test.log'); | |
| $logger = new \Zend_Log(); | |
| $logger->addWriter($writer); |