cancel
Showing results for 
Search instead for 
Did you mean: 

Changes to module not reflected to magento

Changes to module not reflected to magento

Hi,

 

I have written a small module myself. It is quite buggy, so I change every now and then some lines in the source code.

After changing the source, the change works for exactly one time, then the changes do not work any more and it seems that the old code is used once again. When I then edit the source again (the source is still the source AFTER the changes), w.g. when I insert a blank line, same behaviour: One single time new code, then old code.

 

Any hints from you?

 

Regards,
Gunther

5 REPLIES

Re: Changes to module not reflected to magento

Hi @kornblumenapo,

 

Maybe you need to recompile the code?

https://devdocs.magento.com/guides/v2.2/config-guide/cli/config-cli-subcommands-compiler.html

 

On which mode are you executing the store/code? https://devdocs.magento.com/guides/v2.2/config-guide/cli/config-cli-subcommands-mode.html

--
If you've found one of my answers useful, please give "Kudos" or "Accept as Solution"

Re: Changes to module not reflected to magento

Hi @kornblumenapo

 

i understand the problem you are facing !!

 

Generally in magento 2 when we are using factory method or any generation/proxy classes in our custom module , we must required to compile our code again and again !

 

or another option is we need to remove generated, var/generation directory from the magento 2 root folder. as factory and proxy classes are generating each and every time when you load module or you compile module !

 

So here whatever the problem you are facing - its because of compilation only.

 

if you change anything related to those classes you required to run below commands :

 

 

php bin/magento setup:di:compile
php bin/magento cache:clean
php bin/magento cache:flush

 
Hope it helps !

if issue solved,Click Kudos & Accept as Solution

Re: Changes to module not reflected to magento

Hello @kornblumenapo

 

If you are doing development then disable compilation first.

 

Then remove generated/generation and  generated/matadata

 

Then check it.

 

Hope it will help you.

Re: Changes to module not reflected to magento

still the same problem... strange behaviour...

Re: Changes to module not reflected to magento

Here's the code:

if (!$order->getShipmentsCollection()) 
			{
					$this->messageManager->addError("There are no printable Shipment related to selected orders ".$order->getIncrementID());
					//echo ("NOT FOREACH");
			}
			else
			{
				$this->messageManager->addNotice("PZ enter:".$order->getIncrementID());
				
				foreach ($order->getShipmentsCollection() as $shipment) 
				{
					$document = $shipmentDocumentFactory->create(
						['data' => ['shipment' => $shipment]]
					);
					//echo ("FOREACH");

					$pdfRenderer->addDocument($document);
					$this->messageManager->addNotice("PZ OK für:".$order->getIncrementID());
				}
			}

It seems there is a problem in my code:
Magento enters the else branch, but foreach is not executed or only executed some times.
Any ideas?