protected function execute(InputInterface $input, OutputInterface $output)
{
$factory = $this->getContainer()->get('sylius.factory.product');
$manager = $this->getContainer()->get('sylius.manager.product');
$product = $factory->createNew();
$product
->setName('Foo')
->setDescription('Nice product');
$manager->persist($product);
$manager->flush(); // Save changes in database.
So I want to add a product from a command. But I'm always getting this Error:
PHP Fatal error: Call to a member function setDescription() on null in C:\Users\Coffee-Bike\IntelliJIDEAProjects\sylius-shop\acme\src\AppBundle\Command\Collmex\ImportProductsFromCollmexCommand.php on line 46
PHP Stack trace:
PHP 1. {main}() C:\Users\Coffee-Bike\IntelliJIDEAProjects\sylius-shop\acme\bin\console:0
PHP 2. Symfony\Component\Console\Application->run() C:\Users\Coffee-Bike\IntelliJIDEAProjects\sylius-shop\acme\bin\console:28
PHP 3. Symfony\Bundle\FrameworkBundle\Console\Application->doRun() C:\Users\Coffee-Bike\IntelliJIDEAProjects\sylius-shop\acme\vendor\symfony\symfony\src\Symfony\Component\Console\Application.php:130
PHP 4. Symfony\Component\Console\Application->doRun() C:\Users\Coffee-Bike\IntelliJIDEAProjects\sylius-shop\acme\vendor\symfony\symfony\src\Symfony\Bundle\FrameworkBundle\Console\Application.php:81
PHP 5. Symfony\Component\Console\Application->doRunCommand() C:\Users\Coffee-Bike\IntelliJIDEAProjects\sylius-shop\acme\vendor\symfony\symfony\src\Symfony\Component\Console\Application.php:223
PHP 6. Symfony\Component\Console\Command\Command->run() C:\Users\Coffee-Bike\IntelliJIDEAProjects\sylius-shop\acme\vendor\symfony\symfony\src\Symfony\Component\Console\Application.php:887
PHP 7. AppBundle\Command\Collmex\ImportProductsFromCollmexCommand->execute() C:\Users\Coffee-Bike\IntelliJIDEAProjects\sylius-shop\acme\vendor\symfony\symfony\src\Symfony\Component\Console\Command\Command.php:264
Fatal error: Call to a member function setDescription() on null in C:\Users\Coffee-Bike\IntelliJIDEAProjects\sylius-shop\acme\src\AppBundle\Command\Collmex\ImportProductsFromCollmexCommand.php on line 46
But I'm juts following this documentation here.
And this is the same procedure. What am I doing wrong?
Check the docs in The Book section here: http://docs.sylius.org/en/latest/book/products/products.html
Related
Im new to custom wordpress widget creation and im trying to create one. I created my widget at wp-content> plugins> custom-widgets> my-custom-widget.php.
This is my code
if(!class_exists("MyCustomWidget")){
class MyCustomWidget extends WP_Widget{
public function __constructor(){
parent::WP_Widget(false,"My custom Widget");
}
public function form($instance){
?>
<p>
<label>Tilte:</label>
<input type="text"/>
</p>
<?php
}
}
function register_my_widget(){
register_widget("MyCustomWidget");
}
add_action("widgets_init", "register_my_widget");
}
When im trying to activate it i get the wordpress fail page and specially the following. What is wrong?
Fatal error: Uncaught ArgumentCountError: Too few arguments to function WP_Widget::__construct(), 0
passed in F:\Downloads\Worpress\Wordpress Local\apache2\htdocs\store\wordpress\wp-includes\class-wp-
widget-factory.php on line 61 and at least 2 expected in F:\Downloads\Worpress\Wordpress
Local\apache2\htdocs\store\wordpress\wp-includes\class-wp-widget.php:162 Stack trace: #0
F:\Downloads\Worpress\Wordpress Local\apache2\htdocs\store\wordpress\wp-includes\class-wp-widget-
factory.php(61): WP_Widget->__construct() #1 F:\Downloads\Worpress\Wordpress
Local\apache2\htdocs\store\wordpress\wp-includes\widgets.php(115): WP_Widget_Factory->register() #2
F:\Downloads\Worpress\Wordpress Local\apache2\htdocs\store\wordpress\wp-content\plugins\custom-widget\wp-
custom-widget.php(34): register_widget() #3 F:\Downloads\Worpress\Wordpress
Local\apache2\htdocs\store\wordpress\wp-includes\class-wp-hook.php(287): register_my_widget() #4
F:\Downloads\Worpress\Wordpress Local\apache2\htdocs\store\wordpress\wp-includes\class-wp-hook.php(311):
WP in F:\Downloads\Worpress\Wordpress Local\apache2\htdocs\store\wordpress\wp-includes\class-wp-
widget.php on line 162
See this answer from wordpress.stackexchange.com for a full correct widget example.
There is a couple of issues with the code in this question:
It's function __construct() and not function __constructor().
As detailed in rich's answer the parent call should be to parent::__construct(..). For example: parent::__construct('', 'Widget name');
In your constructor, you need to pass 2 arguments... so something like this:
public function __constructor(){
parent::__construct('my_custom_widget',v__('My Custom Widget', 'my_text_domain'));
}
WordPress documentation here:
https://developer.wordpress.org/reference/classes/wp_widget/__construct/
I get this error. I created a button to update the table. When I click the button, I get an error. How to fix it?
Fatal error: Uncaught ArgumentCountError: Too few arguments to function personel::update_form(), 0 passed in C:\xampp\htdocs\warehouse\panel\system\core\CodeIgniter.php on line 360 and exactly 1 expected in C:\xampp\htdocs\warehouse\panel\application\controllers\personel.php:57 Stack trace: #0 C:\xampp\htdocs\warehouse\panel\system\core\CodeIgniter.php(360): personel->update_form() #1 C:\xampp\htdocs\warehouse\panel\index.php(202): require_once('C:\xampp\htdocs...') #2 {main} thrown in C:\xampp\htdocs\warehouse\panel\application\controllers\personel.php on line 57
Fİle Name: personel.php Controller
MY CODES
public function update_form($id){
$where = array( "id" => $id);
$personel = $this->Personel_model->get($where);
$viewData["personel"] = $personel;
$this->load->view("personel_edit");
}
MY BUTTON CODES
Update
You must pass an ID with the button to function in the controller like this.
Update
When I run the command php artisan:make migration, I have this error :
PHP Fatal error: Declaration of NunoMaduro\Collision\Writer::write(Whoops\Exception\Inspector $inspector): NunoMaduro\Collision\void must be compatible with NunoMaduro\Collision\Contracts\Writer::write(Whoops\Exception\Inspector $inspector): NunoMaduro\Collision\Contracts\void in /home/gregory/folbet/vendor/nunomaduro/collision/src/Writer.php on line 27
Symfony\Component\Debug\Exception\FatalErrorException : Declaration of NunoMaduro\Collision\Writer::write(Whoops\Exception\Inspector $inspector): NunoMaduro\Collision\void must be compatible with NunoMaduro\Collision\Contracts\Writer::write(Whoops\Exception\Inspector $inspector): NunoMaduro\Collision\Contracts\void
at /home/gregory/folbet/vendor/nunomaduro/collision/src/Writer.php:27 23| * This is an Collision Writer implementation.
24| * 25| * #author Nuno Maduro <enunomaduro#gmail.com>
26| */ > 27| class Writer implements WriterContract 28| {
29| /** 30| * The number of frames if no verbosity is specified. 31| */
PHP Fatal error: Uncaught TypeError: Return value of NunoMaduro\Collision\Writer::write() must be an instance of NunoMaduro\Collision\void, none returned in /home/gregory/folbet/vendor/nunomaduro/collision/src/Writer.php:114
Stack trace:
#0 /home/gregory/folbet/vendor/nunomaduro/collision/src/Handler.php(48): NunoMaduro\Collision\Writer->write(Object(NunoMaduro\Collision\Adapters\Laravel\Inspector))
#1 /home/gregory/folbet/vendor/nunomaduro/collision/src/Adapters/Laravel/ExceptionHandler.php(86): NunoMaduro\Collision\Handler->handle()
#2 /home/gregory/folbet/vendor/laravel/framework/src/Illuminate/Foundation/Bootstrap/HandleExceptions.php(101): NunoMaduro\Collision\Adapters\Laravel\ExceptionHandler->renderForConsole(Object(Symfony\Component\Console\Output\ConsoleOutput), Object(Symfony\Component\Debug\Exception\FatalErrorException))
#3 /home/gregory/folbet/vendor/laravel/framework/src/Illuminate/Foundation/Bootstrap/HandleExceptions.php(87): Illuminate\Foundation\Bootstrap\HandleExceptions->renderForConsole(Object(Symfony\Com in /home/gregory/folbet/vendor/nunomaduro/collision/src/Writer.php on line 114
How can I fix it ?
My Laravel version is 5.6.* and my PHP version is ^7.1.3
I just uninstalled 2 extension from magento connect and end up with a 3rd extension fatal error.
http://nutrija.com
Front end of magento is throwing just a white page.
backend - is working normally.
i have already tried disabling "Webinse_DailyDeals" extension, removing that 16th line of code. But no luck.
ERROR LOG: [Sun Mar 27 08:11:38 2016] [error] [client 59.96.113.41]
PHP Fatal error: Uncaught Error: Call to a member function addLink()
on null in
/home/nutrija/public_html/includes/src/Webinse_DailyDeals_Block_Links.php:16
Stack trace:
0 /home/nutrija/public_html/includes/src/__default.php(27948): Webinse_DailyDeals_Block_Links->addDealLink('dailydeals_link...')
1 /home/nutrija/public_html/includes/src/__default.php(27814): Mage_Core_Model_Layout->_generateAction(Object(Mage_Core_Model_Layout_Element), Object(Mage_Core_Model_Layout_Element))
2 /home/nutrija/public_html/includes/src/__default.php(27806): Mage_Core_Model_Layout->generateBlocks(Object(Mage_Core_Model_Layout_Element))
3 /home/nutrija/public_html/includes/src/__default.php(27810): Mage_Core_Model_Layout->generateBlocks(Object(Mage_Core_Model_Layout_Element))
4 /home/nutrija/public_html/includes/src/__default.php(27810): Mage_Core_Model_Layout->generateBlocks(Object(Mage_Core_Model_Layout_Element))
5 /home/nutrija/public_html/includes/src/__default.php(13941): Mage_Core_Model_Layout->generateBlocks()
6 /home/nutrija/public in /home/nutrija/public_html/includes/src/Webinse_DailyDeals_Block_Links.php
on line 16
<?php
/**
* AddDealsLink Block
*
* #category Webinse
* #package Webinse_DailyDeals
* #author Webinse Team <info#webinse.com.com>
*/
class Webinse_DailyDeals_Block_Links extends Mage_Core_Block_Template
{
public function addDealLink()
{
$parentBlock = $this->getParentBlock();
$text = $this->helper('dailydeals')->getDealsConfig('dailydeals_group/label_deals_link');
$parentBlock->addLink($text, 'dailydeals/', $text, true, array(), 1, null, 'class="top-link-deals"');
return $this;
}
}
First, try to turn off compilation. Next, check why the $parentBlock not exists in your layout.
I'm a prestashop developper and i want to add my custom function using parameters in a smarty variable.
There's my PHP function
function maFonctionSMarty($params)
{
$array['1'] = $params['monParametre'];
$array['2'] = $params['monParametre1'];
return $array;
}
and in m'y template i try to do this
{$a|maFonctionSMarty:"toto":"tata"}
and i have an error.
Fatal error: Uncaught exception 'SmartyCompilerException' with message 'Syntax Error in template "/Users/guillaume/Sites/prestashop_156/modules/wb_newsletter/admin_panel.tpl" on line 94 "{$a|maFonctionSMarty:"toto":"tata"}" unknown modifier "maFonctionSMarty"' in /Users/guillaume/Sites/prestashop_156/tools/smarty/sysplugins/smarty_internal_templatecompilerbase.php:667 Stack trace: #0 /Users/guillaume/Sites/prestashop_156/tools/smarty/sysplugins/smarty_internal_compile_private_modifier.php(132): Smarty_Internal_TemplateCompilerBase->trigger_template_error('unknown modifie...', 94) #1 /Users/guillaume/Sites/prestashop_156/tools/smarty/sysplugins/smarty_internal_templatecompilerbase.php(475): Smarty_Internal_Compile_Private_Modifier->compile(Array, Object(Smarty_Internal_SmartyTemplateCompiler), Array, NULL, NULL) #2 /Users/guillaume/Sites/prestashop_156/tools/smarty/sysplugins/smarty_internal_templatecompilerbase.php(259): Smarty_Internal_TemplateCompilerBase->callTagCompil in /Users/guillaume/Sites/prestashop_156/tools/smarty/sysplugins/smarty_internal_templatecompilerbase.php on line 667
[PrestaShop] Fatal error in module smarty_internal_templatecompilerbase:
Uncaught exception 'SmartyCompilerException' with message 'Syntax Error in template "/Users/guillaume/Sites/prestashop_156/modules/wb_newsletter/admin_panel.tpl" on line 94 "{$a|maFonctionSMarty:"toto":"tata"}" unknown modifier "maFonctionSMarty"' in /Users/guillaume/Sites/prestashop_156/tools/smarty/sysplugins/smarty_internal_templatecompilerbase.php:667 Stack trace: #0 /Users/guillaume/Sites/prestashop_156/tools/smarty/sysplugins/smarty_internal_compile_private_modifier.php(132): Smarty_Internal_TemplateCompilerBase->trigger_template_error('unknown modifie...', 94) #1 /Users/guillaume/Sites/prestashop_156/tools/smarty/sysplugins/smarty_internal_templatecompilerbase.php(475): Smarty_Internal_Compile_Private_Modifier->compile(Array, Object(Smarty_Internal_SmartyTemplateCompiler), Array, NULL, NULL) #2 /Users/guillaume/Sites/prestashop_156/tools/smarty/sysplugins/smarty_internal_templatecompilerbase.php(259): Smarty_Internal_TemplateCompilerBase->callTagCompil
thanks
You have to put that function as a plugin in a separate file named modifier.maFonctionSMarty.php in tools/smarty/plugins. Also, the name of the function has to be different:
function smarty_modifier_maFonctionSMarty($params)