1 | <?php |
||
29 | class Products extends AbstractUrlRewriteCommand |
||
30 | { |
||
31 | |||
32 | /** |
||
33 | * Name of product input option |
||
34 | */ |
||
35 | const INPUT_PRODUCT = 'product'; |
||
36 | |||
37 | /** |
||
38 | * Force of force input option |
||
39 | */ |
||
40 | const INPUT_FORCE = 'force'; |
||
41 | |||
42 | /** |
||
43 | * Name of product input option |
||
44 | */ |
||
45 | const INPUT_STORE = 'store'; |
||
46 | |||
47 | /** |
||
48 | * @var \Magento\Catalog\Model\ResourceModel\Product\Collection |
||
49 | */ |
||
50 | protected $_collection = null; |
||
51 | |||
52 | /** |
||
53 | * Collections to process |
||
54 | */ |
||
55 | protected $_collections = []; |
||
56 | |||
57 | |||
58 | /** |
||
59 | * {@inheritdoc} |
||
60 | */ |
||
61 | protected function configure() |
||
83 | |||
84 | /** |
||
85 | * {@inheritdoc} |
||
86 | */ |
||
87 | protected function execute(InputInterface $input, OutputInterface $output) |
||
110 | |||
111 | /** |
||
112 | * Generate product url by product |
||
113 | * @param $args |
||
114 | */ |
||
115 | public function callbackGenerateProductUrl($args) |
||
144 | |||
145 | /** |
||
146 | * Remove Product urls |
||
147 | * |
||
148 | * @param $productId |
||
149 | * @param null $storeId |
||
150 | * @return bool |
||
151 | */ |
||
152 | protected function removeProductUrls($productId, $storeId = null) |
||
173 | |||
174 | /** |
||
175 | * Generate list of product urls |
||
176 | * |
||
177 | * @param $product |
||
178 | * @return array |
||
179 | */ |
||
180 | private function prepareUrls($product) |
||
184 | |||
185 | /** |
||
186 | * Get Product Url Generator |
||
187 | * |
||
188 | * @return \Magento\CatalogUrlRewrite\Model\ProductUrlRewriteGenerator |
||
189 | */ |
||
190 | protected function getProductUrlRewriteGenerator() |
||
194 | |||
195 | |||
196 | |||
197 | /** |
||
198 | * Prepare Collections to process |
||
199 | * |
||
200 | * @param $storeId |
||
201 | * @param $productIds |
||
202 | * @throws \Exception |
||
203 | */ |
||
204 | protected function prepareCollections($storeId, $productIds) |
||
225 | |||
226 | /** |
||
227 | * Get product collection |
||
228 | * |
||
229 | * @return \Magento\Catalog\Model\ResourceModel\Product\Collection |
||
230 | */ |
||
231 | protected function getProductCollection() |
||
239 | |||
240 | /** |
||
241 | * Filter collection by product ID |
||
242 | * |
||
243 | * @param null $productIds |
||
244 | */ |
||
245 | private function addFilterProductIds($productIds = null) |
||
252 | |||
253 | /** |
||
254 | * Filter Collection by Store |
||
255 | * |
||
256 | * @param null $storeId |
||
257 | */ |
||
258 | private function addStoreFilter($storeId = null) |
||
267 | |||
268 | /** |
||
269 | * Add collection to process |
||
270 | * |
||
271 | * @param \Magento\Catalog\Model\ResourceModel\Product\Collection $collection |
||
272 | * @param $storeId |
||
273 | */ |
||
274 | protected function addCollections(\Magento\Catalog\Model\ResourceModel\Product\Collection $collection, $storeId) |
||
278 | |||
279 | /** |
||
280 | * Number of Items to process |
||
281 | * |
||
282 | * @return int |
||
283 | */ |
||
284 | protected function getSizeToProcess() |
||
292 | |||
293 | /** |
||
294 | * Rebuild Urls |
||
295 | */ |
||
296 | protected function rebuildUrls() |
||
310 | |||
311 | /** |
||
312 | * Create product factory |
||
313 | * |
||
314 | * @return \Magento\Catalog\Model\ProductFactory |
||
315 | */ |
||
316 | protected function getProductFactory() |
||
320 | } |
If you define a variable conditionally, it can happen that it is not defined for all execution paths.
Let’s take a look at an example:
In the above example, the variable $x is defined if you pass “foo” or “bar” as argument for $a. However, since the switch statement has no default case statement, if you pass any other value, the variable $x would be undefined.
Available Fixes
Check for existence of the variable explicitly:
Define a default value for the variable:
Add a value for the missing path: